Logstash filter conditions does not work, as follows:
filter {
json {
source => "message"
}
if "%{client_ip}" == "-" {
mutate {
remove_field => "client_ip"
add_field => { "client_ip" => "0.0.0.0" }
}
}
}
when %{client_ip} == "-" I want replace it to 0.0.0.0 ,but it does not work,still output like :
{
"method" => "GET",
"body_bytes_sent" => "182",
"source" => "/data/wwwlogs/access_20170920.log",
"message" => "{\"@timestamp\":\"2017-09-20T12:29:01+0800\",\"client_ip\":\"-\",\"request_time\":0,\"status\":200,\"url\":\"/web/123.gif\",\"method\":\"GET\",\"http_host\":\"www.test.com\",\"server_ip\":\"192.168.1.10\",\"http_referer\":\"-\",\"http_user_agent\":\"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36\",\"body_bytes_sent\":\"182\",\"total_bytes_sent\":\"482\"}",
"http_host" => "www.test.com",
"url" => "/web/123.gif",
"http_user_agent" => "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36",
"@timestamp" => 2017-09-20T04:29:01.000Z,
"request_time" => 0,
"http_referer" => "-",
"total_bytes_sent" => "482",
"beat" => {},
"server_ip" => "192.168.1.10",
"client_ip" => "-",
"status" => 200
}