Config files unable to acess env variable value in Ubuntu


(E) #1

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.


(Magnus Bäck) #2

Which version of Logstash? How are you setting the environment variables? How are you starting Logstash?


(E) #3

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


(Magnus Bäck) #4

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).


(E) #5

I have checked if the process has env variables in both cases

    1. /etc/environment and with
    1. /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?


(E) #6

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


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.