# How to optimize config-files of filebeat for many different environments?

**URL:** https://discuss.elastic.co/t/how-to-optimize-config-files-of-filebeat-for-many-different-environments/322577
**Category:** Beats
**Tags:** filebeat
**Created:** [January 5, 2023, 9:03pm UTC](https://discuss.elastic.co/t/how-to-optimize-config-files-of-filebeat-for-many-different-environments/322577 "2023-01-05T21:03:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ira-zaya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ira-zaya/32/115622_2.png) [@ira-zaya](https://discuss.elastic.co/u/ira-zaya)
#### Post date: [January 5, 2023, 9:03pm UTC](https://discuss.elastic.co/t/how-to-optimize-config-files-of-filebeat-for-many-different-environments/322577/1 "2023-01-05T21:03:33Z")

</div>

We have 3 different config files for 3 envs on the project. Each env is a separate cluster. All config files are similar to each other but the one difference - field.env, which is related to environment, accordingly.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/1/911d9195ebad349b3df060a14c3c9823a86ead90.png)  
Thats why now we have a lot of value files for each env.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/5/b5b3d9e3bdb4ac4a866bed715996b823fbe8bc76.png)  
How can we optimize this? Maybe somehow leave only one value file, and override it through the helm task from external variable groups? If it possible?  
Thanks

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [January 5, 2023, 9:57pm UTC](https://discuss.elastic.co/t/how-to-optimize-config-files-of-filebeat-for-many-different-environments/322577/2 "2023-01-05T21:57:35Z")

</div>

You may use [environment variables](https://www.elastic.co/guide/en/beats/filebeat/current/using-environ-vars.html) in your configuration files.

This is how I did a couple of years ago, had something like this:

```auto
fields:
    env: "${HOST_ENV}"
    dc: "${HOST_DC}"

```

Then each host running filbeat had those two environment variables, in windows hosts they where set as global environment variables and in linux hosts I had a `/etc/filebeat/env` file and a `override.conf` pointing to this file in the systemd service.

---

<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: [February 2, 2023, 11:57pm UTC](https://discuss.elastic.co/t/how-to-optimize-config-files-of-filebeat-for-many-different-environments/322577/3 "2023-02-02T23:57:55Z")

</div>

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