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) BytesWithLabels(buf []byte, names ...string) []byte
- func (ls Labels) BytesWithoutLabels(buf []byte, names ...string) []byte
- func (ls Labels) Copy() Labels
- func (ls *Labels) CopyFrom(b 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) InternStrings(intern func(string) string)
- func (ls Labels) IsEmpty() bool
- func (ls Labels) IsValid() bool
- 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) Range(f func(l Label))
- func (ls Labels) ReleaseStrings(release func(string))
- 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) Validate(f func(l Label) error) error
- func (ls Labels) WithoutEmpty() Labels
- type MatchType
- type Matcher
- type ScratchBuilder
- 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 ¶
type FastRegexMatcher struct {
// contains filtered or unexported fields
}
func NewFastRegexMatcher ¶
func NewFastRegexMatcher(v string) (*FastRegexMatcher, error)
func (*FastRegexMatcher) GetRegexString ¶
func (m *FastRegexMatcher) GetRegexString() string
func (*FastRegexMatcher) MatchString ¶
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 EmptyLabels ¶
func EmptyLabels() Labels
EmptyLabels returns n empty Labels value, for convenience.
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 ¶
ReadLabels reads up to n label sets in a JSON formatted file fn. It is mostly useful to load testing data.
func (Labels) Bytes ¶
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) BytesWithLabels ¶
BytesWithLabels is just as Bytes(), but only for labels matching names. 'names' have to be sorted in ascending order.
func (Labels) BytesWithoutLabels ¶
BytesWithoutLabels is just as Bytes(), but only for labels not matching names. 'names' have to be sorted in ascending order.
func (*Labels) CopyFrom ¶
Copy labels from b on top of whatever was in ls previously, reusing memory or expanding if needed.
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 ¶
HasDuplicateLabelNames returns whether ls has duplicate label names. It assumes that the labelset is sorted.
func (Labels) Hash ¶
Hash returns a hash value for the label set. Note: the result is not guaranteed to be consistent across different runs of Prometheus.
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) InternStrings ¶
InternStrings calls intern on every string value inside ls, replacing them with what it returns.
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) ReleaseStrings ¶
ReleaseStrings calls release on every string value inside ls.
func (*Labels) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Labels) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.
func (Labels) Validate ¶
Validate calls f on each label. If f returns a non-nil error, then it returns that error cancelling the iteration.
func (Labels) WithoutEmpty ¶
WithoutEmpty returns the labelset without empty labels. May return the same labelset.
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 ¶
MustNewMatcher panics on error - only for use in tests!
func NewMatcher ¶
NewMatcher returns a matcher object.
func (*Matcher) GetRegexString ¶
GetRegexString returns the regex string.
type ScratchBuilder ¶
type ScratchBuilder struct {
// contains filtered or unexported fields
}
ScratchBuilder allows efficient construction of a Labels from scratch.
func NewScratchBuilder ¶
func NewScratchBuilder(n int) ScratchBuilder
NewScratchBuilder creates a ScratchBuilder initialized for Labels with n entries.
func (*ScratchBuilder) Add ¶
func (b *ScratchBuilder) Add(name, value string)
Add a name/value pair. Note if you Add the same name twice you will get a duplicate label, which is invalid.
func (*ScratchBuilder) Assign ¶
func (b *ScratchBuilder) Assign(ls Labels)
Assign is for when you already have a Labels which you want this ScratchBuilder to return.
func (*ScratchBuilder) Labels ¶
func (b *ScratchBuilder) Labels() Labels
Return the name/value pairs added so far as a Labels object. Note: if you want them sorted, call Sort() first.
func (*ScratchBuilder) Overwrite ¶
func (b *ScratchBuilder) Overwrite(ls *Labels)
Write the newly-built Labels out to ls. Callers must ensure that there are no other references to ls, or any strings fetched from it.
func (*ScratchBuilder) Reset ¶
func (b *ScratchBuilder) Reset()