Skip to content

Instantly share code, notes, and snippets.

@jchauncey
Created July 31, 2015 19:54
Show Gist options
  • Save jchauncey/4cf09887141267214bc8 to your computer and use it in GitHub Desktop.
Save jchauncey/4cf09887141267214bc8 to your computer and use it in GitHub Desktop.
(require '[clojure.string :as str])
(require '[riemann.common :as common])
(logging/init)
(info "loading" *config-file*)
(tcp-server :host "0.0.0.0" :port 5555)
(udp-server :host "0.0.0.0" :port 5556)
; Expire old events from the index every 5 seconds.
(periodically-expire 5)
(defn create-nginx-metrics [event]
(let [split_description (str/split (:description event) #"-")]
(common/event {:service (str "router-http-response-code-" (get split_description 3))
:host (get split_description 8)
:metric 1
:state "ok"})
(common/event {:service "router-response-time"
:host (get split_description 8)
:metric (get split_description 12)
:state "ok"})))
(let [index (index)]
(streams
(default :ttl 300
; Index all events immediately.
index
(where (and (service #"router") (not (state "expired"))) create-nginx-metrics)
(where (and (service #"router.*") (not (state "expired"))) prn)
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment