# Filter JSON content in field and parse target with existing mapping

**URL:** <https://discuss.elastic.co/t/filter-json-content-in-field-and-parse-target-with-existing-mapping/132350>\
**Category:** Logstash\
**Created:** [May 17, 2018, 2:12pm UTC](https://discuss.elastic.co/t/filter-json-content-in-field-and-parse-target-with-existing-mapping/132350 "2018-05-17T14:12:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![baba](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@baba](https://discuss.elastic.co/u/baba)\
**Post date:** [May 17, 2018, 2:12pm UTC](https://discuss.elastic.co/t/filter-json-content-in-field-and-parse-target-with-existing-mapping/132350/1 "2018-05-17T14:12:39Z")

</div>

Hi,  
I'm trying to filter a second type of messages coming in my input queue.  
The difference between messages is that in the second type of messages the log is embedded in a JSON as value of the "Message" field. I configured the JSON filter plugin as follow:

```auto
filter {
  json {
    source => "Message"
    target => "doc"
    remove_field => ["Message"]
  }
}

```

As expected the JSON parsed value of "Message" is placed in the new field "doc". Now, I'm struggling to further parse the "doc" nested fields. I'm using the `add_field` parameter to do this, without success tho.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 17, 2018, 3:15pm UTC](https://discuss.elastic.co/t/filter-json-content-in-field-and-parse-target-with-existing-mapping/132350/2 "2018-05-17T15:15:34Z")

</div>

Can you show us what the doc field looks like and explain exactly what you want to parse from it?

---

<div class="post-metadata">

**Author:** ![baba](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@baba](https://discuss.elastic.co/u/baba)\
**Post date:** [May 17, 2018, 3:35pm UTC](https://discuss.elastic.co/t/filter-json-content-in-field-and-parse-target-with-existing-mapping/132350/3 "2018-05-17T15:35:21Z")

</div>

Here's an example:

```auto
{
      "filename" => "fixtures/sqs.py",
    "@timestamp" => 2018-05-17T15:34:00.215Z,
         "cg_id" => "c6b46234-74d1-45dd-ab3e-1402b2f7147b",
      "@version" => "1",
          "name" => "mex-test",
       "message" => "This is a manually inserted message",
           "env" => "testing",
     "levelname" => "INFO",
        "region" => "local",
      "customer" => "TestCustomerCG",
          "tags" => [
        [0] "_dateparsefailure"
    ]
}
{
          "Type" => "Notification",
    "@timestamp" => 2018-05-17T15:34:00.268Z,
      "@version" => "1",
          "json" => "{\"_id\": null, \"levelname\": \"INFO\", \"asctime\": \"2018/05/11 16:02:14.209597\", \"customer\": \"TestCustomerCG\", \"message\": \"This is a manually inserted message as wrapped by SNS\", \"name\": \"test-logger\", \"funcName\": \"<module>\", \"filename\": \"fixtures/sqs.py\", \"env\": \"testing\", \"region\": \"local\"}"

```

So basically I need the nested field in `"json"` to be unwrapped and shown as the fields of the first message.

---

<div class="post-metadata">

**Author:** ![sgalinma](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@sgalinma](https://discuss.elastic.co/u/sgalinma)\
**Post date:** [May 17, 2018, 3:52pm UTC](https://discuss.elastic.co/t/filter-json-content-in-field-and-parse-target-with-existing-mapping/132350/4 "2018-05-17T15:52:42Z")

</div>

Have you tried using "codec" =\> "json" in your output plugin?

---

<div class="post-metadata">

**Author:** ![baba](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@baba](https://discuss.elastic.co/u/baba)\
**Post date:** [May 17, 2018, 3:58pm UTC](https://discuss.elastic.co/t/filter-json-content-in-field-and-parse-target-with-existing-mapping/132350/5 "2018-05-17T15:58:17Z")

</div>

Yes, nothing changes

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 17, 2018, 4:39pm UTC](https://discuss.elastic.co/t/filter-json-content-in-field-and-parse-target-with-existing-mapping/132350/6 "2018-05-17T16:39:09Z")

</div>

So you have json in a field called json. Use a json filter to parse it.

```
json { source => "json" target => "someField" }
```

---

<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:** [June 14, 2018, 4:39pm UTC](https://discuss.elastic.co/t/filter-json-content-in-field-and-parse-target-with-existing-mapping/132350/7 "2018-06-14T16:39:11Z")

</div>

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