【问题标题】:Logstash count outputLogstash 计数输出
【发布时间】: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


    【解决方案1】:

    根据the doc

    默认情况下或根据 flush_interval 每 5 秒刷新一次指标。

    clear interval ...如果设置为-1,默认值,度量将永远不会被清除

    尝试将这些设置为您喜欢的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-02
      • 2016-10-01
      • 1970-01-01
      相关资源
      最近更新 更多