Last active
October 2, 2015 20:27
-
-
Save graph1zzlle/ca7133aaf1d891e4cfc2 to your computer and use it in GitHub Desktop.
riemann-scratchpad
This file contains 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
;; SCENARIO: Be able to detect high heap pressure on service. | |
;; -> If during the last x minutes, "heap.usage" values are > 0.70, then alert... | |
;; Riemann API http://riemann.io/api.html | |
(defn slack-this-shit [message] | |
(slack slack-alert-channel {:username "Not so friendly Riemann bot", | |
:formatter (fn [ev] {:text (str "*"(:service ev)"*" " is in *" (:state ev) "* state on hosts: *" (:host ev) "*. " message), | |
:icon ":x:"})})) | |
(def tracking-jvm-pressure-stream | |
(where (and (tagged ["production" "jvm"]) | |
(metric "heap.usage") | |
(service "the-service")) | |
(fixed-time-window 300 | |
(smap (fn [events] | |
(let [fraction (/ (count (filter #(> (:value %) 0.80) events)) | |
(count events))] | |
{:service "the-service" | |
:metric fraction | |
:host (apply str (distinct(map :host (filter (fn [x] (> (:value x) 0.80)) events)))) | |
:state (condp < fraction | |
0.8 "critical" | |
0.5 "warning" | |
"ok" )})) | |
(changed-state {:init "ok"} (slack-this-shit "Heap sustain high pressure !")))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment