Created
July 31, 2015 19:54
-
-
Save jchauncey/4cf09887141267214bc8 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
(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