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 GetScrapeURL(labels *promutils.Labels, extraParams map[string][]string) (string, string)
- func LabelsToString(labels []prompbmarshal.Label) string
- func RelabelDebugSteps(targetURL, targetID, format string, dss []DebugStep, ...) string
- func RelabelDebugStepsHTML(targetURL, targetID string, dss []DebugStep, metric, relabelConfigs string, ...) string
- func RelabelDebugStepsJSON(targetURL, targetID string, dss []DebugStep, metric, relabelConfigs string, ...) string
- func SanitizeLabelName(name string) string
- func SanitizeMetricName(value string) string
- func SortLabels(labels []prompbmarshal.Label)
- func SplitMetricNameToTokens(name string) []string
- func StreamRelabelDebugSteps(qw422016 *qt422016.Writer, targetURL, targetID, format string, dss []DebugStep, ...)
- func StreamRelabelDebugStepsHTML(qw422016 *qt422016.Writer, targetURL, targetID string, dss []DebugStep, ...)
- func StreamRelabelDebugStepsJSON(qw422016 *qt422016.Writer, targetURL, targetID string, dss []DebugStep, ...)
- func WriteMetricRelabelDebug(w io.Writer, targetID, metric, relabelConfigs, format string, err error)
- func WriteRelabelDebugSteps(qq422016 qtio422016.Writer, targetURL, targetID, format string, ...)
- func WriteRelabelDebugStepsHTML(qq422016 qtio422016.Writer, targetURL, targetID string, dss []DebugStep, ...)
- func WriteRelabelDebugStepsJSON(qq422016 qtio422016.Writer, targetURL, targetID string, dss []DebugStep, ...)
- func WriteTargetRelabelDebug(w io.Writer, targetID, metric, relabelConfigs, format string, err error)
- type DebugStep
- type IfExpression
- func (ie *IfExpression) MarshalJSON() ([]byte, error)
- func (ie *IfExpression) MarshalYAML() (interface{}, error)
- func (ie *IfExpression) Match(labels []prompbmarshal.Label) bool
- func (ie *IfExpression) Parse(s string) error
- func (ie *IfExpression) String() string
- func (ie *IfExpression) UnmarshalJSON(data []byte) error
- func (ie *IfExpression) UnmarshalYAML(f func(interface{}) error) error
- type MultiLineRegex
- type ParsedConfigs
- type RelabelConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanLabels ¶
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 GetScrapeURL ¶
GetScrapeURL makes scrape url and __address_ labels for the given labels and extraParams.
func LabelsToString ¶
func LabelsToString(labels []prompbmarshal.Label) string
LabelsToString returns Prometheus string representation for the given labels.
Labels in the returned string are sorted by name, while the __name__ label is put in front of {} labels.
func RelabelDebugSteps ¶
func RelabelDebugStepsHTML ¶
func RelabelDebugStepsJSON ¶
func SanitizeLabelName ¶
SanitizeLabelName replaces unsupported by Prometheus chars in label names with _.
See https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
func SanitizeMetricName ¶
SanitizeMetricName replaces unsupported by Prometheus chars in metric names with _.
See https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
func SortLabels ¶
func SortLabels(labels []prompbmarshal.Label)
SortLabels sorts labels in alphabetical order.
func SplitMetricNameToTokens ¶
SplitMetricNameToTokens returns tokens generated from metric name divided by unsupported Prometheus characters
See https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
func StreamRelabelDebugSteps ¶
func WriteMetricRelabelDebug ¶
func WriteMetricRelabelDebug(w io.Writer, targetID, metric, relabelConfigs, format string, err error)
WriteMetricRelabelDebug writes /metric-relabel-debug page to w with the corresponding args.
func WriteRelabelDebugSteps ¶
Types ¶
type DebugStep ¶
type DebugStep struct { // Rule contains string representation of the rule step Rule string // In contains the input labels before the execution of the rule step In string // Out contains the output labels after the execution of the rule step Out string }
DebugStep contains debug information about a single relabeling rule step
type IfExpression ¶
type IfExpression struct {
// contains filtered or unexported fields
}
IfExpression represents PromQL-like label filters such as `metric_name{filters...}`.
It may contain either a single filter or multiple filters, which are executed with `or` operator.
Examples:
if: 'foo{bar="baz"}'
if: - 'foo{bar="baz"}' - '{x=~"y"}'
func (*IfExpression) MarshalJSON ¶
func (ie *IfExpression) MarshalJSON() ([]byte, error)
MarshalJSON marshals ie to JSON.
func (*IfExpression) MarshalYAML ¶
func (ie *IfExpression) MarshalYAML() (interface{}, error)
MarshalYAML marshals ie to YAML
func (*IfExpression) Match ¶
func (ie *IfExpression) Match(labels []prompbmarshal.Label) bool
Match returns true if labels match at least a single label filter inside ie.
Match returns true for empty ie.
func (*IfExpression) String ¶
func (ie *IfExpression) String() string
String returns string representation of ie.
func (*IfExpression) UnmarshalJSON ¶
func (ie *IfExpression) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals ie from JSON data.
func (*IfExpression) UnmarshalYAML ¶
func (ie *IfExpression) UnmarshalYAML(f func(interface{}) error) error
UnmarshalYAML unmarshals ie from YAML passed to f.
type MultiLineRegex ¶
type MultiLineRegex struct {
S string
}
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 ¶
func (mlr *MultiLineRegex) MarshalYAML() (interface{}, error)
MarshalYAML marshals mlr to YAML.
func (*MultiLineRegex) UnmarshalYAML ¶
func (mlr *MultiLineRegex) UnmarshalYAML(f func(interface{}) error) error
UnmarshalYAML unmarshals mlr from YAML passed to f.
type ParsedConfigs ¶
type ParsedConfigs struct {
// contains filtered or unexported fields
}
ParsedConfigs represents parsed relabel configs.
func LoadRelabelConfigs ¶
func LoadRelabelConfigs(path string) (*ParsedConfigs, error)
LoadRelabelConfigs loads relabel configs from the given path.
func ParseRelabelConfigs ¶
func ParseRelabelConfigs(rcs []RelabelConfig) (*ParsedConfigs, error)
ParseRelabelConfigs parses rcs to dst.
func ParseRelabelConfigsData ¶
func ParseRelabelConfigsData(data []byte) (*ParsedConfigs, error)
ParseRelabelConfigsData parses relabel configs from the given data.
func (*ParsedConfigs) Apply ¶
func (pcs *ParsedConfigs) Apply(labels []prompbmarshal.Label, labelsOffset int) []prompbmarshal.Label
Apply applies pcs to labels starting from the labelsOffset.
This function may add additional labels after the len(labels), so make sure it doesn't corrupt in-use labels stored between len(labels) and cap(labels).
func (*ParsedConfigs) ApplyDebug ¶
func (pcs *ParsedConfigs) ApplyDebug(labels []prompbmarshal.Label) ([]prompbmarshal.Label, []DebugStep)
ApplyDebug applies pcs to labels in debug mode.
It returns DebugStep list - one entry per each applied relabeling step.
func (*ParsedConfigs) Len ¶
func (pcs *ParsedConfigs) Len() int
Len returns the number of relabel configs in pcs.
func (*ParsedConfigs) String ¶
func (pcs *ParsedConfigs) String() string
String returns human-readabale representation for pcs.
type RelabelConfig ¶
type RelabelConfig struct { If *IfExpression `yaml:"if,omitempty"` Action string `yaml:"action,omitempty"` 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"` // Match is used together with Labels for `action: graphite`. For example: // - action: graphite // match: 'foo.*.*.bar' // labels: // job: '$1' // instance: '${2}:8080' Match string `yaml:"match,omitempty"` // Labels is used together with Match for `action: graphite`. For example: // - action: graphite // match: 'foo.*.*.bar' // labels: // job: '$1' // instance: '${2}:8080' Labels map[string]string `yaml:"labels,omitempty"` }
RelabelConfig represents relabel config.
See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config