Drop logs when there is a jsonparsefailure

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 thetagsarray. But I am not sure how to search in thetagsarray for_jsonparsefailurestring and drop the log event? Can someone let me know thefilter` config for the logstash?

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

See the conditionals documentation.

2 Likes

Found in the logstash doc the in conditional

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

Thanks @magnusbaeck