Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
89 lines (66 sloc) 2.77 KB
(logging/init :file "/var/log/riemann.log")
(def graph (graphite {:host "localhost"}))
(defn add-environ-name
"Add the environment name to the hostname, based on the presence of a tag."
[{:keys [tags host] :as event}]
(let [tags (set tags)]
(tags "production") (update-in event [:host] str ".production")
(tags "staging") (update-in event [:host] str ".staging")
(tags "dev") (update-in event [:host] str ".dev")
:else event)))
(defn add-environ-name-combined
[{:keys [tags host] :as event}]
(let [tags (set tags)]
(assoc event :host (cond
(tags "production") "all-hosts.production"
(tags "staging") "all-hosts.staging"
(tags "dev") ""
:else "all-hosts"))))
(let [
; Streams that take events, transform them into a specific type of metric,
; and send them along to graphite.
occurrenceify #(adjust [:service str " occurences"]
(with {:metric 1.0}
meterify #(adjust [:service str " rate-per-second"]
(default {:metric 1.0}
(fill-in-last 5 {:metric 0.0}
(rate 5
histogramify #(adjust [:service str " value"]
(percentiles 5 [0.5 0.75 0.95 0.99 1.0]
; Streams that take events, look at their tags, and send them along to the
; appropriate metricizing stream(s).
occurrences #(where (tagged "occurrence")
meters #(where (tagged "meter")
histograms #(where (tagged "histogram")
timers #(where (tagged "timer")
; Gauges are special -- they're super simple.
gauges #(where (tagged "gauge")
; Shortcut to send a stream along to all metrics.
metrics #(default {}
(with {:host "riemann" :service "raw-events-processed" :metric 1.0}
(fill-in-last 5 {:metric 0.0}
(rate 5 graph)))
(adjust add-environ-name
(by [:host :service]
(adjust add-environ-name-combined
(by [:host :service]
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.