labels

package
v2.0.0-alpha.2+incompa... Latest Latest
Warning

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

Go to latest
Published: May 24, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricName   = "__name__"
	AlertName    = "alertname"
	BucketLabel  = "le"
	InstanceName = "instance"
)

Well-known label names used by Prometheus components.

Variables

This section is empty.

Functions

func Compare

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.

func Equal

func Equal(ls, o Labels) bool

Equal returns whether the two label sets are equal.

Types

type Builder

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

LabelsBuilder allows modifiying Labels.

func NewBuilder

func NewBuilder(base Labels) *Builder

NewBuilder returns a new LabelsBuilder

func (*Builder) Del

func (b *Builder) Del(ns ...string) *Builder

Del deletes the label of the given name.

func (*Builder) Labels

func (b *Builder) Labels() Labels

Labels returns the labels from the builder. If no modifications were made, the original labels are returned.

func (*Builder) Set

func (b *Builder) Set(n, v string) *Builder

Set the name/value pair as a label.

type Label

type Label struct {
	Name, Value string
}

Label is a key/value pair of strings.

type Labels

type Labels []Label

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

func FromMap

func FromMap(m map[string]string) Labels

FromMap returns new sorted Labels from the given map.

func FromStrings

func FromStrings(ss ...string) Labels

FromStrings creates new labels from pairs of strings.

func New

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 (Labels) Copy

func (ls Labels) Copy() Labels

Copy returns a copy of the labels.

func (Labels) Get

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

func (ls Labels) Hash() uint64

Hash returns a hash value for the label set.

func (Labels) Len

func (ls Labels) Len() int

func (Labels) Less

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

func (Labels) Map

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

Map returns a string map of the labels.

func (Labels) MarshalJSON

func (ls Labels) MarshalJSON() ([]byte, error)

func (Labels) String

func (ls Labels) String() string

func (Labels) Swap

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

func (*Labels) UnmarshalJSON

func (ls *Labels) UnmarshalJSON(b []byte) error

type MatchType

type MatchType int

MatchType is an enum for label matching types.

const (
	MatchEqual MatchType = iota
	MatchNotEqual
	MatchRegexp
	MatchNotRegexp
)

Possible MatchTypes.

func (MatchType) String

func (m MatchType) String() string

type Matcher

type Matcher struct {
	Type  MatchType
	Name  string
	Value string
	// contains filtered or unexported fields
}

Matcher models the matching of a label.

func NewMatcher

func NewMatcher(t MatchType, n, v string) (*Matcher, error)

NewMatcher returns a matcher object.

func (*Matcher) Matches

func (m *Matcher) Matches(s string) bool

Matches returns whether the matcher matches the given string value.

func (*Matcher) String

func (m *Matcher) String() string

Jump to

Keyboard shortcuts

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