# Determining which item in patterns array of a grok plugin was matched

**URL:** <https://discuss.elastic.co/t/determining-which-item-in-patterns-array-of-a-grok-plugin-was-matched/312538>\
**Category:** Logstash\
**Created:** [August 21, 2022, 6:31am UTC](https://discuss.elastic.co/t/determining-which-item-in-patterns-array-of-a-grok-plugin-was-matched/312538 "2022-08-21T06:31:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![who](https://avatars.discourse-cdn.com/v4/letter/w/cdc98d/32.png) [@who](https://discuss.elastic.co/u/who)\
**Post date:** [August 21, 2022, 6:31am UTC](https://discuss.elastic.co/t/determining-which-item-in-patterns-array-of-a-grok-plugin-was-matched/312538/1 "2022-08-21T06:31:48Z")

</div>

Assuming we're using the grok filter plugin in the "multiple patterns for a single field" mode:

```auto
  filter {
      grok {
        match => {
          "message" => [
            "Duration: %{NUMBER:duration}",
            "Speed: %{NUMBER:speed}"
          ]
        }
      }
    }

```

I need to know which pattern item in the array was matched, to use that array " **index**" in another corespondent array and extract the relevant item.  
It is worth mentioning that the grok filter is being used inside ruby code.  
Thanks

---

<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:** [September 18, 2022, 6:32am UTC](https://discuss.elastic.co/t/determining-which-item-in-patterns-array-of-a-grok-plugin-was-matched/312538/2 "2022-09-18T06:32:01Z")

</div>

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