# How to read JSON input sent to Http input plugin in filter section

**URL:** https://discuss.elastic.co/t/how-to-read-json-input-sent-to-http-input-plugin-in-filter-section/118090
**Category:** Logstash
**Created:** [February 1, 2018, 7:16pm UTC](https://discuss.elastic.co/t/how-to-read-json-input-sent-to-http-input-plugin-in-filter-section/118090 "2018-02-01T19:16:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![elasticuser1](https://avatars.discourse-cdn.com/v4/letter/e/a3d4f5/32.png) [@elasticuser1](https://discuss.elastic.co/u/elasticuser1)
#### Post date: [February 1, 2018, 7:16pm UTC](https://discuss.elastic.co/t/how-to-read-json-input-sent-to-http-input-plugin-in-filter-section/118090/1 "2018-02-01T19:16:14Z")

</div>

Hi, I have sample http input plugin and posting json data to this plugin. I want to copy the json body into another field in order to standardize the output format. Invalid jsons are going into message field. I followed this link - [https://www.elastic.co/blog/introducing-logstash-input-http-plugin](https://www.elastic.co/blog/introducing-logstash-input-http-plugin). This link says body will be deserialized and expanded to root.. Please suggest how to do.. Thanks.

```
input {
  http {
    host => "xxx" # default: 0.0.0.0
    port => 8080 # default: 8080
  }
}
filter {
    grok {
        match => { "[headers][request_uri]" => "/app/%{WORD:App}/env/%{WORD:Environment}/dc/%{WORD:DataCenter}" }
    }
}
output {
kafka {
    codec => json
    bootstrap_servers => "xxx"
    topic_id => "xx-topic"
  }
}
```

---

<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: [February 1, 2018, 9:11pm UTC](https://discuss.elastic.co/t/how-to-read-json-input-sent-to-http-input-plugin-in-filter-section/118090/2 "2018-02-01T21:11:17Z")

</div>

Use a `stdout { codec => rubydebug }` to make debugging easier. What does an example event produced by Logstash look like?

---

<div class="post-metadata">

### Author: ![elasticuser1](https://avatars.discourse-cdn.com/v4/letter/e/a3d4f5/32.png) [@elasticuser1](https://discuss.elastic.co/u/elasticuser1)
#### Post date: [February 1, 2018, 9:38pm UTC](https://discuss.elastic.co/t/how-to-read-json-input-sent-to-http-input-plugin-in-filter-section/118090/3 "2018-02-01T21:38:32Z")

</div>

Thanks @magnusbaeck JSON body is being added to root.. How can I add the body to another field like message instead of root? Is there any configuration in input?

---

<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: [February 2, 2018, 7:19am UTC](https://discuss.elastic.co/t/how-to-read-json-input-sent-to-http-input-plugin-in-filter-section/118090/4 "2018-02-02T07:19:35Z")

</div>

The json codec that's going to be used by default in this case (as the received data probably as application/json as the declared MIME type) always stores the parsed payload in the root of the event, but you should be able to override the codec with the `additional_codecs` option to force a plain codec. Then you can use the json _filter_ to parse the JSON payload, and then you can elect to store the result under another field.

---

<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: [March 2, 2018, 7:19am UTC](https://discuss.elastic.co/t/how-to-read-json-input-sent-to-http-input-plugin-in-filter-section/118090/5 "2018-03-02T07:19:58Z")

</div>

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