Adding ability to expand environment variables used in config file#715
Conversation
7fb2cea to
0c920e6
Compare
There was a problem hiding this comment.
Is there a reason we can't use the function provided by golang? https://golang.org/pkg/os/#ExpandEnv
There was a problem hiding this comment.
os.ExpandEnv(key) is os.Expand(key, os.Getenv) and that's what this does, but with two differences. 1) It logs each replacement which is very important for end-user troubleshooting. 2) It supports setting a default value if you use the form ${var:default value}.
There was a problem hiding this comment.
That is great, especially the logging. Makes later debugging much easier.
|
I'm generally +1 on this one. I also like the other Elasticsearch config option, which is to overwrite variables from CLI with something like |
|
@tsg +1 on the -D option. I think there are 2 different use cases: Environment variables for larger deployments, client flags more for testing. Of course, one can compensate for the other. |
…nfig Adding ability to expand environment variables used in config file
|
Just curious, what's the ETA for this to be publicly available? |
|
@yoanisgil The best option to already use and test this feature is using our nightly builds: https://beats-nightlies.s3.amazonaws.com/index.html |
|
@ruflin thanks for the update. I guess I could give it a try but I was just wondering whether this is ready for production usage or not (hence my question about an ETA for public availability). |
|
@yoanisgil It will be part of the next major release, but it is hard to give an exact date. The nightly builds are quite stable, but of course I would not recommend to run them in production, as we still heavily change stuff on a daily base (and sometimes break stuff). |
|
Hi |
Adds feature requested in #114. If we choose to accept this enhancement then the documentation will need updated.
Overview
This feature replaces
${var}or$varin config files according to the values of the current environment variables.${var:default value}.Examples
name: $NAMEexport NAME=elasticname: elasticname: ${NAME}export NAME=elasticname: elasticname: ${NAME:beats}name: beatsname: ${NAME:beats}export NAME=elasticname: elastichosts: [$HOSTS]export HOSTS="'localhost:9200', 'localhost:9202'"hosts: ['localhost:9200', 'localhost:9202']Troubleshooting
When logging is enabled at the
infolevel or higher, a message is logged for each environment variable replacement. For example: