metricfamily

package
v0.0.0-...-a761d13 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsorted        = fmt.Errorf("metrics in provided family are not in increasing timestamp order")
	ErrNoTimestamp     = fmt.Errorf("metrics in provided family do not have a timestamp")
	ErrTimestampTooOld = fmt.Errorf("metrics in provided family have a timestamp that is too old, check clock skew")
)
View Source
var (
	ErrRequiredLabelMissing = fmt.Errorf("a required label is missing from the metric")
)

Functions

func DropEmptyFamilies

func DropEmptyFamilies(family *clientmodel.MetricFamily) (bool, error)

func DropTimestamp

func DropTimestamp(family *clientmodel.MetricFamily) (bool, error)

DropTimestamp is a transformer that removes timestamps from metrics.

func Filter

func Filter(families []*clientmodel.MetricFamily, filter Transformer) error

func MergeSortedWithTimestamps

func MergeSortedWithTimestamps(families []*clientmodel.MetricFamily) []*clientmodel.MetricFamily

MergeSortedWithTimestamps collapses metrics families with the same name into a single family, preserving the order of the metrics. Families must be dense (no nils for families or metrics), all metrics must be sorted, and all metrics must have timestamps.

func MetricsCount

func MetricsCount(families []*clientmodel.MetricFamily) int

MetricsCount returns the number of unique metrics in the given families. It skips nil families but does not skip nil metrics.

func NewElide

func NewElide(labels ...string) *elide

NewElide creates a new elide transformer for the given metrics.

func None

func Pack

func Pack(families []*clientmodel.MetricFamily) []*clientmodel.MetricFamily

Pack returns only families with metrics in the returned array, preserving the order of the original slice. Nil entries are removed from the slice. The returned slice may be empty.

func PackLabels

func PackLabels(labels []*clientmodel.LabelPair) []*clientmodel.LabelPair

PackLabels fills holes in the label slice by shifting items towards the zero index. It will modify the slice in place.

func PackMetrics

func PackMetrics(family *clientmodel.MetricFamily) (bool, error)

func SortMetrics

func SortMetrics(family *clientmodel.MetricFamily) (bool, error)

Types

type AnonymizeMetrics

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

func NewMetricsAnonymizer

func NewMetricsAnonymizer(salt string, labels []string, metricsLabels map[string][]string) *AnonymizeMetrics

NewMetricsAnonymizer hashes label values on the incoming metrics using a cryptographic hash. Because the cardinality of most label values is low, only a portion of the hash is returned. To prevent rainbow tables from being used to recover the label value, each client should use a salt value. Because label values are expected to remain stable over many sessions, the salt must also be stable over the same time period. The salt should not be shared with the remote agent. This type is not thread-safe.

func (*AnonymizeMetrics) Transform

func (a *AnonymizeMetrics) Transform(family *clientmodel.MetricFamily) (bool, error)

type Count

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

func (*Count) Metrics

func (t *Count) Metrics() int

func (*Count) Transform

func (t *Count) Transform(family *clientmodel.MetricFamily) (bool, error)

type DropUnsorted

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

func (*DropUnsorted) Transform

func (o *DropUnsorted) Transform(family *clientmodel.MetricFamily) (bool, error)

type LabelRetriever

type LabelRetriever interface {
	Labels() (map[string]string, error)
}

type MetricsByTimestamp

type MetricsByTimestamp []*clientmodel.Metric

func (MetricsByTimestamp) Len

func (m MetricsByTimestamp) Len() int

func (MetricsByTimestamp) Less

func (m MetricsByTimestamp) Less(i int, j int) bool

func (MetricsByTimestamp) Swap

func (m MetricsByTimestamp) Swap(i int, j int)

type MultiTransformer

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

func (MultiTransformer) Transform

func (a MultiTransformer) Transform(family *clientmodel.MetricFamily) (bool, error)

func (*MultiTransformer) With

func (a *MultiTransformer) With(t Transformer)

func (*MultiTransformer) WithFunc

func (a *MultiTransformer) WithFunc(f func() Transformer)

type PackedFamilyWithTimestampsByName

type PackedFamilyWithTimestampsByName []*clientmodel.MetricFamily

PackedFamilyWithTimestampsByName sorts a packed slice of metrics (no nils, all families have at least one metric, and all metrics have timestamps) in order of metric name and then oldest sample

func (PackedFamilyWithTimestampsByName) Len

func (families PackedFamilyWithTimestampsByName) Len() int

func (PackedFamilyWithTimestampsByName) Less

func (families PackedFamilyWithTimestampsByName) Less(i int, j int) bool

func (PackedFamilyWithTimestampsByName) Swap

func (families PackedFamilyWithTimestampsByName) Swap(i int, j int)

type RenameMetrics

type RenameMetrics struct {
	Names map[string]string
}

func (RenameMetrics) Transform

func (m RenameMetrics) Transform(family *clientmodel.MetricFamily) (bool, error)

type Transformer

type Transformer interface {
	Transform(*clientmodel.MetricFamily) (ok bool, err error)
}

func NewDropExpiredSamples

func NewDropExpiredSamples(min time.Time) Transformer

func NewDropInvalidFederateSamples

func NewDropInvalidFederateSamples(min time.Time) Transformer

func NewErrorInvalidFederateSamples

func NewErrorInvalidFederateSamples(min time.Time) Transformer

func NewErrorOnUnsorted

func NewErrorOnUnsorted(requireTimestamp bool) Transformer

func NewLabel

func NewLabel(labels map[string]string, retriever LabelRetriever) Transformer

func NewRequiredLabels

func NewRequiredLabels(labels map[string]string) Transformer

func NewWhitelist

func NewWhitelist(rules []string) (Transformer, error)

NewWhitelist returns a Transformer that checks if at least one rule in the whitelist is true. This Transformer will nil metrics within a metric family that do not match a rule. Each given rule is transformed into a matchset. Matchsets are OR-ed. Individual matchers within a matchset are AND-ed, as in PromQL.

type TransformerFunc

type TransformerFunc func(*clientmodel.MetricFamily) (ok bool, err error)

func OverwriteTimestamps

func OverwriteTimestamps(now func() time.Time) TransformerFunc

OverwriteTimestamps sets all timestamps to the current time.

func (TransformerFunc) Transform

func (f TransformerFunc) Transform(family *clientmodel.MetricFamily) (ok bool, err error)

Jump to

Keyboard shortcuts

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