# Filter to drop all packets that are null not working

**URL:** <https://discuss.elastic.co/t/filter-to-drop-all-packets-that-are-null-not-working/76838>\
**Category:** Logstash\
**Created:** [February 28, 2017, 5:18pm UTC](https://discuss.elastic.co/t/filter-to-drop-all-packets-that-are-null-not-working/76838 "2017-02-28T17:18:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Hoffman](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Ben\_Hoffman](https://discuss.elastic.co/u/Ben_Hoffman)\
**Post date:** [February 28, 2017, 5:18pm UTC](https://discuss.elastic.co/t/filter-to-drop-all-packets-that-are-null-not-working/76838/1 "2017-02-28T17:18:43Z")

</div>

So I wrote a filter to drop any event that has a certain field with a value of null:

```
 filter {
    if[type] == "flow" and [packet_source][ip] == "" {
            drop { }
    }
}

```

However, this does not work. Does anyone have any idea why? The names of the parameters are correct

Logstash version 5.2

---

<div class="post-metadata">

**Author:** ![jkuang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkuang/32/72637_2.png) [@jkuang](https://discuss.elastic.co/u/jkuang)\
**Post date:** [February 28, 2017, 8:26pm UTC](https://discuss.elastic.co/t/filter-to-drop-all-packets-that-are-null-not-working/76838/2 "2017-02-28T20:26:54Z")

</div>

Please provide the logstash configs and a sample line of data.

---

<div class="post-metadata">

**Author:** ![Ben\_Hoffman](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Ben\_Hoffman](https://discuss.elastic.co/u/Ben_Hoffman)\
**Post date:** [February 28, 2017, 8:30pm UTC](https://discuss.elastic.co/t/filter-to-drop-all-packets-that-are-null-not-working/76838/3 "2017-02-28T20:30:11Z")

</div>

Here is what my output looks like, and sometimes the "packet\_source.ip" is empty, so I want to drop those packets.

![](https://us1.discourse-cdn.com/elastic/original/2X/4/43c107a7e9ca73e26add077d5152bc029f943890.PNG)

As for my configs, I have the default ones, one set up for input from packetbeat, and that filter in my original post.

---

<div class="post-metadata">

**Author:** ![jkuang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkuang/32/72637_2.png) [@jkuang](https://discuss.elastic.co/u/jkuang)\
**Post date:** [March 1, 2017, 12:08am UTC](https://discuss.elastic.co/t/filter-to-drop-all-packets-that-are-null-not-working/76838/4 "2017-03-01T00:08:45Z")

</div>

Try the following:

```auto
 filter {
    if[type] == "flow" and !([packet_source][ip]) {
            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:** [March 29, 2017, 12:08am UTC](https://discuss.elastic.co/t/filter-to-drop-all-packets-that-are-null-not-working/76838/5 "2017-03-29T00:08:50Z")

</div>

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