# Don't save in ES logs that have in tag \_grokparsefailure or \_dateparsefailure

**URL:** <https://discuss.elastic.co/t/dont-save-in-es-logs-that-have-in-tag-grokparsefailure-or-dateparsefailure/269141>\
**Category:** Logstash\
**Created:** [April 3, 2021, 6:09am UTC](https://discuss.elastic.co/t/dont-save-in-es-logs-that-have-in-tag-grokparsefailure-or-dateparsefailure/269141 "2021-04-03T06:09:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Automation\_Scripts](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/automation_scripts/32/85374_2.png) [@Automation\_Scripts](https://discuss.elastic.co/u/Automation_Scripts)\
**Post date:** [April 3, 2021, 6:09am UTC](https://discuss.elastic.co/t/dont-save-in-es-logs-that-have-in-tag-grokparsefailure-or-dateparsefailure/269141/1 "2021-04-03T06:09:20Z")

</div>

Hi,

How can i filter the logs that are saved within ES in order to have only valid data that has no grok parse failure or date parse error? My approach is bellow

```auto
output {
  if ("_grokparsefailure" not in [tags]) or ("_dateparsefailure" not in [tags]) {
    elasticsearch {
      hosts => ["http://es01:9200","http://es02:9200","http://es03:9200"]
      # index => "%{[indexPrefix]}-logs-%{+dd.MM.YYYY}"
      index => "filebeat-kafka-logstash-%{+YYYY.MM.dd}"
      # index => "logstash-%{[type]}-%{+YYYY.MM.dd}"
      ecs_compatibility => disabled
    }
  }
}

```

---

<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:** [April 3, 2021, 2:58pm UTC](https://discuss.elastic.co/t/dont-save-in-es-logs-that-have-in-tag-grokparsefailure-or-dateparsefailure/269141/2 "2021-04-03T14:58:39Z")

</div>

> [@Automation\_Scripts](#):
>
> `if ("_grokparsefailure" not in [tags]) or ("_dateparsefailure" not in [tags]) {`

I think where you wrote "or" you meant "and".

If the event has \_dateparsefailure but not \_grokparsefailure then the left will evaluate to true and the right will evaluate to false. When you "or" those you get true, so it will be indexed.

---

<div class="post-metadata">

**Author:** ![Automation\_Scripts](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/automation_scripts/32/85374_2.png) [@Automation\_Scripts](https://discuss.elastic.co/u/Automation_Scripts)\
**Post date:** [April 4, 2021, 5:20am UTC](https://discuss.elastic.co/t/dont-save-in-es-logs-that-have-in-tag-grokparsefailure-or-dateparsefailure/269141/3 "2021-04-04T05:20:42Z")

</div>

ok, i solved it with a simple filter with drop. 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:** [May 2, 2021, 5:20am UTC](https://discuss.elastic.co/t/dont-save-in-es-logs-that-have-in-tag-grokparsefailure-or-dateparsefailure/269141/4 "2021-05-02T05:20:56Z")

</div>

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