本文介绍了使用Logstash 1.4将字符串打印到stdout吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我正在测试配置是否使用Logstash网站上的指标此处
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}"
}
}
}
但是似乎不建议使用stdout的"message"字段.在Logstash 1.4中执行此操作的正确方法是什么?
But it looks like the "message" field for stdout was deprecated. What is the correct way to do this in Logstash 1.4?
推荐答案
因此,在查看了Logstash的JIRA页面后就知道了.
So figured it out after looking at the JIRA page for Logstash.
注意:指标仅每5秒打印或刷新"一次,因此,如果生成日志的时间少于5秒,则不会看到指标打印语句
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
看起来应该是:
output {
if "metric" in [tags]
{
stdout {
codec => line {
format => "Rate: %{events.rate_1m}"
}
}
}
}
这篇关于使用Logstash 1.4将字符串打印到stdout吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!