【发布时间】:2018-03-18 13:24:25
【问题描述】:
我正在尝试使用 logstash 做一个简单的任务:我需要计算日志文件的日志级别。我尝试使用指标过滤器。
为了做我的测试,我使用了一个像这样的简单文件:
INFO
WARN
INFO
WARN
INFO
WARN
INFO
我使用这个 conf 文件:
input {
stdin { type => "api" }
}
filter {
grok {
match => [ "message", "%{LOGLEVEL:loglevel}" ]
}
if [loglevel] == "WARN" {
metrics {
meter => "warn"
add_tag => "metric"
}
}
}
output {
if "metric" in [tags] {
stdout {
codec => line {
format => "warn count: %{[warn][count]}"
}
}
}
}
警告计数是准确的,我得到这个输出:
io/console not supported; tty will not be manipulated
Settings: Default pipeline workers: 8
Logstash startup completed
warn count: 3
warn count: 3
warn count: 3
warn count: 3
warn count: 3
warn count: 3
warn count: 3
warn count: 3
warn count: 3
Logstash shutdown completed
谁能解释一下为什么我的输出总是 9 行?我怎样才能只得到一条线?
【问题讨论】:
标签: logstash