I am not sure if it is possible to make such dynamic nested hash access. I cannot found the way too.
But one possible solution could lead through using the ruby filter.
input {
generator {
type => "generated"
}
}
filter {
# make up the host_name value
mutate {
add_field => {
"host_name" => "localhost"
}
}
metrics {
meter => [ "%{host_name}" ]
flush_interval => 60
clear_interval => 300
# mark the metric event
add_tag => "metric"
}
if "metric" in [tags] {
# the metric event starts just after the metrics filter
#the host_name field should be put there back manually
mutate {
add_field => {
"host_name" => "localhost"
}
}
ruby {
code => "event['host_count'] = event[event['host_name']]['count']"
}
}
}
output {
if "metric" in [tags] {
stdout {
codec => line {
format => "rate %{host_name}: %{host_count}"
}
}
}
}
I am not sure how do you fill the host field, actually I had problems when using such variable name thus I used host_name and I am filling it statically .
Thanks for your solution, but doesn't work.
I don't know why is not working, my solution. It worked for other filter, but not metrics.
my meter is %{host}. In kibana i can see the metrics, it seems to work properly. However, in output filter, it doesn't work, i use [%{host}][count] and i get something like server1[count].
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.