# How to validate incoming JSON body using Http-Input plugin

**URL:** <https://discuss.elastic.co/t/how-to-validate-incoming-json-body-using-http-input-plugin/206956>\
**Category:** Logstash\
**Created:** [November 7, 2019, 12:30pm UTC](https://discuss.elastic.co/t/how-to-validate-incoming-json-body-using-http-input-plugin/206956 "2019-11-07T12:30:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iFriT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ifrit/32/46163_2.png) [@iFriT](https://discuss.elastic.co/u/iFriT)\
**Post date:** [November 7, 2019, 12:30pm UTC](https://discuss.elastic.co/t/how-to-validate-incoming-json-body-using-http-input-plugin/206956/1 "2019-11-07T12:30:45Z")

</div>

Dears Elastic,

Using Http-Input plugin, I would like to know if there is a way to validate incoming Message (JSON) against a pre-defined JSON schema and return a specific response for example (Invalid Message) before passing the Input step ?

The scenario is very simple, clients are writing to ES through Logstash http input plugin and we need to make sure that they follow the index mapping that is pre-defined in ES

I'm really looking for some guidance on how to achieve this behavior.

Thank you

---

<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:** [November 7, 2019, 3:02pm UTC](https://discuss.elastic.co/t/how-to-validate-incoming-json-body-using-http-input-plugin/206956/2 "2019-11-07T15:02:18Z")

</div>

So you do not want to validate that it is valid JSON, you want to validate that certain fields have certain types? There is no pre-defined filter to do that. Certainly it could be implemented in logstash, but I think it would be easier to just send the event to elasticsearch and see if you get a mapping exception.

---

<div class="post-metadata">

**Author:** ![iFriT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ifrit/32/46163_2.png) [@iFriT](https://discuss.elastic.co/u/iFriT)\
**Post date:** [November 7, 2019, 8:10pm UTC](https://discuss.elastic.co/t/how-to-validate-incoming-json-body-using-http-input-plugin/206956/3 "2019-11-07T20:10:24Z")

</div>

True, it is easier to rely on ES index mapping. However, how can I instantly notify the sending (client) of the mapping exception without the client listening on Logstash DLQ. If somehow I can get the input to handle the validation and respond directly to the client before sending the event to the filter.

I'm trying to see If i can leverage logstash-http input plug internally as an API with schema validation feature

---

<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:** [December 5, 2019, 8:10pm UTC](https://discuss.elastic.co/t/how-to-validate-incoming-json-body-using-http-input-plugin/206956/4 "2019-12-05T20:10:26Z")

</div>

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