metrics

package
v0.0.0-...-1d9613f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

README

Metrics

The agent offers different type of metric. Each metrics offers 2 methods addSample and flush.

  • addSample: add a new sample to the metrics.
  • flush: aggregate all samples received since the last flush and return a Series to be forwarded to the DataDog backend.
gauge

Gauge tracks the value of a metric. The last value received is the one returned by the flush method.

counter

Counter tracks how many times something happened per second. Counters are only used by DogStatsD and are very similar to Count: the main diffence is that they are sent as Rate.

count

Count is used to count the number of events that occur between 2 flushes. Each sample's value is added to the value that's flushed.

histogram

Histogram tracks the distribution of samples added over one flush period.

historate

Historate tracks the distribution of samples added over one flush period for "rate" like metrics. Warning this doesn't use the harmonic mean, beware of what it means when using it.

monotonic_count

MonotonicCount tracks a raw counter, based on increasing counter values. Samples that have a lower value than the previous sample are ignored (since it usually means that the underlying raw counter has been reset).

Example:

Submitting samples 2, 3, 6, 7 returns 5 (i.e. 7-2) on flush, then submitting samples 10, 11 on the same MonotonicCount returns 4 (i.e. 11-7) on the second flush.

percentile

Percentile tracks the distribution of samples added over one flush period. Designed to be globally accurate for percentiles.

Percentile is not usable yet; it is still undergoing development and testing.

rate

Rate tracks the rate of a metric over 2 successive flushes (ie: no metrics will be returned on the first flush).

set

Set tracks the number of unique elements in a set. This is only used by DogStatsD; you cannot create sets from an Agent check.

service_check

Service checks track the status of any service: OK, WARNING, CRITICAL, or UNKNOWN. The Agent does not aggregate service checks, it sends every check straight to Datadog's backend.

event

Events represent discrete moments in time, e.g. thrown exceptions, code deploys, etc. The Agent does not aggregate events, it sends every event straight to your Datadog event stream.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DistributionMetricTypes = map[MetricType]struct{}{
	DistributionType: {},
}

DistributionMetricTypes contains the MetricTypes that are used for percentiles

Functions

func AssertPointsEqual

func AssertPointsEqual(t *testing.T, expected, actual []Point)

