-
Clone the Riemann Git repository (clones into directory
riemann
):
$ git clone https://github.com/aphyr/riemann.git
-
Checkout the last stable version (0.2.2 in our case):
$ cd riemann
$ git checkout tags/0.2.2
-
Add Carmine dependency to
riemann/project.clj
:
[com.taoensso/carmine "1.12.0"]
-
Add the Redis persistence functionality to Riemann's config file
riemann/config.riemann
:
(ns riemann.config
(:require [taoensso.carmine :as car]))
; Assuming a locally running Redis server listening on port 6379.
(def pool (car/make-conn-pool))
(def spec-server1 (car/make-conn-spec))
(defmacro wcar [& body] `(car/with-conn pool spec-server1 ~@body))
(defn persist-event [& children]
(fn [event]
; Persist event to a Redis list with name '<SERVICE>.new-events'.
(try
(wcar (car/lpush (str (:service event) ".new-events") event))
(catch Exception e
(error "Redis datastore not available.")))
(call-rescue event children))
)
It's then used this way in riemann/config.riemann
:
; Persist events to Redis where service equals 'foo'.
; Exclude those 'foo' events where state 'expired'.
; Additionally add events to 'index'.
(where
(and
(service "foo")
(not (state "expired"))
)
(persist-event index))
- Try it out with a locally running Redis server:
$ lein run
Now it's time to generate some events containing:service "foo"
so thewhere
filter from above matches.
If the events of servicefoo
were successfully persisted into Redis, there should be a length greater than zero (3 in our case) infoo.new-events
(check with Redis shell):
$ redis-cli
redis 127.0.0.1:6379> LLEN foo.new-events
(integer) 3
If this modified version of Riemann should be deployed with the help of lein tar
, then it's necessary to copy riemann/riemann.config
into riemann/pkg
first. This way the config file is then located in the etc
sub directory after extracting the .tar.bz2
archive (created by lein tar
) on the production machine.