# Filters empty messages

**URL:** <https://discuss.elastic.co/t/filters-empty-messages/68461>\
**Category:** Logstash\
**Created:** [December 8, 2016, 5:16pm UTC](https://discuss.elastic.co/t/filters-empty-messages/68461 "2016-12-08T17:16:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![webofmars](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/webofmars/32/9532_2.png) [@webofmars](https://discuss.elastic.co/u/webofmars)\
**Post date:** [December 8, 2016, 5:16pm UTC](https://discuss.elastic.co/t/filters-empty-messages/68461/1 "2016-12-08T17:16:42Z")

</div>

Hello,

I'm trying to filter some empty messages sent from badly formated logs. By empty i mean they can contain just an unknown number of newlines charachters and/or just some spaces.

i tried something like that :

```auto
grok {
    tag_on_failure => []
    match => { "message" => ["^$", "^\s+$"] }
    keep_empty_captures => false
    add_tag => ["msg_is_empty"]
  }

```

I must precise that the multiline concatenation is handled by filebeats.

# Results :

It seams that any newline is actually matched by the grok pattern.  
As i understand it, it's because grok is not multiline aware but i can't see how to configure it properly to make it works.

Any thoughts ?

---

<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:** [December 8, 2016, 5:37pm UTC](https://discuss.elastic.co/t/filters-empty-messages/68461/2 "2016-12-08T17:37:04Z")

</div>

How about this:

```nohighlight
if [message] =~ /^\s*$/ {
  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:** [January 5, 2017, 5:37pm UTC](https://discuss.elastic.co/t/filters-empty-messages/68461/3 "2017-01-05T17:37:30Z")

</div>

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