我从 logstash 获取日志并将包含错误的消息发送到 riemann 服务器。
logsash message : message" => "Jul 10 04:34:47 : [ERROR] [host] Sample abc123"
在 riemann 中,我需要编写一个逻辑来查找同一样本(即样本 abc 123)在 5 分钟内是否发生 2 次以上相同的错误,然后我必须在控制台上警告 /print(目前我正在尝试打印以测试)
下面是我实现这一目标的逻辑,目前它只打印 nil 而不是消息,有人可以在这里帮助我。
(by [:message]
;; over time windows of 5 seconds...
(fixed-time-window 5
;; calculate the average value of the metric and emit an average (summary) event
(combine folds/mean
;; collect the summary event over the last 3 fixed-time-windows
(moving-event-window 2
;;find the summary event with the minimum average metric
(combine folds/minimum
(where (> metric 2.0)
prn
;;(email "xyz")
)
)
)
)
)
)
(如果我只使用固定时间窗口而不使用其他任何东西,它每 2 秒打印一次消息,但我只想在相同的样本在 5 分钟内出现 2 次时才打印)
以黎曼事件为例:
:service "logstash",
:time 1468920656,
:state "critical",
:host "0.0.0.0",
:ttl nil,
:message "Jul 11 04:34:47 <hostname>: [ERROR] [xyz] - Sample abc123 causes problem for ...""