I'm trying to give syntax like 'if [@metadata][field] exists then do this' in output
output{
if [@metadata][field] {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "%{[@metadata][field]}"
}
}
}
I used two config files. One config file , I created input{} filter{} output{}(like above) , other file only filter{} which adds a field [@metadata][field] like
filter{
mutate {
add_field => { "[@metadata][index_name]" => "abc" }
}
}
The index gets created in elasticsearch, when I comment the if statement in the output, but when I remove, it does not get created.
How to make command enter into if statement?