I have built a custom made beats based on libbeat and I want to use environment variable as a value in the config file. However, if I type ${VAR} in the config file and I run config test, I got:
./countbeat -c countbeat.yml --configtest
Exiting: error unpacking config data: missing field accessing 'name' (source:'countbeat.yml')
I tried in line of configuring the name of the shipper:
name: "${HOSTNAME}"
And it works if I change it into a static string:
name: "a_name"
I have tried to use the filebeat (v1.2.3) and the syntax works. Have I made any mistake in building the beats? Thank you.
With beats 5.0, variable expansion will check if environment variable is available and fail if no default is set. In beats 1.x a missing environment variable will just be ignored.
this might work for you:
name: '${HOSTNAME:localhost}'
if HOSTNAME is not set it will expand into "localhost".
In 5.0 you can try to print a custom error if HOSTNAME is missing via:
name: ${HOSTNAME:?Please set HOSTNAME environment variable}
in beats 5.0 one can also overwrite any setting from command line via -E flag. For example:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.