I tried to parse json input file. But logstash doesn't parse the logs and not adding custom field "add_field". I think, my filter configuration is wrong. Someone please help me on this.
Logs file:
{"web1":{"stat1":{"mem":261831,"Name":"stat1","cpu":89}},"web2":{"stat2":{"mem":23456,"Name":"stat2","cpu":76}}
}
Logstash filter config:
filter {
if [type] == "localapp" {
if [Name] {
date {
target => "@timestamp"
locale => "en"
add_field => { "testapp" => "%{Name}"}
}
}
}
}
Output:
{
"web1" => {
"stat1" => {
"mem" => 261831,
"Name" => "stat1",
"cpu" => 89
}
},
"web2" => {
"stat2" => {
"mem" => 23456,
"Name" => "stat2",
"cpu" => 76
}
},
"@version" => "1",
"@timestamp" => "2016-06-20T05:52:25.002Z",
"type" => "localapp",
"host" => "gugan"
}
Here you can see custom field is not added.