promhttputil

package
v0.0.96 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 10 Imported by: 3

README

Rename to promutil?

This is a collection of a bunch of prometheus util methods etc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatcherToString

func MatcherToString(matchers []*labels.Matcher) (string, error)

MatcherToString converts a []*labels.Matcher into the actual matcher you would see on the wire (such as `metricname{label="value"}`)

func MergeSampleStream

func MergeSampleStream(antiAffinityBuffer model.Time, dynamic bool, a, b *model.SampleStream, preferMax bool) (*model.SampleStream, error)

MergeSampleStream merges SampleStreams `a` and `b` with the given antiAffinityBuffer. When combining series from 2 different prometheus hosts we can run into clock-skew / scrape-skew issues (the timestamp prometheus stores is the *start* of the scrape, and exporter response time varies); refusing to merge any datapoint within antiAffinityBuffer of another lets us tolerate antiAffinityBuffer/2 on either side.

When dynamic is true the buffer is recomputed per series from the inter-sample spacing of the longer side: half the median gap, modelling "scrape interval / 2" without forcing operators to know the interval up front. antiAffinityBuffer is the floor / fallback when there are too few samples to estimate (< 3 gaps). See #734.

func MergeValues

func MergeValues(antiAffinityBuffer model.Time, dynamic bool, a, b model.Value, preferMax bool) (model.Value, error)

MergeValues merges values `a` and `b` with the given antiAffinityBuffer. When dynamic is true, each merged SampleStream infers its own anti- affinity from the inter-sample spacing of the longer series and uses antiAffinityBuffer only as a fallback when there isn't enough data to estimate. See #734.

func ValueAddLabelSet

func ValueAddLabelSet(a model.Value, l model.LabelSet) error

ValueAddLabelSet adds the labelset `l` to the value `a`

func WarningsConvert

func WarningsConvert(ws v1.Warnings) annotations.Annotations

WarningsConvert converts v1.Warnings (the JSON-decoded plain-string form of an annotation set) to an annotations.Annotations, preserving the info-vs-warning classification when the original prefix is present.

Types

type ErrorType

type ErrorType string
const (
	ErrorNone     ErrorType = ""
	ErrorTimeout  ErrorType = "timeout"
	ErrorCanceled ErrorType = "canceled"
	ErrorExec     ErrorType = "execution"
	ErrorBadData  ErrorType = "bad_data"
	ErrorInternal ErrorType = "internal"
)

type Status

type Status string

These really should be exported from the prom packages. This was attempted once already -- https://github.com/prometheus/prometheus/pull/3615

const (
	StatusSuccess Status = "success"
	StatusError   Status = "error"
)

type WarningSet

type WarningSet map[string]struct{}

WarningSet simply contains a set of warnings

func (WarningSet) AddWarning

func (s WarningSet) AddWarning(w string)

AddWarning will add a given warning to the set

func (WarningSet) AddWarnings

func (s WarningSet) AddWarnings(ws v1.Warnings)

AddWarnings will add all warnings to the set

func (WarningSet) Warnings

func (s WarningSet) Warnings() v1.Warnings

Warnings returns all of the warnings contained in the set

Jump to

Keyboard shortcuts

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