简体   繁体   中英

In logstash, How to filter logs by json key and value?

Currently I need to ignore some log in logstash.

my logstash input is as below:

 input {
    udp {
            port => 5001
            format => "json"
            type => "udp"
    }
 }

logs like {"key1":"value1", "key2":"value2"} will send to port 5001

I like to drop all logs that with "key1":"value1", how can I achieve it?

I'v tried

filter {
    grep {
            match => { "key1" => "value1" }
            negate => true
    }
}

it doesn't work.

use the if syntax to do this:

filter {
  if [key1] == "value1" {
     drop {}
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM