Search code examples
clojureriemann

custom config for riemann


I'm new to riemann and clojure as well. what is want is, when new event comes in, it checks its state and service, if both things got match it print some thing in console. here is my config file.

(let [index (default :ttl 300 (update-index (index)))]

  ; Inbound events will be passed to these streams:
  (streams

    ; Index all events immediately.
    index

    ; Calculate an overall rate of events.
    (with {:metric 1 :host nil :state "ok" :service "events/sec"}
      (rate 5 index))
      ; my code starts from here 
      ; _______________________
    (where (and (= :service "foo")
        (= :state "ok"))
    (println "It works"))
;________ENDS HERE ______________
    ; Log expired events.
    (expired
      (fn [event] (info "expired" event)))
))

when I start riemann, I can see "It Works" in console. but never afterwards. tell me where i'm doing wrong.?


Solution

  • The problem looks to be your use of keywords in the where expression. The where function will re-write the conditions to use keywords internally, though this behaviour doesn't appear to be clearly stated outside the API documentation. If you look at the example in the howto the conditions in where expressions don't have colons on field names.

    I have tested the following config:

    (where (and (service "foo")
        (state "ok"))
        prn)