问题
So I was testing this config for using metrics from the Logstash website here.
input {
generator {
type => "generated"
}
}
filter {
if [type] == "generated" {
metrics {
meter => "events"
add_tag => "metric"
}
}
}
output {
# only emit events with the 'metric' tag
if "metric" in [tags] {
stdout {
message => "rate: %{events.rate_1m}"
}
}
}
But it looks like the "message" field for stdout was deprecated. What is the correct way to do this in Logstash 1.4?
回答1:
So figured it out after looking at the JIRA page for Logstash.
NOTE: The metrics only print or "flush" every 5 seconds so if you are generating logs for less than 5 seconds, you won't see a metrics print statement
Looks like it should be:
output {
if "metric" in [tags]
{
stdout {
codec => line {
format => "Rate: %{events.rate_1m}"
}
}
}
}
来源:https://stackoverflow.com/questions/24452239/print-a-string-to-stdout-using-logstash-1-4