I am trying to use environment variables so I don't need to change my config files for every environment. So far, in my local Windows environment I was able to do it without problems. But it seems like in Linux/ubuntu there is some issue accessing environment variables.
I have seen this might be the problem https://logstash.jira.com/browse/LOGSTASH-1399 but I am not able to find any workaround.
Which version of Logstash? How are you setting the environment variables? How are you starting Logstash?
Logstash version is 5.1.1
I am setting the environment variables in Ubuntu in /etc/environment like this:
...
DRIVER_CLASS=com.mysql.jdbc.Driver
DB_URL=jdbc:mysql://localhost:3306/mydb
...
I have installed logstash via the.deb file. So I start it using sudo service logstash start command
I'm not completely sure /etc/environment is effective here, but to be sure you can access the environment of the running Logstash process via the /proc file system. Normally one modifies /etc/default/logstash to set environment variables to affect the Logstash service (but this might be different is you use systemd).
I have checked if the process has env variables in both cases
-
- /etc/environment and with
-
- /etc/default/logstash
But none of the options really worked, actually /etc/default/logstash is empty in my case so I guess they must be defined somewhere else.
Maybe I should install logstash in a different way? What do you recommend me?
Seems like the problem was the variables definition; In /etc/environment I usually write it like this:
myvar=value
But in /etc/default/logstash you have to use export:
export myvar=value
I also reinstalled all the packages just in case there was a problem.
Thanks