This document is a guide to "live hacking" a running Riemann instance. Riemann exposes an nREPL, allowing us to connect to it, live in production, and run Clojure code inside its brain.
This document can be considered a rudimentary form of literate Clojure:
- Open it in your editor
- Connect your editor REPL client to tcp/5557 on the Riemann instance
- Evaluate forms
(ns riemann.config)
(let [core riemann.config/core
new-stream (where (service =~ "wibble")
(tag :live-hacked (index)))]
(locking core
(swap! core assoc :streams (conj (:streams @core) new-stream)))
;; Reload services (like the TCP input) so they see the new stream.
(doseq [service (riemann.core/core-services @core)]
(riemann.service/reload! service @core)))
(let [core riemann.config/core]
(locking core
(swap! core assoc :streams (butlast (:streams @core))))
(doseq [service (riemann.core/core-services @riemann.config/core)]
(riemann.service/reload! service @riemann.config/core)))
(riemann.core/stream!
@riemann.config/core
(riemann.common/event
{:host "wibblator"
:service "wibble water level"
:metric 500
:time (riemann.time/unix-time)}))
(riemann.index/search
(riemann.config/index)
(riemann.query/ast "service =~ \"wibble %\""))
(map :metric
(riemann.index/search
(riemann.config/index)
(riemann.query/ast "service = \"wibble water level\"")))
(riemann.index/clear (:index @riemann.config/core))
(riemann.bin/reload!)