# How to parse the log using grok to get the key value pairs from the log, and have the key as a new field

**URL:** https://discuss.elastic.co/t/how-to-parse-the-log-using-grok-to-get-the-key-value-pairs-from-the-log-and-have-the-key-as-a-new-field/82623
**Category:** Logstash
**Created:** [April 17, 2017, 7:47pm UTC](https://discuss.elastic.co/t/how-to-parse-the-log-using-grok-to-get-the-key-value-pairs-from-the-log-and-have-the-key-as-a-new-field/82623 "2017-04-17T19:47:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sanju090](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@sanju090](https://discuss.elastic.co/u/sanju090)
#### Post date: [April 17, 2017, 7:47pm UTC](https://discuss.elastic.co/t/how-to-parse-the-log-using-grok-to-get-the-key-value-pairs-from-the-log-and-have-the-key-as-a-new-field/82623/1 "2017-04-17T19:47:24Z")

</div>

{"apiResponse":"{"errors":[{"code":"APP-1007","message":"Session has Expired.","fields":null}],"warnings":null}","requestUrl":"[http://localhost:8082/checkSessionValidity](http://localhost:8082/checkSessionValidity)"}

This is how the message looks like, I want to know how do i parse apiResponse and requestUrl and create the new fields and have their corresponding values

**"\_apiResponse"** : **"{"errors":[{"code":"APP-1007","message":"Session has Expired.","fields":null}],"warnings":null}"**

**"\_requestUrl"** : **"[http://localhost:8082/checkSessionValidity](http://localhost:8082/checkSessionValidity)"**

I am new to grok filter, sorry if this is a basic question

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [April 17, 2017, 7:53pm UTC](https://discuss.elastic.co/t/how-to-parse-the-log-using-grok-to-get-the-key-value-pairs-from-the-log-and-have-the-key-as-a-new-field/82623/2 "2017-04-17T19:53:35Z")

</div>

This looks like a JSON string, so try using the [json filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-json.html) 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: [May 15, 2017, 7:58pm UTC](https://discuss.elastic.co/t/how-to-parse-the-log-using-grok-to-get-the-key-value-pairs-from-the-log-and-have-the-key-as-a-new-field/82623/3 "2017-05-15T19:58:42Z")

</div>

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