Documentation
¶
Index ¶
- Variables
- func DropEmptyFamilies(family *clientmodel.MetricFamily) (bool, error)
- func DropTimestamp(family *clientmodel.MetricFamily) (bool, error)
- func Filter(families []*clientmodel.MetricFamily, filter Transformer) error
- func MergeSortedWithTimestamps(families []*clientmodel.MetricFamily) []*clientmodel.MetricFamily
- func MetricsCount(families []*clientmodel.MetricFamily) int
- func NewElide(labels ...string) *elide
- func None(*clientmodel.MetricFamily) (bool, error)
- func Pack(families []*clientmodel.MetricFamily) []*clientmodel.MetricFamily
- func PackLabels(labels []*clientmodel.LabelPair) []*clientmodel.LabelPair
- func PackMetrics(family *clientmodel.MetricFamily) (bool, error)
- func SortMetrics(family *clientmodel.MetricFamily) (bool, error)
- type AnonymizeMetrics
- type Count
- type DropUnsorted
- type LabelRetriever
- type MetricsByTimestamp
- type MultiTransformer
- type PackedFamilyWithTimestampsByName
- type RenameMetrics
- type Transformer
- func NewDropExpiredSamples(min time.Time) Transformer
- func NewDropInvalidFederateSamples(min time.Time) Transformer
- func NewErrorInvalidFederateSamples(min time.Time) Transformer
- func NewErrorOnUnsorted(requireTimestamp bool) Transformer
- func NewLabel(labels map[string]string, retriever LabelRetriever) Transformer
- func NewRequiredLabels(labels map[string]string) Transformer
- func NewWhitelist(rules []string) (Transformer, error)
- type TransformerFunc
Constants ¶
This section is empty.
Variables ¶
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") )
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 None(*clientmodel.MetricFamily) (bool, error)
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) 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 MetricsByTimestamp ¶
type MetricsByTimestamp []*clientmodel.Metric
func (MetricsByTimestamp) Len ¶
func (m MetricsByTimestamp) Len() int
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 ¶
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. We essentially already do this in Telemeter v1 by dropping all timestamps on Telemeter Servers and then when federating Telemeter Prometheus sets its own current timestamp. For v2 we want to be consistent when using remote-write and thus we overwrite the timestamps on Telemeter Server already to forward the same timestamps to both systems.
func (TransformerFunc) Transform ¶
func (f TransformerFunc) Transform(family *clientmodel.MetricFamily) (ok bool, err error)