# Env variables in not working in custom fields in filebeat

**URL:** <https://discuss.elastic.co/t/env-variables-in-not-working-in-custom-fields-in-filebeat/101374>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [September 21, 2017, 5:19pm UTC](https://discuss.elastic.co/t/env-variables-in-not-working-in-custom-fields-in-filebeat/101374 "2017-09-21T17:19:27Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [September 22, 2017, 1:24pm UTC](https://discuss.elastic.co/t/env-variables-in-not-working-in-custom-fields-in-filebeat/101374/4 "2017-09-22T13:24:40Z")

</div>

> [@Rohit\_Singh](#):
>
> I have followed the same steps as above following is the output

It's not the same. You used `sudo` which does not preserve the environment for security purposes.

When you get to the point of running Filebeat as a service you will be using systemd. When a service starts it receives a clean environment (just like when you used sudo). For systemd you need to configure an override file with the environment data for the service. You can let systemd create the override file for you by running:

`systemctl edit filebeat.service`

Then configure the overrides for the service.

```auto
[Service]
Environment=CLUSTER_NAME=lokitest

```

You can use `EnvironmentFile=` if you want to point to a file with the environment variables.

---

_[View the full topic](https://discuss.elastic.co/t/env-variables-in-not-working-in-custom-fields-in-filebeat/101374)._
