aphyr/riemann — pull request #23 by pyr (2012-10-19 07:18:26+00:00)
Title: Add a graphite listener.

This will obviously be less efficient than the protobuf tcp-server
or udp-server. But it will allow easy set up with other tools
in the monitoring chain - collectd, statsd for instance -
with very little configuration.

In the configuration, a graphite server is simply started by
issuing `(graphite-server)`. The server will yield events with
only service, metric and timestamp filled. NaN values will be
discarded.

Should you want to do additional handling on the values you
can feed graphite-server a parser-fn yielding a map to
merge onto the event. For instance if you emit data
from collectd using the write_graphite output with the following
configuration:

```

Prefix "collectd."
Host "localhost"
Port 2003

```

You can use the following to have a nicer event, containing hostname
and tags:

```clojure
(graphite-server
:parser-fn (fn [{:keys [service] :as event}]
(if-let [[src host service & tags]
(clojure.string/split service #"\.")]
{:host (clojure.string/replace host #"_" ".")
:service (clojure.string/join "." (concat [service] tags))
:tags (concat tags [src])})))
```