描述事件在黎曼获得nil

时间:2015-11-13 10:17:32

标签: clojure clojurescript riemann

我正在尝试使用Riemann从logstash发送电子邮件警报。我的电子邮件应该在满足某些条件时触发。我写了Riemann配置发送电子邮件提醒,因为我从logstash发送了某些事件,我有硬编码:description字段,但在我的黎曼服务器中,我总是看到描述为nil。我不知道我哪里出错了。

Riemann Config

(let [host "127.0.0.1"]
  (tcp-server {:host host})
  (udp-server {:host host})
  (ws-server  {:host host}))

  ;Create index and print the values indexed
  (let [eindex (default :ttl 300 (update-index (index)))])


  ;Index event for reserve webservice failure
  (let [email (mailer{…….})]

  (streams
    (where (service "e_log")
      (fixed-time-window
        1 
        (smap
          (fn [events]
           (let [count-of-failures (count (filter #(re-find #"system space*" (:description %)) events))]        ;Calculate the count for matched value
               (event
                {:status "Failure"
                 :metric  count-of-failures 
                 :total-fail (>= count-of-failures 1)})))

          (where (and (= (:status event) "Failure")
                      (:total-fail event))

            (email "dfbnn@gmail.com"))prn)))))

Logstash配置

    riemann{
        host=>localhost
             riemann_event => { "service" => "e_log"
"description" => "system space communication"
"metric" => "%{metric}"
"ttl" => "%{ttl}"                                                                                 
                          }                                        
                    }

在我的Riemann服务器中,我看到:description字段始终为nil,因此:total-fail始终为false。

Riemann Server

riemann.codec.Event{:host nil, :service nil, :state nil, :description nil, :metric 0, :tags nil, :time 1447406529, :ttl nil, :status "Failure", :total-fail false}
riemann.codec.Event{:host nil, :service nil, :state nil, :description nil, :metric 0, :tags nil, :time 1447406529, :ttl nil, :status "Failure", :total-fail false}
riemann.codec.Event{:host nil, :service nil, :state nil, :description nil, :metric 0, :tags nil, :time 1447406529, :ttl nil, :status "Failure", :total-fail false}
riemann.codec.Event{:host nil, :service nil, :state nil, :description nil, :metric 0, :tags nil, :time 1447406529, :ttl nil, :status "Failure", :total-fail false}
riemann.codec.Event{:host nil, :service nil, :state nil, :description nil, :metric 0, :tags nil, :time 1447406529, :ttl nil, :status "Failure", :total-fail false}

提前致谢

1 个答案:

答案 0 :(得分:0)

我想到了两件事:

  1. 发送这些事件的代码出了点问题。你能打开有效载荷吗?
  2. 这是一个很远的镜头:这些事件是否过期了?如果是,很可能没有保留钥匙。试试这个:(定期过期5 {:keep-keys [:host:service:description ... etc ...]})(当然,将5更改为你希望它发生的任何值)。