relabel

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

DefaultRelabelConfig sets the default values of fields when decoding a RelabelConfig block.

Functions

func ComponentToPromRelabelConfigs

func ComponentToPromRelabelConfigs(rcs []*Config) []*relabel.Config

ComponentToPromRelabelConfigs bridges the Component-based configuration of relabeling steps to the Prometheus implementation.

func ProcessBuilder added in v1.7.0

func ProcessBuilder(lb LabelBuilder, cfgs ...*Config) (keep bool)

ProcessBuilder should be called with lb LabelBuilder containing the initial set of labels, which are then modified following the configured rules using builder's methods such as Set and Del.

Types

type Action

type Action string

Action is the relabelling action to be performed.

const (
	Replace   Action = "replace"
	Keep      Action = "keep"
	Drop      Action = "drop"
	HashMod   Action = "hashmod"
	LabelMap  Action = "labelmap"
	LabelDrop Action = "labeldrop"
	LabelKeep Action = "labelkeep"
	Lowercase Action = "lowercase"
	Uppercase Action = "uppercase"
	KeepEqual Action = "keepequal"
	DropEqual Action = "dropequal"
)

All possible Action values.

func (Action) MarshalText

func (a Action) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler for Action.

func (Action) String

func (a Action) String() string

String returns the string representation of the Action type.

func (*Action) UnmarshalText

func (a *Action) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler for Action.

type Config

type Config struct {
	SourceLabels []string `alloy:"source_labels,attr,optional"`
	Separator    string   `alloy:"separator,attr,optional"`
	Regex        Regexp   `alloy:"regex,attr,optional"`
	Modulus      uint64   `alloy:"modulus,attr,optional"`
	TargetLabel  string   `alloy:"target_label,attr,optional"`
	Replacement  string   `alloy:"replacement,attr,optional"`
	Action       Action   `alloy:"action,attr,optional"`
}

Config describes a relabelling step to be applied on a target.

func (*Config) SetToDefault

func (c *Config) SetToDefault()

SetToDefault implements syntax.Defaulter.

func (*Config) Validate

func (rc *Config) Validate() error

Validate implements syntax.Validator.

type LabelBuilder added in v1.7.0

type LabelBuilder interface {
	// Get returns given label value. If label is not present, an empty string is returned.
	Get(label string) string
	Range(f func(label string, value string))
	// Set will set given label to given value. Setting to empty value is equivalent to deleting this label.
	Set(label string, val string)
	Del(ns ...string)
}

LabelBuilder is an interface that can be used to change labels with relabel logic.

type Regexp

type Regexp struct {
	*regexp.Regexp
}

Regexp encapsulates the Regexp type from Grafana's fork of the Go stdlib regexp package.

func (Regexp) MarshalText

func (re Regexp) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler for Regexp.

func (Regexp) String

func (re Regexp) String() string

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

func (*Regexp) UnmarshalText

func (re *Regexp) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler for Regexp.

type Rules

type Rules []*Config

Rules returns the relabel configs in use for a relabeling component.

func (Rules) AlloyCapsule

func (r Rules) AlloyCapsule()

AlloyCapsule marks the alias defined above as a "capsule type" so that it cannot be invoked by Alloy code.

Jump to

Keyboard shortcuts

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