Expression can match or reject one time series.
type Expression interface {
// contains filtered or unexported methods
}
func HasPositiveValue() Expression
HasPositiveValue is used to select time series with a positive value.
func HasValueLike(f func(float64) bool) Expression
HasValueLike is used for selecting time series based on value.
func HasValueOf(f float64) Expression
HasValueOf is used for selecting time series based on a specific value.
LabelMatcher can match or reject a label's value.
type LabelMatcher func(string) bool
func Absent() LabelMatcher
Absent is when you want to match series MISSING a specific label.
func Any() LabelMatcher
Any is when you want to select a series which has a certain label, but don't care about the value.
func Equals(expected string) LabelMatcher
Equals is when you want label value to have an exact value.
func IsAddr() LabelMatcher
IsAddr is used to check if the value is an IP:port combo, where IP can be an IPv4 or an IPv6
func IsIP() LabelMatcher
IsIP use used to check if the value is an IPv4 or IPv6
func Like(re *regexp.Regexp) LabelMatcher
Like is when you want label value to match a regular expression.
Labels is used for selecting series with matching labels.
type Labels map[string]LabelMatcher
func TargetAddrLabels() Labels
TargetAddrLabels match series with proper target_addr, target_port, and target_ip.
Matcher contains a list of expressions, which will be checked against each series.
type Matcher struct {
// contains filtered or unexported fields
}
func NewMatcher(name string, ms ...Expression) *Matcher
NewMatcher will match series name (exactly) and all the additional matchers.
func (e *Matcher) HasMatchInString(s string) (bool, error)
HasMatchInString will return: - true, if the provided metrics have a series which matches all expressions, - false, if none of the series matches, - error, if the provided string is not valid Prometheus metrics,
Suite is a list of matchers and messages to check against a string of metrics.
type Suite []matcherAndMessage
func (ms Suite) CheckString(metrics string) error
CheckString will run each assertion in the suite against the provided metrics.
func (ms Suite) MustContain(message string, m *Matcher) Suite
MustContain a series which will match the provided matcher.
func (ms Suite) MustNotContain(message string, m *Matcher) Suite
MustNotContain a series which will match the provided matcher.