New to logstash.
Assume messages in kafka look like:
{"key":"val1"}
{"key":"val2"}
{"key":"val2"}
{"key":"val1"}
...
Try to count the numbers of val1 and val2 in key field, and increase statsd keys: total.val1 and total.val2
How to write the filter and statsd output.
Searching by Google, hard to find good examples.
Any good example or suggestions?
input
{
kafka
{
topic_id => 'test2'
}
}
filter
{
metrics
{
meter => ["'key':%{number}"]
add_tag => ["metric"]
}
}
output
{
if "metric" in [tags]
{
stdout
{
codec => line
{
format => "count: %{number.count}"
}
}
statsd { increment => "test.%{number.count}" }
}
}