Print a string to stdout using Logstash 1.4?

2019-04-12 20:42发布

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条回答
唯我独甜
2楼-- · 2019-04-12 21:43

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}"
                        }

                }
        }
}
查看更多
登录 后发表回答