Documentation ¶
Index ¶
- Constants
- func Compare(a, b Labels) int
- func Equal(ls, o Labels) bool
- type Builder
- type FastRegexMatcher
- type Label
- type Labels
- func (ls Labels) Bytes(buf []byte) []byte
- func (ls Labels) Copy() Labels
- func (ls Labels) Get(name string) string
- func (ls Labels) Has(name string) bool
- func (ls Labels) HasDuplicateLabelNames() (string, bool)
- func (ls Labels) Hash() uint64
- func (ls Labels) HashForLabels(b []byte, names ...string) (uint64, []byte)
- func (ls Labels) HashWithoutLabels(b []byte, names ...string) (uint64, []byte)
- func (ls Labels) Len() int
- func (ls Labels) Less(i, j int) bool
- func (ls Labels) Map() map[string]string
- func (ls Labels) MarshalJSON() ([]byte, error)
- func (ls Labels) MarshalYAML() (interface{}, error)
- func (ls Labels) MatchLabels(on bool, names ...string) Labels
- func (ls Labels) String() string
- func (ls Labels) Swap(i, j int)
- func (ls *Labels) UnmarshalJSON(b []byte) error
- func (ls *Labels) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (ls Labels) WithLabels(names ...string) Labels
- func (ls Labels) WithoutEmpty() Labels
- func (ls Labels) WithoutLabels(names ...string) Labels
- type MatchType
- type Matcher
- type Selector
- type Slice
Constants ¶
const ( MetricName = "__name__" AlertName = "alertname" BucketLabel = "le" InstanceName = "instance" )
Well-known label names used by Prometheus components.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder allows modifying Labels.
func (*Builder) Labels ¶
Labels returns the labels from the builder. If no modifications were made, the original labels are returned.
type FastRegexMatcher ¶ added in v2.25.0
type FastRegexMatcher struct {
// contains filtered or unexported fields
}
func NewFastRegexMatcher ¶ added in v2.25.0
func NewFastRegexMatcher(v string) (*FastRegexMatcher, error)
func (*FastRegexMatcher) GetRegexString ¶ added in v2.25.0
func (m *FastRegexMatcher) GetRegexString() string
func (*FastRegexMatcher) MatchString ¶ added in v2.25.0
func (m *FastRegexMatcher) MatchString(s string) bool
type Labels ¶
type Labels []Label
Labels is a sorted set of labels. Order has to be guaranteed upon instantiation.
func FromStrings ¶
FromStrings creates new labels from pairs of strings.
func New ¶
New returns a sorted Labels from the given labels. The caller has to guarantee that all label names are unique.
func ReadLabels ¶ added in v2.25.0
ReadLabels reads up to n label sets in a JSON formatted file fn. It is mostly useful to load testing data.
func (Labels) Bytes ¶ added in v2.25.0
Bytes returns ls as a byte slice. It uses an byte invalid character as a separator and so should not be used for printing.
func (Labels) Get ¶
Get returns the value for the label with the given name. Returns an empty string if the label doesn't exist.
func (Labels) HasDuplicateLabelNames ¶ added in v2.25.0
HasDuplicateLabelNames returns whether ls has duplicate label names. It assumes that the labelset is sorted.
func (Labels) HashForLabels ¶
HashForLabels returns a hash value for the labels matching the provided names. 'names' have to be sorted in ascending order.
func (Labels) HashWithoutLabels ¶
HashWithoutLabels returns a hash value for all labels except those matching the provided names. 'names' have to be sorted in ascending order.
func (Labels) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Labels) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
func (Labels) MatchLabels ¶
MatchLabels returns a subset of Labels that matches/does not match with the provided label names based on the 'on' boolean. If on is set to true, it returns the subset of labels that match with the provided label names and its inverse when 'on' is set to false.
func (*Labels) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Labels) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.
func (Labels) WithLabels ¶ added in v2.25.0
WithLabels returns a new labels.Labels from ls that only contains labels matching names. 'names' have to be sorted in ascending order.
func (Labels) WithoutEmpty ¶ added in v2.25.0
WithoutEmpty returns the labelset without empty labels. May return the same labelset.
func (Labels) WithoutLabels ¶ added in v2.25.0
WithoutLabels returns a new labels.Labels from ls that contains labels not matching names. 'names' have to be sorted in ascending order.
type Matcher ¶
type Matcher struct { Type MatchType Name string Value string // contains filtered or unexported fields }
Matcher models the matching of a label.
func MustNewMatcher ¶ added in v2.25.0
MustNewMatcher panics on error - only for use in tests!
func NewMatcher ¶
NewMatcher returns a matcher object.
func (*Matcher) GetRegexString ¶ added in v2.25.0
GetRegexString returns the regex string.