Print a string to stdout using Logstash 1.4?

六眼飞鱼酱① 提交于 2019-12-06 11:26:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!