# Config files unable to acess env variable value in Ubuntu

**URL:** <https://discuss.elastic.co/t/config-files-unable-to-acess-env-variable-value-in-ubuntu/69427>\
**Category:** Logstash\
**Created:** [December 19, 2016, 11:06am UTC](https://discuss.elastic.co/t/config-files-unable-to-acess-env-variable-value-in-ubuntu/69427 "2016-12-19T11:06:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ezequielo](https://avatars.discourse-cdn.com/v4/letter/e/b2d939/32.png) [@ezequielo](https://discuss.elastic.co/u/ezequielo)\
**Post date:** [December 19, 2016, 11:06am UTC](https://discuss.elastic.co/t/config-files-unable-to-acess-env-variable-value-in-ubuntu/69427/1 "2016-12-19T11:06:03Z")

</div>

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](https://logstash.jira.com/browse/LOGSTASH-1399) but I am not able to find any workaround.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 19, 2016, 11:59am UTC](https://discuss.elastic.co/t/config-files-unable-to-acess-env-variable-value-in-ubuntu/69427/2 "2016-12-19T11:59:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ezequielo](https://avatars.discourse-cdn.com/v4/letter/e/b2d939/32.png) [@ezequielo](https://discuss.elastic.co/u/ezequielo)\
**Post date:** [December 19, 2016, 12:04pm UTC](https://discuss.elastic.co/t/config-files-unable-to-acess-env-variable-value-in-ubuntu/69427/3 "2016-12-19T12:04:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 19, 2016, 12:17pm UTC](https://discuss.elastic.co/t/config-files-unable-to-acess-env-variable-value-in-ubuntu/69427/4 "2016-12-19T12:17:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ezequielo](https://avatars.discourse-cdn.com/v4/letter/e/b2d939/32.png) [@ezequielo](https://discuss.elastic.co/u/ezequielo)\
**Post date:** [December 19, 2016, 12:35pm UTC](https://discuss.elastic.co/t/config-files-unable-to-acess-env-variable-value-in-ubuntu/69427/5 "2016-12-19T12:35:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ezequielo](https://avatars.discourse-cdn.com/v4/letter/e/b2d939/32.png) [@ezequielo](https://discuss.elastic.co/u/ezequielo)\
**Post date:** [December 20, 2016, 9:17am UTC](https://discuss.elastic.co/t/config-files-unable-to-acess-env-variable-value-in-ubuntu/69427/6 "2016-12-20T09:17:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 17, 2017, 9:17am UTC](https://discuss.elastic.co/t/config-files-unable-to-acess-env-variable-value-in-ubuntu/69427/7 "2017-01-17T09:17:35Z")

</div>

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