Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
; Expire old events from the index every 15 seconds.
(periodically-expire 10 {:keep-keys [:host :service :tags]})
(def rollup-ttl 60)
(def throttle-ttl 120)
(defn event-log [prefix]
(fn [e] (info prefix (str e))))
(def email (mailer {:from "riemann@domain"}))
(def page-email (mailer {:from "pager@domain"}))
(def pd (pagerduty "KEYYYY"))
(def pager (where (state "ok") (:resolve pd) (else (:trigger pd))))
; Keep events in the index for 5 minutes by default.
(let [index (default :ttl 300 (update-index (index)))]
; Inbound events will be passed to these streams:
(streams
; Index all events immediately.
index
(changed-state {:init "ok"}
(where (not (expired? event))
; Send all events via email
(tagged-any ["notify" "page" "pager"]
(rollup 1 rollup-ttl (email "brian@domain")))
; Send paging events via pager as well
(tagged-any ["page" "pager"]
(where (not (state "warn")) pager))))
; Handle expired events separately
(by :host
(where (expired? event)
; Send all events via email
(tagged-any ["notify" "page" "pager"]
(rollup 1 rollup-ttl (event-log "rollup-expired"))) ; works
; Send paging events via pager as well
(tagged-any ["page" "pager"]
(throttle 1 10 (event-log "throttle-expired"))) ; does nothing
(else (throttle 1 10 (event-log "throttle-unexpired"))))) ; logs riemann.codec.Event@24ecd819
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.