ekg-influxdb-0.2.0.0: An EKG backend to send statistics to influxdb

System.Remote.Monitoring.Influxdb

Description

This module lets you periodically flush metrics to a influxdb backend. Example usage:

import qualified Database.Influxdb as Influxdb
main = do
store <- newStore
forkInfluxdb (defaultInfluxdbOptions (Influxdb.writeParams "database")) store

You probably want to include some of the predefined metrics defined in the ekg-core package, by calling e.g. the registerGcMetrics function defined in that pacakge.

NOTE: This package has been modelled after the ekg-carbon package, and is almost identical. The author is indebted to those fine folks who wrote the ekg-carbon package.

Synopsis

# Documentation

Options to control how to connect to the Influxdb server and how often to flush metrics. The flush interval should match the shortest retention rate of the matching retention periods, or you risk over-riding previous samples.

Constructors

 InfluxdbOptions FieldswriteParams :: !WriteParamsThe write parameters for Influxdb.flushInterval :: !IntThe amount of time between sampling EKG metrics and pushing to Influxdb.prefix :: !TextPrefix to add to all matric names.suffix :: !TextSuffix to add to all metric names. This is particularly useful for sending per host stats by settings this value to: takeWhile (/= '.') <\$> getHostName, using getHostName from the Network.BSD module in the network package.

Defaults

• flushInterval = 1000
• Empty prefix and suffix.

Create a thread that periodically flushes the metrics in Store to Influxdb. If the thread flushing statistics throws an exception (for example, the network connection is lost), this exception will be thrown up to the thread that called forkInfluxdb. For more control, see forkInfluxdbRestart.

forkInfluxdbRestart :: InfluxdbOptions -> Store -> (SomeException -> IO () -> IO ()) -> IO ThreadId Source #

Create a thread that periodically flushes the metrics in Store to Influxdb. If the thread flushing statistics throws an exception (for example, the network connection is lost), the callback function will be invoked with the exception that was thrown, and an IO computation to restart the handler.

For example, you can use forkInfluxdbRestart to log failures and restart logging:

forkInfluxdbRestart defaultInfluxdbOptions
store
(\ex restart -> do hPutStrLn stderr ("ekg-influxdb: " ++ show ex)
restart)