Skip to content

Instantly share code, notes, and snippets.

@GregorStocks
Created August 26, 2014 00:44
Show Gist options
  • Save GregorStocks/5384959d0c940a2d1116 to your computer and use it in GitHub Desktop.
Save GregorStocks/5384959d0c940a2d1116 to your computer and use it in GitHub Desktop.
-*- mode: clojure; -*-
; vim: filetype=clojure
(logging/init {:file "riemann.log"})
; Listen on the local interface over TCP (5555), UDP (5555), and websockets
; (5556)
(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)
(require '[clojure.string :as str])
(defn profiler [index]
(where (not (expired? event))
(splitp re-matches service
; Flatten function times across hosts, updating every 60s.
#".*profiler fn .+"
(pipe - (by :service
(coalesce 60
(smap folds/sum
(with {:host nil :time (unix-time)} -))))
; And index the top 10.
(top 10 :metric
index
(with :state "expired" index))))))
; aphyr usually haves a top-level splitp to route events to various subsystems.
(let [index (index)]
(streams
(default :ttl 62
(splitp re-find service
; Route profiler events to the profiler
#"^.*profiler fn" (profiler index)
; Index anything else
index))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment