# Logstash null fields to drop

**URL:** <https://discuss.elastic.co/t/logstash-null-fields-to-drop/170731>\
**Category:** Logstash\
**Created:** [March 4, 2019, 1:52pm UTC](https://discuss.elastic.co/t/logstash-null-fields-to-drop/170731 "2019-03-04T13:52:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fedwe](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@fedwe](https://discuss.elastic.co/u/fedwe)\
**Post date:** [March 4, 2019, 1:52pm UTC](https://discuss.elastic.co/t/logstash-null-fields-to-drop/170731/1 "2019-03-04T13:52:54Z")

</div>

if i have 2 fields i want a condition  
if [field1] == nil and [field2] == nil {  
drop{}  
}  
if both fieds are null values i want to drop the event but none of the conditions i tried worked  
[field1] == "" and [field2] == ""  
"" in [field1] and "" in [field2]  
[

---

<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:** [March 4, 2019, 2:17pm UTC](https://discuss.elastic.co/t/logstash-null-fields-to-drop/170731/2 "2019-03-04T14:17:39Z")

</div>

If they are actually nil then you could use

```
if ![a] and ![b] { drop {} }
```

---

<div class="post-metadata">

**Author:** ![fedwe](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@fedwe](https://discuss.elastic.co/u/fedwe)\
**Post date:** [March 4, 2019, 2:42pm UTC](https://discuss.elastic.co/t/logstash-null-fields-to-drop/170731/3 "2019-03-04T14:42:55Z")

</div>

thank you so much and i want to ask you does the drop filter reduce logstash's performance?

---

<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:** [March 4, 2019, 2:47pm UTC](https://discuss.elastic.co/t/logstash-null-fields-to-drop/170731/4 "2019-03-04T14:47:20Z")

</div>

Not processing data is faster than processing data, so I would say it does not. Just do the drop as early as possible.

---

<div class="post-metadata">

**Author:** ![fedwe](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@fedwe](https://discuss.elastic.co/u/fedwe)\
**Post date:** [March 4, 2019, 2:52pm UTC](https://discuss.elastic.co/t/logstash-null-fields-to-drop/170731/5 "2019-03-04T14:52:54Z")

</div>

okay thank you

---

<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:** [April 1, 2019, 2:52pm UTC](https://discuss.elastic.co/t/logstash-null-fields-to-drop/170731/6 "2019-04-01T14:52:54Z")

</div>

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