I am using Logstash v5.1.0 on Ubuntu 16.04 and my logstash conf file includes an environment variable reference to set the output graphite server, but I cannot get it to work when running as a service.
My config file contains (missing a few lines for clarity):
graphite {
host => "${GRAPHITE_SERVER}"
}
and my /etc/environment file contains:
GRAPHITE_SERVER=54.40.235.208
Yet with configuration file logging, I see:
fetched an invalid config {}
reason=>"Cannot evaluate ${GRAPHITE_SERVER}. Environment variable GRAPHITE_SERVER is not set and there is no default value given."
This does work if I run logstash from bash manually.
Any help would be much appreciated - thanks.
Andrew
I haven't tried it on 16.04 but on 14.04 it works when exporting it in /etc/default/logstash.
E.g. export GRAPHITE_SERVER=54.40.235.208.
I know, it sounds strange to prefix with export in that file, see https://github.com/elastic/logstash/issues/6414 for discussion.
14.04 uses upstart while 16.04 is using systemd, so they are probably souring the file in different ways, but it's worth a try.
Jakob - this is good news, your test worked with my currently installed 5.1.1 version, and when I tried the same with my config.
I know I tried this before and it didn't work, but I have realised I may have been confused by old errors in the logstash_plain log because my service is taking nearly 2 minutes to start (I am on an AWS instance, and although I have improved the entropy, it appears it's not yet good enough).
Anyway - all working now - thanks for your help.
Andrew
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.