# Is there a way to tag for different grok matches?

**URL:** https://discuss.elastic.co/t/is-there-a-way-to-tag-for-different-grok-matches/52785
**Category:** Logstash
**Created:** [June 14, 2016, 10:21pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-tag-for-different-grok-matches/52785 "2016-06-14T22:21:56Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [June 15, 2016, 5:55am UTC](https://discuss.elastic.co/t/is-there-a-way-to-tag-for-different-grok-matches/52785/2 "2016-06-15T05:55:08Z")

</div>

Wrap all but the first grok filter in a conditional so that the subsequent ones are only tried if there hasn't been a match earlier.

```nohighlight
grok {
  ...
}
if "_grokparsefailure" in [tags] {
  grok {
    ...
    remove_tag => ["_grokparsefailure"]
  }
}

```

---

_[View the full topic](https://discuss.elastic.co/t/is-there-a-way-to-tag-for-different-grok-matches/52785)._
