Skip to content

Instantly share code, notes, and snippets.

@briancline
Created January 18, 2013 18:37
Show Gist options
  • Save briancline/4567065 to your computer and use it in GitHub Desktop.
Save briancline/4567065 to your computer and use it in GitHub Desktop.
(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