tsdb: github.com/prometheus/tsdb/labels Index | Files

package labels

import "github.com/prometheus/tsdb/labels"

Index

Package Files

labels.go selector.go

func Compare Uses

func Compare(a, b Labels) int

Compare compares the two label sets. The result will be 0 if a==b, <0 if a < b, and >0 if a > b.

type EqualMatcher Uses

type EqualMatcher struct {
    // contains filtered or unexported fields
}

EqualMatcher matches on equality.

func (EqualMatcher) Matches Uses

func (m EqualMatcher) Matches(v string) bool

Matches implements Matcher interface.

func (EqualMatcher) Name Uses

func (m EqualMatcher) Name() string

Name implements Matcher interface.

func (EqualMatcher) String Uses

func (m EqualMatcher) String() string

String implements Matcher interface.

func (EqualMatcher) Value Uses

func (m EqualMatcher) Value() string

Value returns the matched value.

type Label Uses

type Label struct {
    Name, Value string
}

Label is a key/value pair of strings.

type Labels Uses

type Labels []Label

Labels is a sorted set of labels. Order has to be guaranteed upon instantiation.

func FromMap Uses

func FromMap(m map[string]string) Labels

FromMap returns new sorted Labels from the given map.

func FromStrings Uses

func FromStrings(ss ...string) Labels

FromStrings creates new labels from pairs of strings.

func New Uses

func New(ls ...Label) Labels

New returns a sorted Labels from the given labels. The caller has to guarantee that all label names are unique.

func ReadLabels Uses

func ReadLabels(fn string, n int) ([]Labels, error)

ReadLabels reads up to n label sets in a JSON formatted file fn. It is mostly useful to load testing data.

func (Labels) Equals Uses

func (ls Labels) Equals(o Labels) bool

Equals returns whether the two label sets are equal.

func (Labels) Get Uses

func (ls Labels) Get(name string) string

Get returns the value for the label with the given name. Returns an empty string if the label doesn't exist.

func (Labels) Hash Uses

func (ls Labels) Hash() uint64

Hash returns a hash value for the label set.

func (Labels) Len Uses

func (ls Labels) Len() int

func (Labels) Less Uses

func (ls Labels) Less(i, j int) bool

func (Labels) Map Uses

func (ls Labels) Map() map[string]string

Map returns a string map of the labels.

func (Labels) String Uses

func (ls Labels) String() string

func (Labels) Swap Uses

func (ls Labels) Swap(i, j int)

func (Labels) WithoutEmpty Uses

func (ls Labels) WithoutEmpty() Labels

WithoutEmpty returns the labelset without empty labels. May return the same labelset.

type Matcher Uses

type Matcher interface {
    // Name returns the label name the matcher should apply to.
    Name() string
    // Matches checks whether a value fulfills the constraints.
    Matches(v string) bool
    // String returns a human readable matcher.
    String() string
}

Matcher specifies a constraint for the value of a label.

func NewEqualMatcher Uses

func NewEqualMatcher(name, value string) Matcher

NewEqualMatcher returns a new matcher matching an exact label value.

func NewMustRegexpMatcher Uses

func NewMustRegexpMatcher(name, pattern string) Matcher

NewMustRegexpMatcher returns a new matcher verifying that a value matches the regular expression pattern. Will panic if the pattern is not a valid regular expression.

func NewRegexpMatcher Uses

func NewRegexpMatcher(name, pattern string) (Matcher, error)

NewRegexpMatcher returns a new matcher verifying that a value matches the regular expression pattern.

func Not Uses

func Not(m Matcher) Matcher

Not inverts the matcher's matching result.

type NotMatcher Uses

type NotMatcher struct {
    Matcher
}

NotMatcher inverts the matching result for a matcher.

func (NotMatcher) Matches Uses

func (m NotMatcher) Matches(v string) bool

func (NotMatcher) String Uses

func (m NotMatcher) String() string

type RegexpMatcher Uses

type RegexpMatcher struct {
    // contains filtered or unexported fields
}

func (RegexpMatcher) Matches Uses

func (m RegexpMatcher) Matches(v string) bool

func (RegexpMatcher) Name Uses

func (m RegexpMatcher) Name() string

func (RegexpMatcher) String Uses

func (m RegexpMatcher) String() string

func (RegexpMatcher) Value Uses

func (m RegexpMatcher) Value() string

type Selector Uses

type Selector []Matcher

Selector holds constraints for matching against a label set.

func (Selector) Matches Uses

func (s Selector) Matches(labels Labels) bool

Matches returns whether the labels satisfy all matchers.

type Slice Uses

type Slice []Labels

Slice is a sortable slice of label sets.

func (Slice) Len Uses

func (s Slice) Len() int

func (Slice) Less Uses

func (s Slice) Less(i, j int) bool

func (Slice) Swap Uses

func (s Slice) Swap(i, j int)

Package labels imports 10 packages (graph) and is imported by 37 packages. Updated 2019-06-01. Refresh now. Tools for package owners.