# Check if env variable is set

**URL:** https://discuss.elastic.co/t/check-if-env-variable-is-set/232328
**Category:** Logstash
**Created:** [May 12, 2020, 10:52pm UTC](https://discuss.elastic.co/t/check-if-env-variable-is-set/232328 "2020-05-12T22:52:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![alxsss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alxsss/32/69929_2.png) [@alxsss](https://discuss.elastic.co/u/alxsss)
#### Post date: [May 12, 2020, 10:52pm UTC](https://discuss.elastic.co/t/check-if-env-variable-is-set/232328/1 "2020-05-12T22:52:45Z")

</div>

Is it possible to check if an env variable is set? I tired a workaround like this  
In bash  
$set DATE=a

filter{  
if (["{DATE:a}"]=="a") { mutate { add\_field =\> { "startTime" =\> "2019-10-19" }} } else{ mutate { add\_field =\> { "startTime" =\> "{DATE}" } }  
}  
}

the output is  
startTime=\>"a"

So, else statement was executed, instead of if statement.

Any ideas what is wrong here?

Thx, in advance.

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [May 12, 2020, 11:28pm UTC](https://discuss.elastic.co/t/check-if-env-variable-is-set/232328/2 "2020-05-12T23:28:17Z")

</div>

See [here](https://discuss.elastic.co/t/environment-variables-in-if-then-logic/197099/2).

---

<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: [June 9, 2020, 11:28pm UTC](https://discuss.elastic.co/t/check-if-env-variable-is-set/232328/3 "2020-06-09T23:28:20Z")

</div>

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