# Drop logs when there is a jsonparsefailure

**URL:** <https://discuss.elastic.co/t/drop-logs-when-there-is-a-jsonparsefailure/28655>\
**Category:** Logstash\
**Created:** [September 4, 2015, 7:27am UTC](https://discuss.elastic.co/t/drop-logs-when-there-is-a-jsonparsefailure/28655 "2015-09-04T07:27:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deb/32/46162_2.png) [@Deb](https://discuss.elastic.co/u/Deb)\
**Post date:** [September 4, 2015, 7:27am UTC](https://discuss.elastic.co/t/drop-logs-when-there-is-a-jsonparsefailure/28655/1 "2015-09-04T07:27:46Z")

</div>

Hi,

I am trying to push some of our logs to elasticsearch via logstash. Can some one let me know how can I drop the logs in logstash itself if the logs are not in proper json format , before they are being pushed to elasticsearch.

I can see a `_jsonparsefailure in the`tags`array. But I am not sure how to search in the`tags`array for`\_jsonparsefailure`string and drop the log event? Can someone let me know the`filter` config for the logstash?

---

<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:** [September 4, 2015, 7:33am UTC](https://discuss.elastic.co/t/drop-logs-when-there-is-a-jsonparsefailure/28655/2 "2015-09-04T07:33:59Z")

</div>

```
filter {
  if "_jsonparsefailure" in [tags] {
    drop { }
  }
}

```

See the [conditionals documentation](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals).

---

<div class="post-metadata">

**Author:** ![Deb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deb/32/46162_2.png) [@Deb](https://discuss.elastic.co/u/Deb)\
**Post date:** [September 4, 2015, 7:34am UTC](https://discuss.elastic.co/t/drop-logs-when-there-is-a-jsonparsefailure/28655/3 "2015-09-04T07:34:44Z")

</div>

Found in the logstash [doc](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html) the `in` conditional

```
filter {
  if "_jsonparsefailure" in [tags] {
        drop { }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Deb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deb/32/46162_2.png) [@Deb](https://discuss.elastic.co/u/Deb)\
**Post date:** [September 4, 2015, 7:35am UTC](https://discuss.elastic.co/t/drop-logs-when-there-is-a-jsonparsefailure/28655/4 "2015-09-04T07:35:00Z")

</div>

Thanks @magnusbaeck

---

<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 6, 2017, 5:30am UTC](https://discuss.elastic.co/t/drop-logs-when-there-is-a-jsonparsefailure/28655/5 "2017-07-06T05:30:07Z")

</div>


