# Grok - Value could appear or not. multiple rules?

**URL:** <https://discuss.elastic.co/t/grok-value-could-appear-or-not-multiple-rules/273548>\
**Category:** Logstash\
**Created:** [May 20, 2021, 2:01pm UTC](https://discuss.elastic.co/t/grok-value-could-appear-or-not-multiple-rules/273548 "2021-05-20T14:01:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![legolas\_bilbao](https://avatars.discourse-cdn.com/v4/letter/l/3da27b/32.png) [@legolas\_bilbao](https://discuss.elastic.co/u/legolas_bilbao)\
**Post date:** [May 20, 2021, 2:01pm UTC](https://discuss.elastic.co/t/grok-value-could-appear-or-not-multiple-rules/273548/1 "2021-05-20T14:01:26Z")

</div>

I'm working with some logs from squid but one value could appear or not

1621232309.575 1 172.99.6.74 TCP\_MEM\_HIT/206 3096 GET [http://storage.googleapis.com/](http://storage.googleapis.com/) - HIER\_NONE/- application/octet-stream

1621232309.575 1 172.99.6.74 TCP\_MEM\_HIT/206 3096 GET [http://storage.googleapis.com/](http://storage.googleapis.com/) - HIER\_NONE/1.1.1.1- application/octet-stream

How can i manage through grok the differences??

---

<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:** [May 20, 2021, 3:22pm UTC](https://discuss.elastic.co/t/grok-value-could-appear-or-not-multiple-rules/273548/2 "2021-05-20T15:22:18Z")

</div>

You can surround part of the grok pattern with ( and )? so that it matches zero or more times.

---

<div class="post-metadata">

**Author:** ![legolas\_bilbao](https://avatars.discourse-cdn.com/v4/letter/l/3da27b/32.png) [@legolas\_bilbao](https://discuss.elastic.co/u/legolas_bilbao)\
**Post date:** [May 21, 2021, 12:45pm UTC](https://discuss.elastic.co/t/grok-value-could-appear-or-not-multiple-rules/273548/3 "2021-05-21T12:45:16Z")

</div>

many 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:** [June 18, 2021, 12:45pm UTC](https://discuss.elastic.co/t/grok-value-could-appear-or-not-multiple-rules/273548/4 "2021-06-18T12:45:48Z")

</div>

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