AssertPointsEqual evaluate if two list of point are equal (order doesn't matters).

func AssertSerieEqual

func AssertSerieEqual(t *testing.T, expected, actual *Serie)

AssertSerieEqual evaluate if two are equal.

func AssertSketchSeriesEqual

func AssertSketchSeriesEqual(t *testing.T, expected, actual *percentile.SketchSeries)

AssertSketchSeriesEqual checks whether two SketchSeries are equal

func AssertSketchesEqual

func AssertSketchesEqual(t *testing.T, expected, actual []percentile.Sketch)

AssertSketchesEqual checks whether two Sketch slices are equal

func AssertTagsEqual

func AssertTagsEqual(t *testing.T, expected, actual []string)

AssertTagsEqual evaluate if two list of tags are equal (the order doesn't matters).

Types

type APIMetricType

type APIMetricType int

APIMetricType represents an API metric type

const (
	APIGaugeType APIMetricType = iota
	APIRateType
	APICountType
)

Enumeration of the existing API metric types

func (APIMetricType) MarshalText

func (a APIMetricType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshal interface to marshal an APIMetricType to a serialized byte slice

func (APIMetricType) String

func (a APIMetricType) String() string

String returns a string representation of APIMetricType

func (APIMetricType) UnmarshalText

func (a APIMetricType) UnmarshalText(buf []byte) error

UnmarshalText is a custom unmarshaller for APIMetricType (used for testing)

type ContextKey

type ContextKey [16]byte

ContextKey is a non-cryptographic hash unique to a context

type ContextMetrics

type ContextMetrics map[ckey.ContextKey]Metric

ContextMetrics stores all the metrics by context key

func MakeContextMetrics

func MakeContextMetrics() ContextMetrics

MakeContextMetrics returns a new ContextMetrics

func (ContextMetrics) AddSample

func (m ContextMetrics) AddSample(contextKey ckey.ContextKey, sample *MetricSample, timestamp float64, interval int64)

AddSample add a sample to the current ContextMetrics and initialize a new metrics if needed. TODO: Pass a reference to *MetricSample instead

func (ContextMetrics) Flush

func (m ContextMetrics) Flush(timestamp float64) []*Serie

Flush flushes every metrics in the ContextMetrics

type ContextSketch

type ContextSketch map[ckey.ContextKey]*Distribution

ContextSketch stores the distributions by context key

func MakeContextSketch

func MakeContextSketch() ContextSketch

MakeContextSketch returns a new ContextSketch

func (ContextSketch) AddSample

func (c ContextSketch) AddSample(contextKey ckey.ContextKey, sample *MetricSample, timestamp float64, interval int64)

AddSample adds a sample to the ContextSketch

func (ContextSketch) Flush

func (c ContextSketch) Flush(timestamp float64) []*percentile.SketchSeries

Flush flushes sketches in the ContextSketch

type Count

type Count struct {
	// contains filtered or unexported fields
}

Count is used to count the number of events that occur between 2 flushes. Each sample's value is added to the value that's flushed

type Counter

type Counter struct {
	// contains filtered or unexported fields
}

Counter tracks how many times something happened per second. Counters are only used by DogStatsD and are very similar to Count: the main diffence is that they are sent as Rate.

func NewCounter

func NewCounter(interval int64) *Counter

NewCounter return a new initialized Counter

type Distribution

type Distribution struct {
	// contains filtered or unexported fields
}

Distribution tracks the distribution of samples added over one flush period. Designed to be globally accurate for percentiles.

func NewDistribution

func NewDistribution() *Distribution

NewDistribution creates a new Distribution containing GKArray

type Event

type Event struct {
	Title          string         `json:"msg_title"`
	Text           string         `json:"msg_text"`
	Ts             int64          `json:"timestamp"`
	Priority       EventPriority  `json:"priority,omitempty"`
	Host           string         `json:"host"`
	Tags           []string       `json:"tags,omitempty"`
	AlertType      EventAlertType `json:"alert_type,omitempty"`
	AggregationKey string         `json:"aggregation_key,omitempty"`
	SourceTypeName string         `json:"source_type_name,omitempty"`
	EventType      string         `json:"event_type,omitempty"`
}

Event holds an event (w/ serialization to DD agent 5 intake format)

func (*Event) String

func (e *Event) String() string

Return a JSON string or "" in case of error during the Marshaling

type EventAlertType

type EventAlertType string

EventAlertType represents the alert type of an event

const (
	EventAlertTypeError   EventAlertType = "error"
	EventAlertTypeWarning EventAlertType = "warning"
	EventAlertTypeInfo    EventAlertType = "info"
	EventAlertTypeSuccess EventAlertType = "success"
)

Enumeration of the existing event alert types, and their values

func GetAlertTypeFromString

func GetAlertTypeFromString(val string) (EventAlertType, error)

GetAlertTypeFromString returns the EventAlertType from its string representation

type EventPriority

type EventPriority string

EventPriority represents the priority of an event

const (
	EventPriorityNormal EventPriority = "normal"
	EventPriorityLow    EventPriority = "low"
)

Enumeration of the existing event priorities, and their values

func GetEventPriorityFromString

func GetEventPriorityFromString(val string) (EventPriority, error)

GetEventPriorityFromString returns the EventPriority from its string representation

type Events

type Events []*Event

Events represents a list of events ready to be serialize

func (Events) Marshal

func (events Events) Marshal() ([]byte, error)

Marshal serialize events using agent-payload definition

func (Events) MarshalJSON

func (events Events) MarshalJSON() ([]byte, error)

MarshalJSON serializes events to JSON so it can be sent to the Agent 5 intake (we don't use the v1 event endpoint because it only supports 1 event per payload) FIXME(olivier): to be removed when v2 endpoints are available

func (Events) SplitPayload

func (events Events) SplitPayload(times int) ([]marshaler.Marshaler, error)

SplitPayload breaks the payload into times number of pieces

type Gauge

type Gauge struct {
	// contains filtered or unexported fields
}

Gauge tracks the value of a metric

type Histogram

type Histogram struct {
	// contains filtered or unexported fields
}

Histogram tracks the distribution of samples added over one flush period

func NewHistogram

func NewHistogram(interval int64) *Histogram

NewHistogram returns a newly initialized histogram

type Historate

type Historate struct {
	// contains filtered or unexported fields
}

Historate tracks the distribution of samples added over one flush period for "rate" like metrics. Warning this doesn't use the harmonic mean, beware of what it means when using it.

func NewHistorate

func NewHistorate(interval int64) *Historate

NewHistorate returns a newly-initialized historate

type Metric

type Metric interface {
	// contains filtered or unexported methods
}

Metric is the interface of all metric types

type MetricSample

type MetricSample struct {
	Name       string
	Value      float64
	RawValue   string
	Mtype      MetricType
	Tags       []string
	Host       string
	SampleRate float64
	Timestamp  float64
}

MetricSample represents a raw metric sample

type MetricType

type MetricType int

MetricType is the representation of an aggregator metric type

const (
	GaugeType MetricType = iota
	RateType
	CountType
	MonotonicCountType
	CounterType
	HistogramType
	HistorateType
	SetType
	// NOTE: DistributionType is in development and is NOT supported
	DistributionType
)

metric type constants enumeration

func (MetricType) String

func (m MetricType) String() string

String returns a string representation of MetricType

type MonotonicCount

type MonotonicCount struct {
	// contains filtered or unexported fields
}

MonotonicCount tracks a raw counter, based on increasing counter values. Samples that have a lower value than the previous sample are ignored (since it usually means that the underlying raw counter has been reset). Example:

submitting samples 2, 3, 6, 7 returns 5 (i.e. 7-2) on flush ;
then submitting samples 10, 11 on the same MonotonicCount returns 4 (i.e. 11-7) on flush

type NoSerieError

type NoSerieError struct{}

NoSerieError is the error returned by a metric when not enough samples have been submitted to generate a serie

func (NoSerieError) Error

func (e NoSerieError) Error() string

type OrderedSketches

type OrderedSketches struct {
	// contains filtered or unexported fields
}

OrderedSketches are used to sort []Sketch

func (OrderedSketches) Len

func (os OrderedSketches) Len() int

func (OrderedSketches) Less

func (os OrderedSketches) Less(i, j int) bool

func (OrderedSketches) Swap

func (os OrderedSketches) Swap(i, j int)

type Point

type Point struct {
	Ts    float64
	Value float64
}

Point represents a metric value at a specific time

func (*Point) MarshalJSON

func (p *Point) MarshalJSON() ([]byte, error)

MarshalJSON return a Point as an array of value (to be compatible with v1 API) FIXME(maxime): to be removed when v2 endpoints are available

func (*Point) UnmarshalJSON

func (p *Point) UnmarshalJSON(buf []byte) error

UnmarshalJSON is a custom unmarshaller for Point (used for testing)

type Rate

type Rate struct {
	// contains filtered or unexported fields
}

Rate tracks the rate of a metric over 2 successive flushes

type Serie

type Serie struct {
	Name           string          `json:"metric"`
	Points         []Point         `json:"points"`
	Tags           []string        `json:"tags"`
	Host           string          `json:"host"`
	Device         string          `json:"device,omitempty"` // FIXME(olivier): remove as soon as the v1 API can handle `device` as a regular tag
	MType          APIMetricType   `json:"type"`
	Interval       int64           `json:"interval"`
	SourceTypeName string          `json:"source_type_name,omitempty"`
	ContextKey     ckey.ContextKey `json:"-"`
	NameSuffix     string          `json:"-"`
}

Serie holds a timeseries (w/ json serialization to DD API format)

func (Serie) String

func (e Serie) String() string

type Series

type Series []*Serie

Series represents a list of Serie ready to be serialize

func (Series) Marshal

func (series Series) Marshal() ([]byte, error)

Marshal serialize timeseries using agent-payload definition

func (Series) MarshalJSON

func (series Series) MarshalJSON() ([]byte, error)

MarshalJSON serializes timeseries to JSON so it can be sent to V1 endpoints FIXME(maxime): to be removed when v2 endpoints are available

func (Series) SplitPayload

func (series Series) SplitPayload(times int) ([]marshaler.Marshaler, error)

SplitPayload breaks the payload into, at least, "times" number of pieces

type ServiceCheck

type ServiceCheck struct {
	CheckName string             `json:"check"`
	Host      string             `json:"host_name"`
	Ts        int64              `json:"timestamp"`
	Status    ServiceCheckStatus `json:"status"`
	Message   string             `json:"message"`
	Tags      []string           `json:"tags"`
}

ServiceCheck holds a service check (w/ serialization to DD api format)

func (ServiceCheck) String

func (sc ServiceCheck) String() string

type ServiceCheckStatus

type ServiceCheckStatus int

ServiceCheckStatus represents the status associated with a service check

const (
	ServiceCheckOK       ServiceCheckStatus = iota
	ServiceCheckWarning  ServiceCheckStatus = 1
	ServiceCheckCritical ServiceCheckStatus = 2
	ServiceCheckUnknown  ServiceCheckStatus = 3
)

Enumeration of the existing service check statuses, and their values

func GetServiceCheckStatus

func GetServiceCheckStatus(val int) (ServiceCheckStatus, error)

GetServiceCheckStatus returns the ServiceCheckStatus from and integer value

func (ServiceCheckStatus) String

func (s ServiceCheckStatus) String() string

String returns a string representation of ServiceCheckStatus

type ServiceChecks

type ServiceChecks []*ServiceCheck

ServiceChecks represents a list of service checks ready to be serialize

func (ServiceChecks) Marshal

func (sc ServiceChecks) Marshal() ([]byte, error)

Marshal serialize service checks using agent-payload definition

func (ServiceChecks) MarshalJSON

func (sc ServiceChecks) MarshalJSON() ([]byte, error)

MarshalJSON serializes service checks to JSON so it can be sent to V1 endpoints FIXME(olivier): to be removed when v2 endpoints are available

func (ServiceChecks) SplitPayload

func (sc ServiceChecks) SplitPayload(times int) ([]marshaler.Marshaler, error)

SplitPayload breaks the payload into times number of pieces

type Set

type Set struct {
	// contains filtered or unexported fields
}

Set tracks the number of unique elements in a set. They are only use by DogStatsD

func NewSet

func NewSet() *Set

NewSet return a new initialized Set

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL