# How to use GROK pattern for JSON Object

**URL:** https://discuss.elastic.co/t/how-to-use-grok-pattern-for-json-object/149959
**Category:** Logstash
**Created:** [September 26, 2018, 8:45am UTC](https://discuss.elastic.co/t/how-to-use-grok-pattern-for-json-object/149959 "2018-09-26T08:45:11Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Teja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/teja/32/16324_2.png) [@Teja](https://discuss.elastic.co/u/Teja)
#### Post date: [September 26, 2018, 8:45am UTC](https://discuss.elastic.co/t/how-to-use-grok-pattern-for-json-object/149959/1 "2018-09-26T08:45:12Z")

</div>

Hi Folks,

I want to apply grok for one JSON object[field] and extract values from the field.

Sample Json Message:

`{"event.created":"1537941675000","isoTimeFormat":"yyyy-MM-dd'T'HH:mm:ss.SSSZ","event.payload":"dstintf=\"port3\" profiletype=\"applist\" proto=6 service=\"HTTP\" policyid=959 applist=\"Web_AppCtrl_Profile\" action=\"pass\" msg=\"Update: Root.Certificate.URL,\" ","host":"0.0.0.0","event.category":"System","destination.PostNATport":"0", "device.type":"firewall"}`

I am already parsing "event.category, host, event.created, destination.PosyNATport" fields using "json" filter plugin in logstash.

But, Now i want to apply "grok pattern" to json object "event.payload" to parse "service & action etc".

I dont know how to form syntax to achieve above use case in logstash.

Is it possible to achieve or is there any other way to accomplish.?

Gratitude,  
TJ

---

<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: [September 26, 2018, 8:50am UTC](https://discuss.elastic.co/t/how-to-use-grok-pattern-for-json-object/149959/2 "2018-09-26T08:50:23Z")

</div>

While doable it is not advised. You should use the json filter - it is designed to do just that. You can remove any fields that you do not want.

---

<div class="post-metadata">

### Author: ![Teja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/teja/32/16324_2.png) [@Teja](https://discuss.elastic.co/u/Teja)
#### Post date: [September 26, 2018, 8:57am UTC](https://discuss.elastic.co/t/how-to-use-grok-pattern-for-json-object/149959/3 "2018-09-26T08:57:15Z")

</div>

I am already using JSON filter in my logstash to parse other fields such as

> [@Teja](#):
>
> "event.category, host, event.created, destination.PosyNATport" fields using "json" filter plugin in logstash.

But now i want to extract `service=\"HTTP\"` in `"event.payload"` json object.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [September 26, 2018, 9:12am UTC](https://discuss.elastic.co/t/how-to-use-grok-pattern-for-json-object/149959/4 "2018-09-26T09:12:58Z")

</div>

Use a kv filter.

---

<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: [October 24, 2018, 9:13am UTC](https://discuss.elastic.co/t/how-to-use-grok-pattern-for-json-object/149959/5 "2018-10-24T09:13:00Z")

</div>

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