# Are constants and/or variabales available in Logstash?

**URL:** <https://discuss.elastic.co/t/are-constants-and-or-variabales-available-in-logstash/72833>\
**Category:** Logstash\
**Created:** [January 25, 2017, 11:31pm UTC](https://discuss.elastic.co/t/are-constants-and-or-variabales-available-in-logstash/72833 "2017-01-25T23:31:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![irom77](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/irom77/32/12976_2.png) [@irom77](https://discuss.elastic.co/u/irom77)\
**Post date:** [January 25, 2017, 11:31pm UTC](https://discuss.elastic.co/t/are-constants-and-or-variabales-available-in-logstash/72833/1 "2017-01-25T23:31:11Z")

</div>

I am reusing same values (see integer 100 example below) in my logstash configuration file. Is there way I can define constant at the beginning of the file i.e. **THRESHOLD=60** for later use in the config file

> if [SOMETHING][count] \> 100 {
> 
> ```
> exec {
> command => "iquery-notify -time=60"
> }
> 
> ```
> 
> }

also in this particular case is it possible to pass variable **%{URL}** to exec command ?

> ```
> exec {
> command => "iquery-notify -time=60 -url= **\"%{URL}\"**"
> }
> 
> ```

---

<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:** [January 26, 2017, 7:10am UTC](https://discuss.elastic.co/t/are-constants-and-or-variabales-available-in-logstash/72833/2 "2017-01-26T07:10:08Z")

</div>

> I am reusing same values (see integer 100 example below) in my logstash configuration file. Is there way I can define constant at the beginning of the file i.e. THRESHOLD=60 for later use in the config file

You can access environment variables via `${name-of-variable}` but Logstash has no constant concept of its own (unless you store the value in a field).

> also in this particular case is it possible to pass variable %{URL} to exec command ?

Yes, assuming there is a `URL` field.

---

<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 23, 2017, 7:10am UTC](https://discuss.elastic.co/t/are-constants-and-or-variabales-available-in-logstash/72833/3 "2017-02-23T07:10:14Z")

</div>

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