labeler

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoneLabelMatcher = []*labels.Matcher{{
	Name:  "__",
	Value: "none",
	Type:  labels.MatchEqual,
}}

NoneLabelMatcher is a prometheus label matcher that fails for all metrics

Functions

func MustParseLabels

func MustParseLabels(query string) (labelMatchers []*labels.Matcher)

MustParseLabels is a ParseLabels version that panics on error

func ParseLabels

func ParseLabels(query string) (labelMatchers []*labels.Matcher, err error)

ParseLabels uses Prometheus promql library to parse a string of Prometheus labels into LaberMatchers

Types

type Labeler

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

Labeler provides the relabeling functions and thracks the metrics

func NewLabeler

func NewLabeler() (l *Labeler)

NewLabeler creates a new instance of *Labeler

func (*Labeler) AddLabels

func (l *Labeler) AddLabels(expr promql.Expr, acl core.ACL) (labeled promql.Expr)

AddLabels reversively walks through a promql.Expr and adds the LabelMatches provided by core.ACL to every metric

This function tries to follow the same flow as Promtheus eval https://github.com/prometheus/prometheus/blob/master/promql/engine.go#L923

func (*Labeler) DedupeMatchers

func (l *Labeler) DedupeMatchers(matchers []*labels.Matcher) []*labels.Matcher

DedupeMatchers tries to find Matchers that do the same stuff and remove the more cpu intersive version.

func (*Labeler) PromACLMiddlewareFor

func (l *Labeler) PromACLMiddlewareFor(u *url.URL) func(http.Handler) http.Handler

PromACLMiddlewareFor generates a Middleware for a URL that modifies Prometheus Queries by injecting additional Labels. These labels are provided by a core.ACL interface via the requests Context

Jump to

Keyboard shortcuts

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