# How to parse grok in Logstash

**URL:** <https://discuss.elastic.co/t/how-to-parse-grok-in-logstash/192746>\
**Category:** Logstash\
**Created:** [July 29, 2019, 4:42pm UTC](https://discuss.elastic.co/t/how-to-parse-grok-in-logstash/192746 "2019-07-29T16:42:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sajal](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sajal](https://discuss.elastic.co/u/Sajal)\
**Post date:** [July 29, 2019, 4:42pm UTC](https://discuss.elastic.co/t/how-to-parse-grok-in-logstash/192746/1 "2019-07-29T16:42:34Z")

</div>

Tanium 148 - [GIS:-Startup-Programs@017472  
Tanium 148 - [WEC:-Subscription-Manager-Setting@017472  
Tanium 148 - [GIS:-Trace-Executed-Processes---Powershell@017472  
Tanium 148 - [GIS:-Scheduled-Task-Information@017472

Tried below grok but GIS is changing  
%{DATA:Field} - [GIS:-%{GREEDYDATA:GIS}

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [July 30, 2019, 4:05pm UTC](https://discuss.elastic.co/t/how-to-parse-grok-in-logstash/192746/2 "2019-07-30T16:05:40Z")

</div>

After fixing this you should anchor the start of your grok pattern as it is a regular expression under the hood.  
Read this [blog post](https://www.elastic.co/blog/do-you-grok-grok)

So because it is a regular expression you can put in a pattern for the varying section.

`%{DATA:Field} - [%{DATA:message_type}:-%{GREEDYDATA:GIS}`

If you don't want the lines with `WEC` in the `message_type` then you can add a conditional section with the `drop` filter.

```auto
    if not message_type == "GIS" {
      drop {}
    }

```

---

<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:** [August 27, 2019, 4:19pm UTC](https://discuss.elastic.co/t/how-to-parse-grok-in-logstash/192746/3 "2019-08-27T16:19:38Z")

</div>

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