# How to code grok filter

**URL:** <https://discuss.elastic.co/t/how-to-code-grok-filter/88948>\
**Category:** Logstash\
**Created:** [June 11, 2017, 11:56am UTC](https://discuss.elastic.co/t/how-to-code-grok-filter/88948 "2017-06-11T11:56:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibrahimsharaf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ibrahimsharaf/32/17304_2.png) [@ibrahimsharaf](https://discuss.elastic.co/u/ibrahimsharaf)\
**Post date:** [June 11, 2017, 11:56am UTC](https://discuss.elastic.co/t/how-to-code-grok-filter/88948/1 "2017-06-11T11:56:03Z")

</div>

Hello, I have the following two lines (they can occur multiple times) in a logfile

> 2017-05-01 09:21:35 [item\_utils.py] INFO: stock\_status value after cleanup is OUT\_OF\_STOCK  
> 2017-05-01 09:21:35 [item\_utils.py] INFO: stock\_status value after cleanup is IN\_STOCK

I want to create 2 variables (in\_stock, out\_of\_stock) to count the times of concurrence of each of the previous two lines, how to do it using grok?

Thanks

---

<div class="post-metadata">

**Author:** ![ibrahimsharaf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ibrahimsharaf/32/17304_2.png) [@ibrahimsharaf](https://discuss.elastic.co/u/ibrahimsharaf)\
**Post date:** [June 11, 2017, 2:52pm UTC](https://discuss.elastic.co/t/how-to-code-grok-filter/88948/2 "2017-06-11T14:52:06Z")

</div>

Figured it out, `%{TIMESTAMP_ISO8601} %{NOTSPACE} %{LOGLEVEL}: stock_status value after cleanup is %{GREEDYDATA:stock_status}`

---

<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:** [July 9, 2017, 2:52pm UTC](https://discuss.elastic.co/t/how-to-code-grok-filter/88948/3 "2017-07-09T14:52:36Z")

</div>

Closed on July 9, 2017, 2:52pm UTC

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