Skip to content

Instantly share code, notes, and snippets.

View chiradeep's full-sized avatar

Chiradeep Vittal chiradeep

View GitHub Profile
@chiradeep
chiradeep / cloudwatch_riemann_2.clj
Created January 9, 2014 23:24
Riemann function for threshold crossing alerts
(defn tc [wndtime numwnds threshold & children]
(fixed-event-window wndtime
(combine folds/mean
(moving-event-window numwnds
(combine folds/minimum
(where (> metric threshold)
;;create a threshold crossing event
(with {:host nil :state "threshold crossed" :description (str "service crossed the value of " threshold " over " numwnds " windows of " wndtime " seconds")}
(apply sdo children)))))))
)
@chiradeep
chiradeep / cloudwatch_riemann_1.clj
Created January 9, 2014 23:11
Riemann configuration to generate notifications like CloudWatch Alarms
(streams
(where (not (expired? event))
;; over time windows of 3 seconds...
(fixed-time-window 3
;; calculate the average value of the metric and emit an average (summary) event
(combine folds/mean
;; if there are no events in the window, we can get nil events
(where (not (nil? event))
#(info "average event" %)