# Environmental variable in Logstash

**URL:** <https://discuss.elastic.co/t/environmental-variable-in-logstash/271063>\
**Category:** Logstash\
**Created:** [April 23, 2021, 9:41am UTC](https://discuss.elastic.co/t/environmental-variable-in-logstash/271063 "2021-04-23T09:41:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stillfreem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stillfreem/32/85628_2.png) [@stillfreem](https://discuss.elastic.co/u/stillfreem)\
**Post date:** [April 23, 2021, 9:41am UTC](https://discuss.elastic.co/t/environmental-variable-in-logstash/271063/1 "2021-04-23T09:41:14Z")

</div>

Hi Folks,

I use Logstash to send logs to a cloud SIEM.  
In particular I use an output plugin for the SIEM Vendor  
In order to authenticate towards the cloud Logstash presents **id** which is public and don't bother me and **key** which is kind of sensitive.  
Hence I used environmental variable in the config file and it worked like a charm.

However, I just tested it.  
For real-live scenarios I'd have to set the variable into the **bashrc** of an account that is going to be used. When I set the var in the **root**  **bashrc** Logstash can't see the variable since it runs with the **logstash** account.  
However, I can't set the variable into **logstash**  **bashrc** since this is a service account and has no interactive shell as you can see below  
` Service User:/usr/share/logstash:/usr/sbin/nologin`

Now I can set the variable in **/etc/environment** but this is a global config file and every account would see the variable which security wise doesn't seem right to be.

I read about the logstash **Secrets keystore** but in order to be password-protected I need to again use environmental variable to store the password for the keystore. Correct? Which means that it's the same situation and I'd need to set the variable in **/etc/environment**

Could you please give me your five cents on the matter?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![stillfreem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stillfreem/32/85628_2.png) [@stillfreem](https://discuss.elastic.co/u/stillfreem)\
**Post date:** [April 26, 2021, 6:25am UTC](https://discuss.elastic.co/t/environmental-variable-in-logstash/271063/2 "2021-04-26T06:25:41Z")

</div>

As an addition, I checked and I can execute single commands for user logstash, so I tested it if I can set a var in its .bashrc. However, logstash has no .bashrc file (as Service User:/usr/share/logstash:/usr/sbin/nologin)?

@Badger have you got any ideas off top of your head?

---

<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:** [May 24, 2021, 6:26am UTC](https://discuss.elastic.co/t/environmental-variable-in-logstash/271063/3 "2021-05-24T06:26:09Z")

</div>

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