relabel

package
v0.41.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 6 Imported by: 183

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRelabelConfig = Config{
		Action:      Replace,
		Separator:   ";",
		Regex:       MustNewRegexp("(.*)"),
		Replacement: "$1",
	}
)

Functions

func Process

func Process(lbls labels.Labels, cfgs ...*Config) labels.Labels

Process returns a relabeled copy of the given label set. The relabel configurations are applied in order of input. If a label set is dropped, nil is returned. May return the input labelSet modified.

Types

type Action

type Action string

Action is the action to be performed on relabeling.

const (
	// Replace performs a regex replacement.
	Replace Action = "replace"
	// Keep drops targets for which the input does not match the regex.
	Keep Action = "keep"
	// Drop drops targets for which the input does match the regex.
	Drop Action = "drop"
	// KeepEqual drops targets for which the input does not match the target.
	KeepEqual Action = "keepequal"
	// Drop drops targets for which the input does match the target.
	DropEqual Action = "dropequal"
	// HashMod sets a label to the modulus of a hash of labels.
	HashMod Action = "hashmod"
	// LabelMap copies labels to other labelnames based on a regex.
	LabelMap Action = "labelmap"
	// LabelDrop drops any label matching the regex.
	LabelDrop Action = "labeldrop"
	// LabelKeep drops any label not matching the regex.
	LabelKeep Action = "labelkeep"
	// Lowercase maps input letters to their lower case.
	Lowercase Action = "lowercase"
	// Uppercase maps input letters to their upper case.
	Uppercase Action = "uppercase"
)

func (*Action) UnmarshalYAML

func (a *Action) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Config

type Config struct {
	// A list of labels from which values are taken and concatenated
	// with the configured separator in order.
	SourceLabels model.LabelNames `yaml:"source_labels,flow,omitempty"`
	// Separator is the string between concatenated values from the source labels.
	Separator string `yaml:"separator,omitempty"`
	// Regex against which the concatenation is matched.
	Regex Regexp `yaml:"regex,omitempty"`
	// Modulus to take of the hash of concatenated values from the source labels.
	Modulus uint64 `yaml:"modulus,omitempty"`
	// TargetLabel is the label to which the resulting string is written in a replacement.
	// Regexp interpolation is allowed for the replace action.
	TargetLabel string `yaml:"target_label,omitempty"`
	// Replacement is the regex replacement pattern to be used.
	Replacement string `yaml:"replacement,omitempty"`
	// Action is the action to be performed for the relabeling.
	Action Action `yaml:"action,omitempty"`
}

Config is the configuration for relabeling of target label sets.

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Regexp

type Regexp struct {
	*regexp.Regexp
}

Regexp encapsulates a regexp.Regexp and makes it YAML marshalable.

func MustNewRegexp

func MustNewRegexp(s string) Regexp

MustNewRegexp works like NewRegexp, but panics if the regular expression does not compile.

func NewRegexp

func NewRegexp(s string) (Regexp, error)

NewRegexp creates a new anchored Regexp and returns an error if the passed-in regular expression does not compile.

func (Regexp) MarshalYAML

func (re Regexp) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (Regexp) String added in v0.37.0

func (re Regexp) String() string

String returns the original string used to compile the regular expression.

func (*Regexp) UnmarshalYAML

func (re *Regexp) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

Jump to

Keyboard shortcuts

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