seqcli icon indicating copy to clipboard operation
seqcli copied to clipboard

Pickup server URL and API key from environment variables

Open yooakim opened this issue 2 years ago • 3 comments

It would be good if the SEQCLI could be updated to pickup the server URL and the API key from the environment.

I know I could modify the call and include them from my local environment. But if the SEQCLI was updated to look for default keys of SEQ_SERVER_URL and SEQ_API_KEY it would make life easier :-)

I am not sure where in the codebase this need to be added but I'd be happy to help if I could get pointers to some introduction to the code and how to contribute.

yooakim avatar Sep 05 '23 06:09 yooakim

Thanks for dropping us a line! It'd be great if we can understand the scenario a little more if possible - in which situations is it easier to consume settings from the environment rather than set them up through the config set command or command-line args?

nblumhardt avatar Sep 05 '23 07:09 nblumhardt

We are considering using the SEQCLI in a pipeline. Our templates already load keys from key vaults and in this scenario it would be less work if all we need is to install the dotnet global tool and run it.

Given that our environment variables are set.

Does this make sense?

Not a big issue... But nice if it would work.

yooakim avatar Sep 05 '23 21:09 yooakim

Sorry about the slow reply, release week here 😅.

Thanks for the additional info; yes, I think I can see how it frees up people writing scripts further down the pipeline to ignore details of how seqcli is configured 👍

Seq and Seq Forwarder both use a common convention for environment variable naming based on the matching JSON configuration fields that I think would lead us to:

SEQCLI_CONNECTION_APIKEY
SEQCLI_CONNECTION_SERVERURL
SEQCLI_OUTPUT_DISABLECOLOR
SEQCLI_OUTPUT_FORCECOLOR

(Covering the options output by seqcli config.)

There's a PR in Seq Forwarder that might be a good starting point for an approach/to avoid the couple of gotchas we encountered over there:

https://github.com/datalust/seq-forwarder/pull/57

Forwarder doesn't use nested configuration objects, so the code doesn't take that into account as far as I can recall. (Seq does do this, but it has a much more heavyweight configuration system that wouldn't really be appropriate for the CLI.)

nblumhardt avatar Sep 08 '23 05:09 nblumhardt