Skip to content

Instantly share code, notes, and snippets.

@iGEL
Created November 19, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iGEL/e352764a8c559440c851 to your computer and use it in GitHub Desktop.
Save iGEL/e352764a8c559440c851 to your computer and use it in GitHub Desktop.
; -*- mode: clojure; -*-
; vim: filetype=clojure
(def sns ((sns-publisher {:access-key (System/getenv "AWS_ACCESS_KEY_ID")
:secret-key (System/getenv "AWS_SECRET_ACCESS_KEY")
:region (System/getenv "AWS_REGION")})
"arn:aws:sns:xxx"))
(let [host "xxx"]
(tcp-server :host host :port xxx)
(udp-server :host host :port xxx)
(ws-server :host host :port xxx))
; 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)))]
(streams (tagged "health" (changed-state {:init "ok"} (rollup 3 3600 sns))))
; Inbound events will be passed to these streams:
(streams
; Index all events immediately.
index
(batch (Integer. (System/getenv "INFLUXDB_BATCH_SIZE"))
(Integer. (System/getenv "INFLUXDB_BATCH_TIME"))
(influxdb {:version :0.9
:host (System/getenv "INFLUXDB_HOST")
:port 8086
:db "riemann"
:username "xxx"
:password "xxx"}))
; 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)))
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment