# Setting variables in logstash configuration files

**URL:** <https://discuss.elastic.co/t/setting-variables-in-logstash-configuration-files/49431>\
**Category:** Logstash\
**Created:** [May 6, 2016, 7:54pm UTC](https://discuss.elastic.co/t/setting-variables-in-logstash-configuration-files/49431 "2016-05-06T19:54:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Groten](https://avatars.discourse-cdn.com/v4/letter/r/f9ae1b/32.png) [@Ryan\_Groten](https://discuss.elastic.co/u/Ryan_Groten)\
**Post date:** [May 6, 2016, 7:54pm UTC](https://discuss.elastic.co/t/setting-variables-in-logstash-configuration-files/49431/1 "2016-05-06T19:54:38Z")

</div>

I have multiple logstash clients that use identical logstash configurations except for small things like the path to the file to monitor. I'm wondering if this value can be parameterized for easier templating?

Currently each file has:

```
input {
  file {
    path => "/path/instance[123..n]/to/access_log"
    type => "apache-access"
  }
}

```

Is it possible to set a variable in the logstash.conf file (or elsewhere) so I could do something like this:

```
INSTANCE=instance1
input {
  file {
    path => "/path/$INSTANCE/to/access_log"
    type => "apache-access"
  }
}

```

Thanks,  
Ryan

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [May 6, 2016, 8:49pm UTC](https://discuss.elastic.co/t/setting-variables-in-logstash-configuration-files/49431/2 "2016-05-06T20:49:58Z")

</div>

Before launching logstash, you could set an environment variable :  
`export INSTANCE="MY_INSTANCE"`

Then, in logstash configuration file, you can reference this environment variable using :  
`${INSTANCE}`

Precision : you need logstash 2.3.x minimum.

---

<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:** [July 6, 2017, 4:59am UTC](https://discuss.elastic.co/t/setting-variables-in-logstash-configuration-files/49431/3 "2017-07-06T04:59:00Z")

</div>


