# \_grokparsefailure exception with custom pattern

**URL:** <https://discuss.elastic.co/t/grokparsefailure-exception-with-custom-pattern/123962>\
**Category:** Logstash\
**Created:** [March 14, 2018, 5:30pm UTC](https://discuss.elastic.co/t/grokparsefailure-exception-with-custom-pattern/123962 "2018-03-14T17:30:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sehrish\_naeem\_naeem](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@sehrish\_naeem\_naeem](https://discuss.elastic.co/u/sehrish_naeem_naeem)\
**Post date:** [March 14, 2018, 5:30pm UTC](https://discuss.elastic.co/t/grokparsefailure-exception-with-custom-pattern/123962/1 "2018-03-14T17:30:01Z")

</div>

Hi,

I am newbie and trying to add a field as "cid" in with my logs based on this pattern

2018-03-14 22:26:57.268 INFO 22996 --- [nio-8090-exec-2] com.example.ms1.service.ValidatorImpl : validation completed with cid: ms1-0-8a7e131b-1730-45f2-a72d-c2bc7cba4b93  
2018-03-14 22:26:57.470 INFO 22996 --- [nio-8090-exec-2] com.example.ms1.service.ProcessorImpl : processing completed with cid: ms1-0-8a7e131b-1730-45f2-a72d-c2bc7cba4b93

I have created a file for my custom pattern named as "CORRELATIONID [A-Fa-f0-9]{3}-[0-9]{1}-[A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}" and I am using this grok

grok {  
patterns\_dir =\> ["C:/Users/Venturedive/Desktop/custom-pattern"]  
match =\> {"message" =\> "%{TIMESTAMP\_ISO8601:timestamp} \*%{LOGLEVEL:level} %{CORRELATIONID:cid}"}  
}

can anyone help?

---

<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:** [March 14, 2018, 5:49pm UTC](https://discuss.elastic.co/t/grokparsefailure-exception-with-custom-pattern/123962/2 "2018-03-14T17:49:04Z")

</div>

> [@sehrish\_naeem\_naeem](#):
>
> can anyone help?

The first two characters of the correlation id are m and s, which are not in the range a-f. This matches

```
input { generator { message => 'ms1-0-8a7e131b-1730-45f2-a72d-c2bc7cba4b93' count => 1 } }
output { stdout { codec => rubydebug } }
filter {
  grok { match => ["message", "(?[A-Fa-s0-9]{3}-[0-9]{1}-[A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12})" ] }
}
```

---

<div class="post-metadata">

**Author:** ![sehrish\_naeem\_naeem](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@sehrish\_naeem\_naeem](https://discuss.elastic.co/u/sehrish_naeem_naeem)\
**Post date:** [March 14, 2018, 6:15pm UTC](https://discuss.elastic.co/t/grokparsefailure-exception-with-custom-pattern/123962/3 "2018-03-14T18:15:40Z")

</div>

> [@Badger](#):
>
> "(?[A-Fa-s0-9]{3}-[0-9]{1}-[A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12})"

Thanks for your reply, I have updated my grok like this  
grok {  
match =\> ["message", "(?[A-Za-z0-9]{3}-[0-9]{1}-[A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12})" ]  
}

since first two letters can be from a to z, but now it is giving me regex error

 ![regex%20error](https://us1.discourse-cdn.com/elastic/original/3X/4/b/4b665613c2d9644d74249780cefc39b05cead1b6.PNG)

---

<div class="post-metadata">

**Author:** ![sehrish\_naeem\_naeem](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@sehrish\_naeem\_naeem](https://discuss.elastic.co/u/sehrish_naeem_naeem)\
**Post date:** [March 14, 2018, 6:22pm UTC](https://discuss.elastic.co/t/grokparsefailure-exception-with-custom-pattern/123962/4 "2018-03-14T18:22:34Z")

</div>

Cool it worked, just modified my grok like this  
grok {  
match =\> ["message", "(?[A-Za-z0-9]{3}-[0-9]{1}-[A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12})" ]  
}

thanks badger 🙂

---

<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:** [March 14, 2018, 6:24pm UTC](https://discuss.elastic.co/t/grokparsefailure-exception-with-custom-pattern/123962/5 "2018-03-14T18:24:45Z")

</div>

> [@sehrish\_naeem\_naeem](#):
>
> now it is giving me regex error

Sorry, I didn't escape the \< and \>, so it ate the name

```auto
grok { match => ["message", "(?<cid>[A-Za-z0-9]{3}-[0-9]{1}-[A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12})" ] }

```

---

<div class="post-metadata">

**Author:** ![sehrish\_naeem\_naeem](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@sehrish\_naeem\_naeem](https://discuss.elastic.co/u/sehrish_naeem_naeem)\
**Post date:** [March 14, 2018, 6:25pm UTC](https://discuss.elastic.co/t/grokparsefailure-exception-with-custom-pattern/123962/6 "2018-03-14T18:25:21Z")

</div>

yeah I did the same and it was perfect (y)

---

<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:** [April 11, 2018, 6:25pm UTC](https://discuss.elastic.co/t/grokparsefailure-exception-with-custom-pattern/123962/7 "2018-04-11T18:25:22Z")

</div>

Closed on April 11, 2018, 6:25pm UTC

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