Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- data InfluxdbOptions = InfluxdbOptions {
- writeParams :: !WriteParams
- flushInterval :: !Int
- prefix :: !Text
- suffix :: !Text
- defaultInfluxdbOptions :: WriteParams -> InfluxdbOptions
- forkInfluxdb :: InfluxdbOptions -> Store -> IO ThreadId
- forkInfluxdbRestart :: InfluxdbOptions -> Store -> (SomeException -> IO () -> IO ()) -> IO ThreadId
Documentation
data InfluxdbOptions Source #
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.
InfluxdbOptions | |
|
forkInfluxdb :: InfluxdbOptions -> Store -> 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), 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)