ekg-carbon-1.0.10: An EKG backend to send statistics to Carbon (part of Graphite monitoring tools)

Safe HaskellNone
LanguageHaskell2010

System.Remote.Monitoring.Carbon

Description

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

main = do
  store <- newStore
  forkCarbon defaultCarbonOptions 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 package.

Synopsis

Documentation

data CarbonOptions Source #

Options to control how to connect to the Carbon 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

CarbonOptions 

Fields

  • host :: !Text

    The hostname or IP address of the server running Carbon.

  • port :: !Int

    Server port of the TCP line receiver interface.

  • flushInterval :: !Int

    The amount of time between sampling EKG metrics and pushing to Carbon.

  • prefix :: !Text

    Prefix to add to all metric names.

  • suffix :: !Text

    Suffix 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.

defaultCarbonOptions :: CarbonOptions Source #

Defaults:

  • host = "127.0.0.1"
  • port = 2003
  • flushInterval = 1000
  • Empty prefix and suffix.

forkCarbon :: CarbonOptions -> Store -> IO ThreadId Source #

Create a thread that periodically flushes the metrics in Store to Carbon. 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 forkCarbon. For more control, see forkCarbonRestart.

forkCarbonRestart :: CarbonOptions -> Store -> (SomeException -> IO () -> IO ()) -> IO ThreadId Source #

Create a thread that periodically flushes the metrics in Store to Carbon. 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 forkCarbonRestart to log failures and restart logging:

forkCarbonRestart defaultCarbonOptions
                  store
                  (\ex restart -> do hPutStrLn stderr ("ekg-carbon: " ++ show ex)
                                     restart)