ekg-elastic-0.2.2.0: Push metrics to elastic

Safe HaskellNone
LanguageHaskell2010

System.Metrics.Json

Contents

Description

Encoding of ekg metrics as metricbeats compliant JSON. This module is originally from egk-json with some tweaks for metricbeats

Synopsis

Converting metrics to JSON values

Types

data BeatEvent Source #

Encode a Sample as a metricbeat event

For reference this is the event structure

{
  "@timestamp": "2016-06-22T22:05:53.291Z",
  "beat": {
    "hostname": "host.example.com",
    "name": "host.example.com"
  },
  "metricset": {
    "module": "system",
    "name": "process",
    "rtt": 7419
  },
  .
  .
  .
  "type": "metricsets"
}

Constructors

BeatEvent 

Fields

data Beat Source #

The beat key of the BeatEvent

Constructors

Beat 

Fields

  • hostname :: !Text

    Hostname of metric source

  • name :: !Text

    Name of the beat (hardcoded to "ekg" at the moment)

  • version :: !Text

    Beat version (hardcoded to 0.1 at the moment)

Instances

Generic Beat Source # 

Associated Types

type Rep Beat :: * -> * #

Methods

from :: Beat -> Rep Beat x #

to :: Rep Beat x -> Beat #

ToJSON Beat Source # 
type Rep Beat Source # 
type Rep Beat = D1 (MetaData "Beat" "System.Metrics.Json" "ekg-elastic-0.2.2.0-Fh2boFNDaI4BmcKdqpSnOr" False) (C1 (MetaCons "Beat" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "hostname") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Text)) ((:*:) (S1 (MetaSel (Just Symbol "name") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Text)) (S1 (MetaSel (Just Symbol "version") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Text)))))

newtype BulkRequest Source #

Make a bulk submission to elastic

Constructors

BulkRequest [(CreateBulk, BeatEvent)] 

newtype CreateBulk Source #

Newtype around the index to send events to

Constructors

CreateBulk 

Fields

Conversion functions

sampleToJson :: Sample -> Value Source #

Generate the nested json for a Sample

Each "." in the metric name introduces a new level of nesting. For example, the metrics [("foo.bar", 10), ("foo.baz", "label")] are encoded as

{
  "foo": {
    "bar": {
      "type:", "c",
      "val": 10
    },
    "baz": {
      "type": "l",
      "val": "label"
    }
  }
}

valueToJson :: Value -> Value Source #

Encodes a single Value as a JSON object. Examples:

{ "count": 89460 }
{ "gauge": 300 }

sampleBeatEvents :: Store -> [Text] -> IO [BeatEvent] Source #

Generate a BeatEvent for each metric in the Store

Generated Lenses

Newtype wrappers with instances

newtype Sample Source #

Newtype wrapper that provides a ToJSON instances for the underlying Sample without creating an orphan instance.

Constructors

Sample Sample 

newtype Value Source #

Newtype wrapper that provides a ToJSON instances for the underlying Value without creating an orphan instance.

Constructors

Value Value