Documentation ¶
Index ¶
- Variables
- type APIMetricType
- type AddSampleTelemetry
- type CheckMetrics
- func (cm *CheckMetrics) AddSample(contextKey ckey.ContextKey, sample *MetricSample, timestamp float64, ...) error
- func (cm *CheckMetrics) Expire(contextKeys []ckey.ContextKey, timestamp float64)
- func (cm *CheckMetrics) Flush(timestamp float64) ([]*Serie, map[ckey.ContextKey]error)
- func (cm *CheckMetrics) RemoveExpired(timestamp float64)
- type CheckMetricsTelemetryAccumulator
- type ContextMetrics
- type Count
- type Counter
- type Event
- type EventAlertType
- type EventContext
- type EventPriority
- type Events
- func (events Events) CreateMarshalersBySourceType() []marshaler.StreamJSONMarshaler
- func (events Events) CreateSingleMarshaler() marshaler.StreamJSONMarshaler
- func (events Events) Marshal() ([]byte, error)
- func (events Events) MarshalJSON() ([]byte, error)
- func (events Events) MarshalSplitCompress(bufferContext *marshaler.BufferContext) ([]*[]byte, error)
- func (events Events) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)
- type Gauge
- type Histogram
- type HistogramBucket
- type Historate
- type IntakeEvents
- type Metric
- type MetricSample
- type MetricSampleContext
- type MetricSamplePool
- type MetricType
- type MonotonicCount
- type NoSerieError
- type Point
- type Rate
- type Serie
- type Series
- func (series Series) DescribeItem(i int) string
- func (series Series) Len() int
- func (series Series) MarshalJSON() ([]byte, error)
- func (series Series) MarshalSplitCompress(bufferContext *marshaler.BufferContext) ([]*[]byte, error)
- func (series Series) MarshalStrings() ([]string, [][]string)
- func (series Series) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)
- func (series Series) WriteFooter(stream *jsoniter.Stream) error
- func (series Series) WriteHeader(stream *jsoniter.Stream) error
- func (series Series) WriteItem(stream *jsoniter.Stream, i int) error
- type ServiceCheck
- type ServiceCheckStatus
- type ServiceChecks
- func (sc ServiceChecks) DescribeItem(i int) string
- func (sc ServiceChecks) Len() int
- func (sc ServiceChecks) MarshalJSON() ([]byte, error)
- func (sc ServiceChecks) MarshalSplitCompress(bufferContext *marshaler.BufferContext) ([]*[]byte, error)
- func (sc ServiceChecks) MarshalStrings() ([]string, [][]string)
- func (sc ServiceChecks) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)
- func (sc ServiceChecks) WriteFooter(stream *jsoniter.Stream) error
- func (sc ServiceChecks) WriteHeader(stream *jsoniter.Stream) error
- func (sc ServiceChecks) WriteItem(stream *jsoniter.Stream, i int) error
- type Set
- type SketchPoint
- type SketchSeries
- type SketchSeriesList
- func (sl SketchSeriesList) Marshal() ([]byte, error)
- func (sl SketchSeriesList) MarshalJSON() ([]byte, error)
- func (sl SketchSeriesList) MarshalSplitCompress(bufferContext *marshaler.BufferContext) ([]*[]byte, error)
- func (sl SketchSeriesList) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)
- type SourceLink
Constants ¶
This section is empty.
Variables ¶
var ( DistributionMetricTypes = map[MetricType]struct{}{ DistributionType: {}, } )
DistributionMetricTypes contains the MetricTypes that are used for percentiles
Functions ¶
This section is empty.
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 AddSampleTelemetry ¶
type AddSampleTelemetry struct { Total telemetry.SimpleCounter Stateful telemetry.SimpleCounter Stateless telemetry.SimpleCounter }
AddSampleTelemetry counts number of new metrics added.
func (*AddSampleTelemetry) Inc ¶
func (a *AddSampleTelemetry) Inc(isStateful bool)
Inc should be called once for each new metric added to the map.
isStateful should be the value returned by isStateful method for the new metric.
type CheckMetrics ¶
type CheckMetrics struct {
// contains filtered or unexported fields
}
CheckMetrics stores metrics for the check sampler.
This is similar to ContextMetrics, but provides additional facility to remove metrics.
Metrics can be requested to be removed by calling Expire(). Metrics that keep state between flushes (see Metric.isStateful) are kept for additional statefulTimeout seconds after expiration, as a precaution against checks that send metrics intermittently. Older stateful metrics need to be cleaned up by calling RemoveExpired().
func NewCheckMetrics ¶
func NewCheckMetrics(expireMetrics bool, statefulTimeout time.Duration) CheckMetrics
NewCheckMetrics returns new CheckMetrics instance.
func (*CheckMetrics) AddSample ¶
func (cm *CheckMetrics) AddSample(contextKey ckey.ContextKey, sample *MetricSample, timestamp float64, interval int64) error
AddSample adds a new sample to the metric with contextKey, initializing a new metric as necessary.
If contextKey is scheduled for removal (see Expire), it will be unscheduled.
See also ContextMetrics.AddSample().
func (*CheckMetrics) Expire ¶
func (cm *CheckMetrics) Expire(contextKeys []ckey.ContextKey, timestamp float64)
Expire enables metric data for given context keys to be removed.
Metrics that do not keep state between flushes, will be removed immediately.
Metrics that do keep state, will be kept around for additional `cm.statefulTimeout` time after timestamp, before ultimately removed (See RemoveExpired). Call to AddSample will cancel delayed removal.
func (*CheckMetrics) Flush ¶
func (cm *CheckMetrics) Flush(timestamp float64) ([]*Serie, map[ckey.ContextKey]error)
Flush flushes every metrics in the CheckMetrics (see ContextMetrics.Flush)
func (*CheckMetrics) RemoveExpired ¶
func (cm *CheckMetrics) RemoveExpired(timestamp float64)
RemoveExpired removes stateful metrics that have expired before the given timestamp.
type CheckMetricsTelemetryAccumulator ¶
type CheckMetricsTelemetryAccumulator struct {
// contains filtered or unexported fields
}
CheckMetricsTelemetryAccumulator aggregates telemetry collected from multiple CheckMetrics instances.
func (*CheckMetricsTelemetryAccumulator) Flush ¶
func (c *CheckMetricsTelemetryAccumulator) Flush()
Flush updates telemetry counters based on aggregated statistics.
func (*CheckMetricsTelemetryAccumulator) VisitCheckMetrics ¶
func (c *CheckMetricsTelemetryAccumulator) VisitCheckMetrics(cm *CheckMetrics)
VisitCheckMetrics adds metrics from CheckMetrics instance to the accumulator.
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, t *AddSampleTelemetry) error
AddSample add a sample to the current ContextMetrics and initialize a new metrics if needed.
func (ContextMetrics) Flush ¶
func (m ContextMetrics) Flush(timestamp float64) ([]*Serie, map[ckey.ContextKey]error)
Flush flushes every metrics in the ContextMetrics. Returns the slice of Series and a map of errors by context key.
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 ¶
NewCounter return a new initialized Counter
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"` OriginID string `json:"-"` K8sOriginID string `json:"-"` Cardinality string `json:"-"` EventContext *EventContext `json:"context,omitempty"` }
Event holds an event (w/ serialization to DD agent 5 intake format)
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 EventContext ¶
type EventContext struct { SourceIdentifier string `json:"source_identifier,omitempty" msg:"source_identifier,omitempty"` ElementIdentifiers []string `json:"element_identifiers" msg:"element_identifiers"` Source string `json:"source" msg:"source"` Category string `json:"category" msg:"category"` Data map[string]interface{} `json:"data,omitempty" msg:"data,omitempty"` SourceLinks []SourceLink `json:"source_links" msg:"source_links"` } // [sts]
EventContext enriches the event with some more context and allows correlation to topology in StackState
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) CreateMarshalersBySourceType ¶
func (events Events) CreateMarshalersBySourceType() []marshaler.StreamJSONMarshaler
CreateMarshalersBySourceType creates a collection of marshaler.StreamJSONMarshaler. Each StreamJSONMarshaler is composed of all events for a specific source type name.
func (Events) CreateSingleMarshaler ¶
func (events Events) CreateSingleMarshaler() marshaler.StreamJSONMarshaler
CreateSingleMarshaler creates marshaler.StreamJSONMarshaler where each item is composed of all events for a specific source type name.
func (Events) MarshalJSON ¶
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) MarshalSplitCompress ¶
func (events Events) MarshalSplitCompress(bufferContext *marshaler.BufferContext) ([]*[]byte, error)
MarshalSplitCompress not implemented
func (Events) SplitPayload ¶
func (events Events) SplitPayload(times int) ([]marshaler.AbstractMarshaler, 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 ¶
NewHistogram returns a newly initialized histogram
type HistogramBucket ¶
type HistogramBucket struct { Name string Value int64 LowerBound float64 UpperBound float64 Monotonic bool Tags []string Host string Timestamp float64 FlushFirstValue bool }
HistogramBucket represents a prometheus/openmetrics histogram bucket
func (*HistogramBucket) GetHost ¶
func (m *HistogramBucket) GetHost() string
GetHost returns the bucket host
func (*HistogramBucket) GetName ¶
func (m *HistogramBucket) GetName() string
GetName returns the bucket name
func (*HistogramBucket) GetTags ¶
func (m *HistogramBucket) GetTags(tb *tagset.HashingTagsAccumulator)
GetTags returns the bucket tags.
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 ¶
NewHistorate returns a newly-initialized historate
type IntakeEvents ¶
type IntakeEvents struct {
Events []Event
}
IntakeEvents are used in the transactional batcher to keep state of events in a payload [sts]
func (IntakeEvents) IntakeFormat ¶
func (ie IntakeEvents) IntakeFormat() map[string][]Event
IntakeFormat returns a map of events grouped by source type name
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 FlushFirstValue bool OriginID string K8sOriginID string Cardinality string }
MetricSample represents a raw metric sample
func (*MetricSample) Copy ¶
func (m *MetricSample) Copy() *MetricSample
Copy returns a deep copy of the m MetricSample
func (*MetricSample) GetHost ¶
func (m *MetricSample) GetHost() string
GetHost returns the metric sample host
func (*MetricSample) GetName ¶
func (m *MetricSample) GetName() string
GetName returns the metric sample name
func (*MetricSample) GetTags ¶
func (m *MetricSample) GetTags(tb *tagset.HashingTagsAccumulator)
GetTags returns the metric sample tags
type MetricSampleContext ¶
type MetricSampleContext interface { GetName() string GetHost() string GetTags(*tagset.HashingTagsAccumulator) }
MetricSampleContext allows to access a sample context data
type MetricSamplePool ¶
type MetricSamplePool struct {
// contains filtered or unexported fields
}
MetricSamplePool is a pool of metrics sample
func NewMetricSamplePool ¶
func NewMetricSamplePool(batchSize int) *MetricSamplePool
NewMetricSamplePool creates a new MetricSamplePool
func (*MetricSamplePool) GetBatch ¶
func (m *MetricSamplePool) GetBatch() []MetricSample
GetBatch gets a batch of metric samples from the pool
func (*MetricSamplePool) PutBatch ¶
func (m *MetricSamplePool) PutBatch(batch []MetricSample)
PutBatch puts a batch back into the pool
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 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 Point ¶
Point represents a metric value at a specific time
func (*Point) MarshalJSON ¶
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 Note: it is not used with jsoniter, encodePoints takes over
func (*Point) UnmarshalJSON ¶
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)
type Series ¶
type Series []*Serie
Series represents a list of Serie ready to be serialize
func (Series) DescribeItem ¶
DescribeItem returns a text description for logs
func (Series) MarshalJSON ¶
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) MarshalSplitCompress ¶
func (series Series) MarshalSplitCompress(bufferContext *marshaler.BufferContext) ([]*[]byte, error)
MarshalSplitCompress uses the stream compressor to marshal and compress series payloads. If a compressed payload is larger than the max, a new payload will be generated. This method returns a slice of compressed protobuf marshaled MetricPayload objects.
func (Series) MarshalStrings ¶
MarshalStrings converts the timeseries to a sorted slice of string slices
func (Series) SplitPayload ¶
func (series Series) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)
SplitPayload breaks the payload into, at least, "times" number of pieces
func (Series) WriteFooter ¶
WriteFooter prints the payload footer for this type
func (Series) WriteHeader ¶
WriteHeader writes the payload header for this type
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"` OriginID string `json:"-"` K8sOriginID string `json:"-"` Cardinality string `json:"-"` }
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) DescribeItem ¶
func (sc ServiceChecks) DescribeItem(i int) string
DescribeItem returns a text description for logs
func (ServiceChecks) Len ¶
func (sc ServiceChecks) Len() int
Len returns the number of items to marshal
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) MarshalSplitCompress ¶
func (sc ServiceChecks) MarshalSplitCompress(bufferContext *marshaler.BufferContext) ([]*[]byte, error)
MarshalSplitCompress not implemented
func (ServiceChecks) MarshalStrings ¶
func (sc ServiceChecks) MarshalStrings() ([]string, [][]string)
MarshalStrings converts the service checks to a sorted slice of string slices
func (ServiceChecks) SplitPayload ¶
func (sc ServiceChecks) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)
SplitPayload breaks the payload into times number of pieces
func (ServiceChecks) WriteFooter ¶
func (sc ServiceChecks) WriteFooter(stream *jsoniter.Stream) error
WriteFooter prints the payload footer for this type
func (ServiceChecks) WriteHeader ¶
func (sc ServiceChecks) WriteHeader(stream *jsoniter.Stream) error
WriteHeader writes the payload header for this type
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
type SketchPoint ¶
A SketchPoint represents a quantile sketch at a specific time
type SketchSeries ¶
type SketchSeries struct { Name string `json:"metric"` Tags []string `json:"tags"` Host string `json:"host"` Interval int64 `json:"interval"` Points []SketchPoint `json:"points"` ContextKey ckey.ContextKey `json:"-"` }
A SketchSeries is a timeseries of quantile sketches.
type SketchSeriesList ¶
type SketchSeriesList []SketchSeries
A SketchSeriesList implements marshaler.Marshaler
func (SketchSeriesList) Marshal ¶
func (sl SketchSeriesList) Marshal() ([]byte, error)
Marshal encodes this series list.
func (SketchSeriesList) MarshalJSON ¶
func (sl SketchSeriesList) MarshalJSON() ([]byte, error)
MarshalJSON serializes sketch series to JSON. Quite slow, but hopefully this method is called only in the `agent check` command
func (SketchSeriesList) MarshalSplitCompress ¶
func (sl SketchSeriesList) MarshalSplitCompress(bufferContext *marshaler.BufferContext) ([]*[]byte, error)
MarshalSplitCompress uses the stream compressor to marshal and compress sketch series payloads. If a compressed payload is larger than the max, a new payload will be generated. This method returns a slice of compressed protobuf marshaled gogen.SketchPayload objects. gogen.SketchPayload is not directly marshaled - instead it's contents are marshaled individually, packed with the appropriate protobuf metadata, and compressed in stream. The resulting payloads (when decompressed) are binary equal to the result of marshaling the whole object at once.
func (SketchSeriesList) SplitPayload ¶
func (sl SketchSeriesList) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)
SplitPayload breaks the payload into times number of pieces
type SourceLink ¶
type SourceLink struct { Title string `json:"title" msg:"title"` URL string `json:"url" msg:"url"` } // [sts]
SourceLink points to links that may contain more information about this event