i agree and understand your concern but i've tried the same with log files where i've set ENV variable and it was not working there also so i used proper path instead of ENV variable and that was working properly.
Hi harsh Thank for suggestion, but I should use env variable that is my requirement , because i can't define logstash host in every docker image , when i run docker image then i pass env variables
Please format logs, configs and terminal input/output using the </>-Button or markdown code fences. This forum uses Markdown to format posts. Without proper formatting, it can be very hard to read your posts. Proper formatting helps us to help you.
Config files using YAML are sensitive to formatting and indentation. Without proper formatting it is difficult to spot any errors in your configs.
Environment variables should work, given the variable is present and the starting service correctly passes the environment variable to the child process. How exactly do you start filebeat?
The hosts setting must be an array.
You can enforce a custom error message via:
output.logstash:
hosts: [${host:?host environment variable is not set}]
Have you updated the shipped systemd init files to pick up the environment variables?
The RPMs also install an SystemV script for some older systems. Make sure you delete/disable this file, so systemd does not pick up the wrong file by accident.
I'm also working on cent OS and checked the same on machine and found below solutions for the same.
Solution 1:
Systemctl doesn't have access the ENV file this is the reason not picking the configuration from system environment for this you can start the filebeat manually instead for "Systemctl" like below.
./filebeat -c /etc/filebeat/filebeat.yml &
it will pick the system ENV configuration and filebeat works smoothly.
Solution 2:
Go to the system filebeat service and edit vi /usr/lib/systemd/system/filebeat.service and add Environment varaiable like below.
[Service]
Environment=host=X.X.X.X:5044
and reload the daemon and start your filebeat service.
Solution 3:
Create a text file and write all variables with values like below and save the file.
Textfile
host=x.x.x.x:5044
VAR2=value2
VAR3=value3
and edit the system filebeat service and give the path of your text file as below:
[Service]
EnvironmentFile=/etc/yourtextfile
and reload the daemon and start your filebeat service.
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.