Last active
August 29, 2015 14:01
-
-
Save maxthoursie/08386518fe411e871837 to your computer and use it in GitHub Desktop.
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
(defn trigger-above-cancel-below | |
"Set state to \"critical\" when metric is > above for trigger_window seconds. | |
Reset to \"ok\" when metric is < below for cancel-window seconds." | |
[above trigger-window below cancel-window & children] | |
(let [changed-stream (changed-state {:init "ok"} | |
#(call-rescue % children)) | |
;; Forward critical or ok if they are stable | |
stable-stream (sdo | |
(stable trigger-window :state | |
(where (state "critical") changed-stream)) | |
(stable cancel-window :state | |
(where (state "ok") changed-stream)))] | |
;; Classify the metric into ok/middle/critical | |
(split | |
(> metric above) (with :state "critical" stable-stream) | |
(< metric below) (with :state "ok" stable-stream) | |
(with :state "middle" stable-stream)))) |
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
(defn trigger-above-cancel-below | |
"Set state to \"critical\" when metric is > above for trigger_window seconds. | |
Reset to \"ok\" when metric is < below for cancel-window seconds." | |
[above trigger-window below cancel-window & children] | |
(pipe -- | |
(split | |
(> metric above) (with :state "critical" --) | |
(< metric below) (with :state "middle" --) | |
(with :state "ok" --)) | |
(sdo | |
(stable trigger-window :state | |
(where (state "critical") --)) | |
(stable cancel-window :state | |
(where (state "ok") --))) | |
(changed-state {:init "ok"} | |
#(call-rescue % children)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment