promhttputil

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2019 License: MIT Imports: 8 Imported by: 0

README

Rename to promutil?

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

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func MatcherToString added in v0.0.2

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

convert list of labelMatchers to a promql string 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, a, b *model.SampleStream) (*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 some problems with clock skew (from a variety of sources). The primary one I've run into is issues with the time that prometheus stores. Since the time associated with the datapoint is the *start* time of the scrape, there can be quite a lot of time (which can vary dramatically between hosts) for the exporter to return. In an attempt to mitigate this problem we're going to *not* merge any datapoint within antiAffinityBuffer of another point we have. This means we can tolerate antiAffinityBuffer/2 on either side (which can be used by either clock skew or from this scrape skew).

func MergeValues

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

MergeValues merges values `a` and `b` with the given antiAffinityBuffer TODO: always make copies? Now we sometimes return one, or make a copy, or do nothing

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

func ParseTime

func ParseTime(s string) (model.Time, error)

func ValueAddLabelSet

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

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

Types

type ErrorType

type ErrorType string

type QueryData

type QueryData struct {
	ResultType model.ValueType `json:"resultType"`
	Result     model.Value     `json:"result"`
}

func (*QueryData) UnmarshalEasyJSON

func (out *QueryData) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*QueryData) UnmarshalJSON

func (v *QueryData) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Status

type Status string

TODO: have the api.go thing export these attempted once already -- https://github.com/prometheus/prometheus/pull/3615

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

Jump to

Keyboard shortcuts

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