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 '[clj-http.client :as http]) | |
(require '[riemann.common :as common]) | |
(defn remote-post [event] | |
(http/post "http://example.com/post_event" {:body (common/event-to-json event) | |
:content-type :json | |
:accept :json })) | |
(logging/init :file "riemann.log") | |
(let [host "0.0.0.0"] | |
(tcp-server :host host) | |
(udp-server :host host) | |
(ws-server :host host)) | |
; Expire old events from the index every 5 seconds. | |
(periodically-expire 5) | |
; Keep events in the index for 5 minutes by default. | |
(let [index (default :ttl 300 (update-index (index)))] | |
; Inbound events will be passed to these streams: | |
(streams | |
; Index all events immediately. | |
index | |
; Calculate an overall rate of events. | |
(with {:metric 1 :host nil :state "ok" :service "events/sec"} | |
(rate 5 index)) | |
; Log expired events. | |
(expired | |
(fn [event] (info "expired" event))) | |
(where (tagged "mytag") remote-post) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment