Last active
September 2, 2016 15:41
-
-
Save manute/8852537 to your computer and use it in GitHub Desktop.
Riemann Service Down Alerts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; | |
; Riemann Service Down Alerts | |
; =================================================== | |
; | |
; The index stores the most recent state for any [host, service] pair. Clients | |
; can search the index for various states with a basic query language. The | |
; default implementation is a NonBlockingHashMap. | |
; | |
(let [my-index (index) | |
; Let's also define a stream that feeds states into this index. We'll | |
; call it index for short. | |
index (update-index my-index)] | |
; When services disappear or fail, their states in the index will get stale. | |
; Periodically, Riemann can scan the index and delete states that have exceeded | |
; their TTL. You'll receive events with the deleted statee's original :host, | |
; :service, and :state "expired". | |
; | |
; To expire old states every ten seconds: | |
(periodically-expire 10) | |
; You can select expired events with where, or the expired stream: | |
(streams | |
(where (state "expired") prn) | |
(expired prn)) | |
; This way, Riemann can issue an alert for a service that failed to check in | |
; regularly. The default TTL is 60 seconds, but you can submit ttls with each | |
; event or assign them using (with) or (default). | |
(streams | |
(default :ttl 10 index) | |
(by [:host :service] | |
(changed :state {:init "ok"} | |
#(info "email with event expired" %)))));;(:trigger pd) | |
; Any service that fails to check in within every 10 seconds will be removed | |
; and an alert sent. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment