Last active
December 25, 2015 04:29
-
-
Save robkuz/6918034 to your computer and use it in GitHub Desktop.
I have an adjust-state fn which I use to, well adjust the state ;-) thru which I stream all my events.
And then I have a changedx fn (basically its the riemann.streams.changed fn with added debug output). Now If I run this I get multiple outputs for every host/service combination event thou the state hasn't changed. If I stream events directly f…
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 transform-event [event options] | |
(let [ event-path (event-to-vector event) | |
state-values (find-state-thresholds event-path options) | |
state (find-state (:metric event) state-values) | |
new-event (assoc event :state state)] | |
new-event)) | |
(defn adjust-state [options & children] | |
(fn [e] | |
(let [ new-event (transform-event e options)] | |
(call-rescue new-event children)))) | |
(defn changedx [pred & children] | |
(let [ options (first children) | |
previous (ref | |
(when (map? options) | |
(:init options))) | |
children (if (map? options) | |
(rest children) | |
children)] | |
(fn stream [event] | |
(when | |
(dosync | |
(let [ cur (pred event) | |
old (deref previous) | |
] | |
(when-not (= cur old) | |
(println (str "200: '" (:service event) "@" (:host event) ": " old "'='" cur "'")) | |
(ref-set previous cur) | |
true))) | |
(call-rescue event children))))) | |
(let [index (default :ttl 30 (update-index (index)))] | |
(streams | |
(adjust-state threshold-options | |
(where (host "monitoring-agent") | |
(changedx :state {:init "started"} notify-me-and-the-world)) | |
index))) |
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
;this works as expected | |
;but I need to stream thru adjust-state | |
(let [index (default :ttl 30 (update-index (index)))] | |
(streams | |
(where (host "monitoring-agent") | |
(changedx :state {:init "started"} notify-me-and-the-world)) | |
(adjust-state threshold-options | |
index))) |
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
200: 'load-15@monitoring-agent: ok'='critical' 200: '/@monitoring-agent: critical'='ok' | |
200: 'load-15@monitoring-agent: ok'='critical' 200: '/@monitoring-agent: critical'='ok' | |
200: 'load-15@monitoring-agent: ok'='critical' | |
200: '/@monitoring-agent: critical'='ok' | |
200: 'load-15@monitoring-agent: ok'='critical' | |
200: '/@monitoring-agent: critical'='ok' | |
200: 'load-15@monitoring-agent: ok'='critical' | |
200: '/@monitoring-agent: critical'='ok' | |
200: 'load-15@monitoring-agent: ok'='critical' | |
200: '/@monitoring-agent: critical'='ok' | |
200: 'load-15@monitoring-agent: ok'='critical' | |
200: '/@monitoring-agent: critical'='ok' | |
200: 'load-15@monitoring-agent: ok'='critical' | |
200: '/@monitoring-agent: critical'='ok' | |
200: 'load-15@monitoring-agent: ok'='critical' | |
200: '/@monitoring-agent: critical'='ok' | |
200: 'load-15@monitoring-agent: ok'='critical' | |
200: '/@monitoring-agent: critical'='ok' | |
200: 'load-15@monitoring-agent: ok'='critical' | |
200: '/@monitoring-agent: critical'='ok' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment