clojure - How to use AND operation in Riemann -


i have riemann code trigger email when both condition met . wrote below code.

(let [email (mailer {....email configuration})]         (streams     (where (service "log")         (smap           (fn [events]            (let [count-of-failures (count (filter #(= "failed" (:status %)) events) , (filter #(= "uk" (:country %)) events))] ;calculate count matched value               (event               {                  :status "failure"                  :metric  count-of-failures                   :total-fail (>= count-of-failures 2)})))            (where (and (= (:status event) "failure")                       (:total-fail event))               (email "xxx@xx.com")              )prn)))) 

i getting below error once started execute clojure.lang.arityexception: wrong number of args (3) passed to:

can please suggest me right way use , operation here.

thanks in advance

you give 3 args count - therefore error.

why truncate error output right before essential information ... args (3) passed to: count beyond me.

(let [email (mailer {....email configuration})]   (streams    (where (service "log")           (smap            (fn [events]              (let [count-of-failures (count ; <--- count takes 1 argument                                       (filter #(= "failed" (:status %)) events)                                       ,                                       (filter #(= "uk" (:country %)) events))] ;calculate count matched value                (event                 {:status "failure"                  :metric  count-of-failures                  :total-fail (>= count-of-failures 2)})))             (where (and (= (:status event) "failure")                        (:total-fail event))                   (email "xxx@xx.com")) prn)))) 

it's not clear description, did mean do:

(count (and (filter ...) (filter ...))  

which counts the last not-nil collection ?


i want check 2 condition status should failed , country should uk . if email should triggered

does help? :

(def event {:status "failed" :country "uk"}) ; example1 (some #(and (= "failed" (:status %)) (= (:country %) "uk")) [event]) ; => true (def event {:status "failed" :country "us"}) ; example2 (some #(and (= "failed" (:status %)) (= (:country %) "uk")) [event]) ; => nil 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -