# Grok multiple matches reports failures in an unexpected way

**URL:** <https://discuss.elastic.co/t/grok-multiple-matches-reports-failures-in-an-unexpected-way/189593>\
**Category:** Logstash\
**Created:** [July 9, 2019, 4:16pm UTC](https://discuss.elastic.co/t/grok-multiple-matches-reports-failures-in-an-unexpected-way/189593 "2019-07-09T16:16:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sous\_Lesquels](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sous_lesquels/32/41843_2.png) [@Sous\_Lesquels](https://discuss.elastic.co/u/Sous_Lesquels)\
**Post date:** [July 9, 2019, 4:16pm UTC](https://discuss.elastic.co/t/grok-multiple-matches-reports-failures-in-an-unexpected-way/189593/1 "2019-07-09T16:16:11Z")

</div>

I have this filter:

```
grok {
  break_on_match => false
  match => {
    'message' => [
      'a(?<a>\d+)',
      'b(?<b>\d+)'
    ]
  }
}

```

and this input file:

```
a11
b21
a31 b32

```

When run, this parses correctly, i.e. I get three events:

- `{a => 11}`
- `{b => 21}`
- `{a => 31, b => 32}`

as expected. However, I also get `tags => ["_grokparsefailure"]` on the first event. Why only on the first (and in particular not on the second)?

If I modify the above to this:

```
grok {
  break_on_match => false
  match => {
    'message' => [
      'a(?<a>\d+)',
      'b(?<b>\d+)',
      'c(?<c>\d+)'
    ]
  }
}

```

then I get `tags => ["_grokparsefailure"]` on all three events.

My expectation is that I'd get `_grokparsefailure` only when **all** of the supplied matches fail. Is my expectation incorrect and is there a way to make `grok` work so that it reports failure only if all matches fail?

---

<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:** [July 9, 2019, 4:19pm UTC](https://discuss.elastic.co/t/grok-multiple-matches-reports-failures-in-an-unexpected-way/189593/2 "2019-07-09T16:19:47Z")

</div>

> [@Sous\_Lesquels](#):
>
> My expectation is that I'd get `_grokparsefailure` only when **all** of the supplied matches fail.

That is a [known issue](https://github.com/logstash-plugins/logstash-filter-grok/issues/49#issuecomment-460290854).

---

<div class="post-metadata">

**Author:** ![Sous\_Lesquels](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sous_lesquels/32/41843_2.png) [@Sous\_Lesquels](https://discuss.elastic.co/u/Sous_Lesquels)\
**Post date:** [July 9, 2019, 4:23pm UTC](https://discuss.elastic.co/t/grok-multiple-matches-reports-failures-in-an-unexpected-way/189593/3 "2019-07-09T16:23:08Z")

</div>

@Badger Ah... No workarounds at the moment?

---

<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:** [July 9, 2019, 4:24pm UTC](https://discuss.elastic.co/t/grok-multiple-matches-reports-failures-in-an-unexpected-way/189593/4 "2019-07-09T16:24:44Z")

</div>

None that I know of.

---

<div class="post-metadata">

**Author:** ![Sous\_Lesquels](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sous_lesquels/32/41843_2.png) [@Sous\_Lesquels](https://discuss.elastic.co/u/Sous_Lesquels)\
**Post date:** [July 9, 2019, 4:25pm UTC](https://discuss.elastic.co/t/grok-multiple-matches-reports-failures-in-an-unexpected-way/189593/5 "2019-07-09T16:25:45Z")

</div>

Cool ty @Badger

---

<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:** [August 6, 2019, 4:28pm UTC](https://discuss.elastic.co/t/grok-multiple-matches-reports-failures-in-an-unexpected-way/189593/6 "2019-08-06T16:28:03Z")

</div>

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