# Comparing Empty String

**URL:** <https://discuss.elastic.co/t/comparing-empty-string/182846>\
**Category:** Logstash\
**Created:** [May 27, 2019, 6:44am UTC](https://discuss.elastic.co/t/comparing-empty-string/182846 "2019-05-27T06:44:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepak2](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Deepak2](https://discuss.elastic.co/u/Deepak2)\
**Post date:** [May 27, 2019, 6:44am UTC](https://discuss.elastic.co/t/comparing-empty-string/182846/1 "2019-05-27T06:44:45Z")

</div>

Hi,

I am not able to compare empty string and do the necessary operation in logstasgh. Below is my logstash config file line

if [fields][type] == "serverlog"{  
grok {  
match =\> {"message"=\> "%{DATE:log\_date}%{SPACE}%{TIME:log\_time}%{SPACE}%{LOGLEVEL:level}%{SPACE}[%{DATA:class}]%{SPACE}%{GREEDYDATA:Log\_message}"}  
}

if [message][class] == "" {  
drop {}  
}

Please guide me to figure out the wrong. Thank you in advance

---

<div class="post-metadata">

**Author:** ![logger](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@logger](https://discuss.elastic.co/u/logger)\
**Post date:** [May 27, 2019, 8:19am UTC](https://discuss.elastic.co/t/comparing-empty-string/182846/2 "2019-05-27T08:19:22Z")

</div>

It is not nested so you can just use

> if [class] == "" {  
> drop {}  
> }

---

<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 24, 2019, 8:19am UTC](https://discuss.elastic.co/t/comparing-empty-string/182846/3 "2019-06-24T08:19:31Z")

</div>

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