# Checking null condition in logstash not working

**URL:** <https://discuss.elastic.co/t/checking-null-condition-in-logstash-not-working/235157>\
**Category:** Logstash\
**Created:** [June 1, 2020, 12:01pm UTC](https://discuss.elastic.co/t/checking-null-condition-in-logstash-not-working/235157 "2020-06-01T12:01:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjilinga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anjilinga/32/86010_2.png) [@anjilinga](https://discuss.elastic.co/u/anjilinga)\
**Post date:** [June 1, 2020, 12:01pm UTC](https://discuss.elastic.co/t/checking-null-condition-in-logstash-not-working/235157/1 "2020-06-01T12:01:31Z")

</div>

Hi,  
I am using the belwo logstash configuration, i will be getting one field value at a time among two fields in the record and i want to assign the value to the new field.

csv{  
separator =\> ","  
columns =\> ["source","destin",Name]  
skip\_empty\_columns =\> false  
}   
if [Name] {   
mutate {   
add\_field =\> {   
"new\_field" =\> "%{Name}"  
}  
}  
}  
if [source] {   
mutate {   
add\_field =\> {   
"new\_field" =\> "%{source}"  
}  
}  
}

but It is executing two loops and it is appening as %Name or %source if the field value is empty as below.  
%Name, A  
B, %source

how to check the null condition ?

---

<div class="post-metadata">

**Author:** ![ptamba](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@ptamba](https://discuss.elastic.co/u/ptamba)\
**Post date:** [June 1, 2020, 2:25pm UTC](https://discuss.elastic.co/t/checking-null-condition-in-logstash-not-working/235157/2 "2020-06-01T14:25:56Z")

</div>

it will help if you provide some sample input and expected output

---

<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 29, 2020, 2:26pm UTC](https://discuss.elastic.co/t/checking-null-condition-in-logstash-not-working/235157/3 "2020-06-29T14:26:03Z")

</div>

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