# How to use grok filter on JSON field

**URL:** <https://discuss.elastic.co/t/how-to-use-grok-filter-on-json-field/90578>\
**Category:** Logstash\
**Created:** [June 23, 2017, 6:31am UTC](https://discuss.elastic.co/t/how-to-use-grok-filter-on-json-field/90578 "2017-06-23T06:31:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sachiiit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sachiiit/32/19163_2.png) [@sachiiit](https://discuss.elastic.co/u/sachiiit)\
**Post date:** [June 23, 2017, 6:31am UTC](https://discuss.elastic.co/t/how-to-use-grok-filter-on-json-field/90578/1 "2017-06-23T06:31:34Z")

</div>

I have an http input plugin in my logstash configuration with codec as json as

```
http {
                host => "0.0.0.0"
                port => "8080"
                user => "username"
                password => "password"
                codec => json
        }

```

So the message in my filter section is

```
 {   
        "@timestamp" => 2017-06-23T06:16:05.000Z,
          "@version" => "1",
             "event" => {
               "logLevel" => "INFO",
            "description" => "sachchit.bansal@xyz.com \"Coupon\" \"Chrome\" \"Linux\" \"182.72.92.14, 172.20.14.45, 172.20.12.14\" \"182.72.92.14\" \"/user/dashboard\" \"Coupon - Dashboard\" _14981985629789475123422 \"URLChange\" \"\"",
              "className" => "internalUserTrackLog",
              "eventType" => "USER_TRACKING_INFO_EVENT"
        }
    }

```

I want to use grok filter on the description field of the message. I don't want any other field. What I was doing is

```
 grok {
                         match => ["[event][description]", "%{COUPON_DATE:logdate} %{IPORHOST:machineIp} %{EMAILADDRESS:user} %{QS:account} %{QS:browser} %{QS:os} %{QS:forwardList} %{QS:ipAddress} %{QS:pageURL} %{QS:pageTitle} %{WORD:tabId} %{QS:eventType} %{GREEDYDATA:customKVP}"]
                        patterns_dir => "/etc/logstash/patterns"
                }

```

But I am getting \_grokparsefailure.

---

<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:** [June 26, 2017, 5:34am UTC](https://discuss.elastic.co/t/how-to-use-grok-filter-on-json-field/90578/2 "2017-06-26T05:34:56Z")

</div>

Since the the field is a space-separated list of strings I suggest you use the csv filter instead of grok.

---

<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 24, 2017, 5:35am UTC](https://discuss.elastic.co/t/how-to-use-grok-filter-on-json-field/90578/3 "2017-07-24T05:35:26Z")

</div>

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