| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
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
- data BeatEvent = BeatEvent {}
 - data Beat = Beat {}
 - newtype BulkRequest = BulkRequest [(CreateBulk, BeatEvent)]
 - newtype CreateBulk = CreateBulk {}
 - sampleToJson :: Sample -> Value
 - valueToJson :: Value -> Value
 - sampleBeatEvents :: Store -> [Text] -> IO [BeatEvent]
 - beat :: Lens' BeatEvent Beat
 - timestamp :: Lens' BeatEvent POSIXTime
 - beatTags :: Lens' BeatEvent [Text]
 - ekg :: Lens' BeatEvent Sample
 - rtt :: Lens' BeatEvent Int
 - newtype Sample = Sample Sample
 - newtype Value = Value Value
 
Converting metrics to JSON values
Types
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 | |
newtype BulkRequest Source #
Make a bulk submission to elastic
Constructors
| BulkRequest [(CreateBulk, BeatEvent)] | 
Instances
newtype CreateBulk Source #
Newtype around the index to send events to
Constructors
| CreateBulk | |
Instances
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 }