# Optional grok pattern field doesnt match

**URL:** <https://discuss.elastic.co/t/optional-grok-pattern-field-doesnt-match/262483>\
**Category:** Logstash\
**Created:** [January 28, 2021, 11:00am UTC](https://discuss.elastic.co/t/optional-grok-pattern-field-doesnt-match/262483 "2021-01-28T11:00:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deny7](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@Deny7](https://discuss.elastic.co/u/Deny7)\
**Post date:** [January 28, 2021, 11:00am UTC](https://discuss.elastic.co/t/optional-grok-pattern-field-doesnt-match/262483/1 "2021-01-28T11:00:50Z")

</div>

Hi, my log looks like this:

> "[rootModel":"modelR","providedByRM":false,"rm\_user":"100001935398@rm.com](mailto:rootModel%22:%22modelR%22,%22providedByRM%22:false,%22rm_user%22:%22100001935398@rm.com)","publishers":["Unknown"]

the part: `,"rm_user":"100001935398@rm.com"` is optional so i marked it with ()?, but it doesnt match when its there, the whole pair is mached to providedByRM field as you can see in picture bellow. Can somebody help?

My grok pattern is:  
`"rootModel":"%{GREEDYDATA:rootModel}","providedByRM":%{GREEDYDATA:providedByRM}(,"rm_user":"%{GREEDYDATA:rm_user}")?,"publishers":\["%{GREEDYDATA:publishers}"\]`

 ![elas](https://us1.discourse-cdn.com/elastic/original/3X/4/a/4afc44b22851a3a226f3d7945cda2e0e18a2c082.png)

---

<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:** [January 28, 2021, 5:20pm UTC](https://discuss.elastic.co/t/optional-grok-pattern-field-doesnt-match/262483/2 "2021-01-28T17:20:48Z")

</div>

Change all those GREEDYDATA to DATA.

---

<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:** [February 25, 2021, 5:21pm UTC](https://discuss.elastic.co/t/optional-grok-pattern-field-doesnt-match/262483/3 "2021-02-25T17:21:01Z")

</div>

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