Documentation
¶
Overview ¶
Package legacy implements decoding routines for legacy metric formats.
Index ¶
- Variables
- func PeekHostID(data []byte) (int, error)
- type Fetcher
- type FloatMetric
- type FloatMetrics
- type Formatter
- type IntMetric
- type IntMetrics
- type MetricBatch
- type MetricData
- type MetricElastic
- type MetricSocket
- type MetricSplit
- type MetricValue
- type PluginMetric
- type PluginMetricBatch
- type StringMetric
- type StringMetrics
Constants ¶
This section is empty.
Variables ¶
var Debug = false
Debug set to true means unexpected input will be skipped and spewed to StdErr. When set to false, it will return error instead.
Functions ¶
func PeekHostID ¶
PeekHostID returns the HostID from a MetricBatch
Types ¶
type Fetcher ¶
type Fetcher func() error
Fetcher is a function that will fill the metrics Registry with current values.
type FloatMetric ¶
type FloatMetric struct {
Metric string `json:"metric"`
Subtype string `json:"subtype"`
Value float64 `json:"value"`
}
FloatMetric represents a single metric value of type float64
type FloatMetrics ¶
type FloatMetrics []FloatMetric
FloatMetrics is a FloatMetric collection for sort.Interface
func (FloatMetrics) Len ¶
func (slice FloatMetrics) Len() int
Len returns the length of the collection
func (FloatMetrics) Less ¶
func (slice FloatMetrics) Less(i, j int) bool
Less sorts in ascending lexical order
func (FloatMetrics) MarshalJSON ¶
func (slice FloatMetrics) MarshalJSON() ([]byte, error)
MarshalJSON assembles a JSON substring for FloatMetrics
func (FloatMetrics) Swap ¶
func (slice FloatMetrics) Swap(i, j int)
Swap switches the position of the slice elements i, j
type Formatter ¶
type Formatter func(*PluginMetricBatch) func(string, interface{})
Formatter is a function that will format the metrics Registry metrics into PluginMetricBatch. The returned function will be called via metrics.Registry.Each()
type IntMetric ¶
type IntMetric struct {
Metric string `json:"metric"`
Subtype string `json:"subtype"`
Value int64 `json:"value"`
}
IntMetric represents a single metric value of type int64
type IntMetrics ¶
type IntMetrics []IntMetric
IntMetrics is a IntMetric collection for sort.Interface
func (IntMetrics) Less ¶
func (slice IntMetrics) Less(i, j int) bool
Less sorts in ascending lexical order
func (IntMetrics) MarshalJSON ¶
func (slice IntMetrics) MarshalJSON() ([]byte, error)
MarshalJSON assembles a JSON substring for IntMetrics
func (IntMetrics) Swap ¶
func (slice IntMetrics) Swap(i, j int)
Swap switches the position of the slice elements i, j
type MetricBatch ¶
type MetricBatch struct {
HostID int `json:"hostID"`
Protocol int `json:"protocol"`
Data []MetricData `json:"data"`
}
MetricBatch represents a single request payload as sent by the client application. It can contain multiple measurement cycles, each in turn consisting of many individual metrics.
func (*MetricBatch) MarshalJSON ¶
func (m *MetricBatch) MarshalJSON() ([]byte, error)
MarshalJSON marshals a struct MetricBatch into the reduced wire format expected by downstream consumers
func (*MetricBatch) Split ¶
func (m *MetricBatch) Split() []MetricSplit
Split breaks up a MetricBatch into a slice of individual MetricSplit message
func (*MetricBatch) UnmarshalJSON ¶
func (m *MetricBatch) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the logic required to parse the JSON wireformat into a struct.
type MetricData ¶
type MetricData struct {
Time time.Time `json:"time"`
FloatMetrics FloatMetrics `json:"floatMetrics"`
StringMetrics StringMetrics `json:"stringMetrics"`
IntMetrics IntMetrics `json:"intMetrics"`
}
MetricData contains the metric data from a single measurement time
func (*MetricData) MarshalJSON ¶
func (m *MetricData) MarshalJSON() ([]byte, error)
MarshalJSON assembles a JSON string for MetricData
type MetricElastic ¶
type MetricElastic struct {
HostID int `json:"hostID"`
Time time.Time `json:"timestamp"`
Metrics map[string]map[string]string `json:"metrics"`
Collect map[string]map[string][]string `json:"collections"`
}
MetricElastic is an intermediate metric representation between MetricBatch and the singleton's MetricSplit that de-batches suitable for insertion into ElasticSearch
func ElasticFromBatch ¶
func ElasticFromBatch(batch *MetricBatch) []MetricElastic
ElasticFromBatch converts batch into a slice of MetricElastic
type MetricSocket ¶
type MetricSocket struct {
Errors chan error
Shutdown chan struct{}
// contains filtered or unexported fields
}
MetricSocket provides a socket on which clients can connect and receive a current metrics export in PluginMetricBatch format
func NewFetchingMetricSocket ¶
func NewFetchingMetricSocket(conf *erebos.Config, reg *metrics.Registry, death chan error, format Formatter, fetch Fetcher) *MetricSocket
NewFetchingMetricSocket returns a new MetricSocket that updates the metrics when called. To create the socket and start the listener, the Run() method must be called. Returns nil if the provided configuration contains an empty SocketPath
func NewMetricSocket ¶
func NewMetricSocket(conf *erebos.Config, reg *metrics.Registry, death chan error, format Formatter) *MetricSocket
NewMetricSocket returns a new MetricSocket. To create the socket and start the listener, the Run() method must be called. Returns nil if the provided configuration contains an empty SocketPath
func (*MetricSocket) Run ¶
func (s *MetricSocket) Run()
Run creates the socket, opens the listener and runs accept on incoming connections. If Run is called, the Errors channel must be read from or the MetricSocket will get stuck.
func (*MetricSocket) SetDebugFormatter ¶
func (s *MetricSocket) SetDebugFormatter(format Formatter)
SetDebugFormatter can be used to provide a debug formatter for the metrics registry.
type MetricSplit ¶
type MetricSplit struct {
AssetID int64
Path string
TS time.Time
Type string
Unit string
Val MetricValue
Tags []string
Labels map[string]string
}
MetricSplit represents a de-batched, self-contained metric from a MetricBatch, suitable for forwarding towards event processing
func (*MetricSplit) LookupID ¶
func (m *MetricSplit) LookupID() string
LookupID returns the LookupID hash for m
func (*MetricSplit) MarshalJSON ¶
func (m *MetricSplit) MarshalJSON() ([]byte, error)
MarshalJSON marshals a struct MetricSplit into the reduced wire format expected by downstream consumers
func (*MetricSplit) UnmarshalJSON ¶
func (m *MetricSplit) UnmarshalJSON(data []byte) error
UnmarshalJSON converts the reduced wire format into struct MetricSplit
type MetricValue ¶
MetricValue contains the value of MetricSplit with support for multiple value types
type PluginMetric ¶
type PluginMetric struct {
Type string
Metric string
Label string
Value MetricValue
}
PluginMetric represents an individual metric gathered by a plugin
func (*PluginMetric) MarshalJSON ¶
func (p *PluginMetric) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of PluginMetric
type PluginMetricBatch ¶
type PluginMetricBatch struct {
Metrics []PluginMetric `json:"metrics"`
}
PluginMetricBatch is the format used by plugins to send metrics to the main collector
type StringMetric ¶
type StringMetric struct {
Metric string `json:"metric"`
Subtype string `json:"subtype"`
Value string `json:"value"`
}
StringMetric represents a single metric value of type string
type StringMetrics ¶
type StringMetrics []StringMetric
StringMetrics is a StringMetric collection for sort.Interface
func (StringMetrics) Len ¶
func (slice StringMetrics) Len() int
Len returns the length of the collection
func (StringMetrics) Less ¶
func (slice StringMetrics) Less(i, j int) bool
Less sorts in ascending lexical order
func (StringMetrics) MarshalJSON ¶
func (slice StringMetrics) MarshalJSON() ([]byte, error)
MarshalJSON assembles a JSON substring for StringMetrics
func (StringMetrics) Swap ¶
func (slice StringMetrics) Swap(i, j int)
Swap switches the position of the slice elements i, j