# Variable value is not accesible in nested if condition

**URL:** <https://discuss.elastic.co/t/variable-value-is-not-accesible-in-nested-if-condition/101779>\
**Category:** Logstash\
**Created:** [September 26, 2017, 5:10am UTC](https://discuss.elastic.co/t/variable-value-is-not-accesible-in-nested-if-condition/101779 "2017-09-26T05:10:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![raja\_gopal](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@raja\_gopal](https://discuss.elastic.co/u/raja_gopal)\
**Post date:** [September 26, 2017, 5:10am UTC](https://discuss.elastic.co/t/variable-value-is-not-accesible-in-nested-if-condition/101779/1 "2017-09-26T05:10:22Z")

</div>

In a nested if condition like  
if [type] == "tcp"{  
if [parsed\_message][NotificationType] == "NOTIFY"

The if block inside "tcp" is not working since it is not getting the value of "[parsed\_message][NotificationType]" but if i give the same condition like  
if [parsed\_message][NotificationType] == "NOTIFY" and [type] == "tcp"{  
It is working fine, what is the problem here ?

---

<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:** [September 26, 2017, 5:15am UTC](https://discuss.elastic.co/t/variable-value-is-not-accesible-in-nested-if-condition/101779/2 "2017-09-26T05:15:41Z")

</div>

Please show an example of a document that has this perceived problem so that we can try to reproduce it.

---

<div class="post-metadata">

**Author:** ![raja\_gopal](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@raja\_gopal](https://discuss.elastic.co/u/raja_gopal)\
**Post date:** [September 26, 2017, 5:27am UTC](https://discuss.elastic.co/t/variable-value-is-not-accesible-in-nested-if-condition/101779/3 "2017-09-26T05:27:24Z")

</div>

`<NotificationTime><![CDATA[1505469213]]></NotificationTime><NotificationType><![CDATA[CLEAR]]></NotificationType><OccurrenceCount><![CDATA[4]]></OccurrenceCount><Severity><![CDATA[1]]></Severity>`

In this above example i am not able to use the notification type in nested if

---

<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:** [September 26, 2017, 5:36am UTC](https://discuss.elastic.co/t/variable-value-is-not-accesible-in-nested-if-condition/101779/4 "2017-09-26T05:36:41Z")

</div>

That doesn't help without also knowing your configuration. I meant the document _produced_ by Logstash, i.e. basically the input to the conditional that's not working. Use a `stdout { codec => rubydebug }` output.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 26, 2017, 5:40am UTC](https://discuss.elastic.co/t/variable-value-is-not-accesible-in-nested-if-condition/101779/5 "2017-09-26T05:40:23Z")

</div>

What does the full configuration block look like? It seems like you are missing a curly brace on the second line, but I assume that could simply be a cut and paste error.

---

<div class="post-metadata">

**Author:** ![raja\_gopal](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@raja\_gopal](https://discuss.elastic.co/u/raja_gopal)\
**Post date:** [September 26, 2017, 6:06am UTC](https://discuss.elastic.co/t/variable-value-is-not-accesible-in-nested-if-condition/101779/6 "2017-09-26T06:06:59Z")

</div>

xml {  
store\_xml =\> true  
source =\> message  
target =\> parsed\_message  
force\_array =\> false  
remove\_field =\> "message"  
}

This is my code block to parse the xml. The output block is

`if [type] == "tcp"{ if [parsed_message][NotificationType] == "NOTIFY" { elasticsearch { } } }`

---

<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:** [October 24, 2017, 6:07am UTC](https://discuss.elastic.co/t/variable-value-is-not-accesible-in-nested-if-condition/101779/7 "2017-10-24T06:07:07Z")

</div>

Closed on October 24, 2017, 6:07am UTC

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