Documentation ¶
Index ¶
- func CleanLabels(labels []prompbmarshal.Label)
- func FinalizeLabels(dst, src []prompbmarshal.Label) []prompbmarshal.Label
- func GetLabelByName(labels []prompbmarshal.Label, name string) *prompbmarshal.Label
- func GetLabelValueByName(labels []prompbmarshal.Label, name string) string
- func RemoveMetaLabels(dst, src []prompbmarshal.Label) []prompbmarshal.Label
- func SortLabels(labels []prompbmarshal.Label)
- type MultiLineRegex
- type ParsedConfigs
- type RelabelConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanLabels ¶ added in v1.46.0
func CleanLabels(labels []prompbmarshal.Label)
CleanLabels sets label.Name and label.Value to an empty string for all the labels.
This should help GC cleaning up label.Name and label.Value strings.
func FinalizeLabels ¶
func FinalizeLabels(dst, src []prompbmarshal.Label) []prompbmarshal.Label
FinalizeLabels removes labels with "__" in the beginning (except of "__name__").
func GetLabelByName ¶
func GetLabelByName(labels []prompbmarshal.Label, name string) *prompbmarshal.Label
GetLabelByName returns label with the given name from labels.
func GetLabelValueByName ¶ added in v1.34.8
func GetLabelValueByName(labels []prompbmarshal.Label, name string) string
GetLabelValueByName returns value for label with the given name from labels.
It returns empty string for non-existing label.
func RemoveMetaLabels ¶ added in v1.34.8
func RemoveMetaLabels(dst, src []prompbmarshal.Label) []prompbmarshal.Label
RemoveMetaLabels removes all the `__meta_` labels from src and puts the rest of labels to dst.
See https://www.robustperception.io/life-of-a-label fo details.
Types ¶
type MultiLineRegex ¶ added in v1.66.0
type MultiLineRegex struct {
// contains filtered or unexported fields
}
MultiLineRegex contains a regex, which can be split into multiple lines.
These lines are joined with "|" then. For example:
regex: - foo - bar
is equivalent to:
regex: "foo|bar"
func (*MultiLineRegex) MarshalYAML ¶ added in v1.66.0
func (mlr *MultiLineRegex) MarshalYAML() (interface{}, error)
MarshalYAML marshals mlr to YAML.
func (*MultiLineRegex) UnmarshalYAML ¶ added in v1.66.0
func (mlr *MultiLineRegex) UnmarshalYAML(f func(interface{}) error) error
UnmarshalYAML unmarshals mlr from YAML passed to f.
type ParsedConfigs ¶ added in v1.55.0
type ParsedConfigs struct {
// contains filtered or unexported fields
}
ParsedConfigs represents parsed relabel configs.
func LoadRelabelConfigs ¶
func LoadRelabelConfigs(path string, relabelDebug bool) (*ParsedConfigs, error)
LoadRelabelConfigs loads relabel configs from the given path.
func ParseRelabelConfigs ¶
func ParseRelabelConfigs(rcs []RelabelConfig, relabelDebug bool) (*ParsedConfigs, error)
ParseRelabelConfigs parses rcs to dst.
func ParseRelabelConfigsData ¶ added in v1.55.0
func ParseRelabelConfigsData(data []byte, relabelDebug bool) (*ParsedConfigs, error)
ParseRelabelConfigsData parses relabel configs from the given data.
func (*ParsedConfigs) Apply ¶ added in v1.55.0
func (pcs *ParsedConfigs) Apply(labels []prompbmarshal.Label, labelsOffset int, isFinalize bool) []prompbmarshal.Label
Apply applies pcs to labels starting from the labelsOffset.
If isFinalize is set, then FinalizeLabels is called on the labels[labelsOffset:].
The returned labels at labels[labelsOffset:] are sorted.
func (*ParsedConfigs) Len ¶ added in v1.55.0
func (pcs *ParsedConfigs) Len() int
Len returns the number of relabel configs in pcs.
func (*ParsedConfigs) String ¶ added in v1.55.0
func (pcs *ParsedConfigs) String() string
String returns human-readabale representation for pcs.
type RelabelConfig ¶
type RelabelConfig struct { SourceLabels []string `yaml:"source_labels,flow,omitempty"` Separator *string `yaml:"separator,omitempty"` TargetLabel string `yaml:"target_label,omitempty"` Regex *MultiLineRegex `yaml:"regex,omitempty"` Modulus uint64 `yaml:"modulus,omitempty"` Replacement *string `yaml:"replacement,omitempty"` Action string `yaml:"action,omitempty"` }
RelabelConfig represents relabel config.
See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config