# Skip first two grok pattern matches

**URL:** https://discuss.elastic.co/t/skip-first-two-grok-pattern-matches/194666
**Category:** Logstash
**Created:** [August 9, 2019, 6:34pm UTC](https://discuss.elastic.co/t/skip-first-two-grok-pattern-matches/194666 "2019-08-09T18:34:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jim\_Thunder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jim_thunder/32/45439_2.png) [@Jim\_Thunder](https://discuss.elastic.co/u/Jim_Thunder)
#### Post date: [August 9, 2019, 6:34pm UTC](https://discuss.elastic.co/t/skip-first-two-grok-pattern-matches/194666/1 "2019-08-09T18:34:08Z")

</div>

I am trying to parse out the last number of a field (that is a string). My grok pattern, currently, pulls the first number and puts it in the new field. How can make that grok pattern skip the first 2 numbers it comes across and instead grab the third?

**Sample [TEXT] field value:**

" IAT1613 JOB SERZMFP (JOB04933) SYSTEM MESSAGE COUNT IS 290,000"

**Here's my code:**  
\</\>  
if "IAT1613" in [TEXT] {  
grok { match =\> ["TEXT","%{NUMBER:MSG\_COUNT}"] }  
}  
\</\>

The grok pattern grabs the "1613" but I need it to grab the number 290,000 instead.

---

<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: [August 9, 2019, 7:58pm UTC](https://discuss.elastic.co/t/skip-first-two-grok-pattern-matches/194666/2 "2019-08-09T19:58:13Z")

</div>

Anchor the pattern to end of line. Also, NUMBER cannot contain commas, so use a custom pattern.

```
"(?<MSG_COUNT>[0-9,]+)$"
```

---

<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 6, 2019, 7:58pm UTC](https://discuss.elastic.co/t/skip-first-two-grok-pattern-matches/194666/3 "2019-09-06T19:58:13Z")

</div>

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