Documentation ¶
Overview ¶
Package model contains core representation of Prometheus client primitives.
Index ¶
- Constants
- func LabelsToSignature(labels map[string]string) uint64
- func SignatureForLabels(m Metric, labels LabelNames) uint64
- func SignatureWithoutLabels(m Metric, labels map[LabelName]struct{}) uint64
- type COWMetric
- type Fingerprint
- type FingerprintSet
- type Fingerprints
- type LabelName
- type LabelNames
- type LabelSet
- type LabelValue
- type LabelValues
- type Metric
- type Sample
- type SampleValue
- type Samples
- type Timestamp
- func (t Timestamp) Add(d native_time.Duration) Timestamp
- func (t Timestamp) After(o Timestamp) bool
- func (t Timestamp) Before(o Timestamp) bool
- func (t Timestamp) Equal(o Timestamp) bool
- func (t Timestamp) MarshalJSON() ([]byte, error)
- func (t Timestamp) String() string
- func (t Timestamp) Sub(o Timestamp) native_time.Duration
- func (t Timestamp) Time() native_time.Time
- func (t Timestamp) Unix() int64
- func (t Timestamp) UnixNano() int64
Constants ¶
const ( // ExporterLabelPrefix is the label name prefix to prepend if a // synthetic label is already present in the exported metrics. ExporterLabelPrefix LabelName = "exporter_" // MetricNameLabel is the label name indicating the metric name of a // timeseries. MetricNameLabel LabelName = "__name__" // ReservedLabelPrefix is a prefix which is not legal in user-supplied // label names. ReservedLabelPrefix = "__" // JobLabel is the label name indicating the job from which a timeseries // was scraped. JobLabel LabelName = "job" // BucketLabel is used for the label that defines the upper bound of a // bucket of a histogram ("le" -> "less or equal"). BucketLabel = "le" // QuantileLabel is used for the label that defines the quantile in a // summary. QuantileLabel = "quantile" )
const ( // MinimumTick is the minimum supported time resolution. This has to be // at least native_time.Second in order for the code below to work. MinimumTick = native_time.Millisecond // Earliest is the earliest timestamp representable. Handy for // initializing a high watermark. Earliest = Timestamp(math.MinInt64) // Latest is the latest timestamp representable. Handy for initializing // a low watermark. Latest = Timestamp(math.MaxInt64) )
const SeparatorByte byte = 255
SeparatorByte is a byte that cannot occur in valid UTF-8 sequences and is used to separate label names, label values, and other strings from each other when calculating their combined hash value (aka signature aka fingerprint).
Variables ¶
This section is empty.
Functions ¶
func LabelsToSignature ¶
LabelsToSignature returns a unique signature (i.e., fingerprint) for a given label set.
func SignatureForLabels ¶ added in v0.4.4
func SignatureForLabels(m Metric, labels LabelNames) uint64
SignatureForLabels works like LabelsToSignature but takes a Metric as parameter (rather than a label map) and only includes the labels with the specified LabelNames into the signature calculation.
func SignatureWithoutLabels ¶ added in v0.4.4
SignatureWithoutLabels works like LabelsToSignature but takes a Metric as parameter (rather than a label map) and excludes the labels with any of the specified LabelNames from the signature calculation.
Types ¶
type COWMetric ¶
COWMetric wraps a Metric to enable copy-on-write access patterns.
func (*COWMetric) Delete ¶
Delete deletes a given label name from the wrapped Metric and copies the Metric initially, if it is not already a copy.
func (COWMetric) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*COWMetric) Set ¶
func (m *COWMetric) Set(ln LabelName, lv LabelValue)
Set sets a label name in the wrapped Metric to a given value and copies the Metric initially, if it is not already a copy.
type Fingerprint ¶
type Fingerprint uint64
Fingerprint provides a hash-capable representation of a Metric. For our purposes, FNV-1A 64-bit is used.
func (Fingerprint) Equal ¶
func (f Fingerprint) Equal(o Fingerprint) bool
Equal implements sort.Interface.
func (Fingerprint) Less ¶
func (f Fingerprint) Less(o Fingerprint) bool
Less implements sort.Interface.
func (*Fingerprint) LoadFromString ¶
func (f *Fingerprint) LoadFromString(s string) error
LoadFromString transforms a string representation into a Fingerprint.
func (Fingerprint) String ¶
func (f Fingerprint) String() string
type FingerprintSet ¶
type FingerprintSet map[Fingerprint]struct{}
FingerprintSet is a set of Fingerprints.
func (FingerprintSet) Equal ¶
func (s FingerprintSet) Equal(o FingerprintSet) bool
Equal returns true if both sets contain the same elements (and not more).
func (FingerprintSet) Intersection ¶
func (s FingerprintSet) Intersection(o FingerprintSet) FingerprintSet
Intersection returns the elements contained in both sets.
type Fingerprints ¶
type Fingerprints []Fingerprint
Fingerprints represents a collection of Fingerprint subject to a given natural sorting scheme. It implements sort.Interface.
func (Fingerprints) Less ¶
func (f Fingerprints) Less(i, j int) bool
Less implements sort.Interface.
type LabelName ¶
type LabelName string
A LabelName is a key for a LabelSet or Metric. It has a value associated therewith.
type LabelNames ¶
type LabelNames []LabelName
LabelNames is a sortable LabelName slice. In implements sort.Interface.
func (LabelNames) Len ¶
func (l LabelNames) Len() int
func (LabelNames) Less ¶
func (l LabelNames) Less(i, j int) bool
func (LabelNames) String ¶
func (l LabelNames) String() string
func (LabelNames) Swap ¶
func (l LabelNames) Swap(i, j int)
type LabelSet ¶
type LabelSet map[LabelName]LabelValue
A LabelSet is a collection of LabelName and LabelValue pairs. The LabelSet may be fully-qualified down to the point where it may resolve to a single Metric in the data store or not. All operations that occur within the realm of a LabelSet can emit a vector of Metric entities to which the LabelSet may match.
func (LabelSet) MergeFromMetric ¶
MergeFromMetric merges Metric into this LabelSet.
type LabelValues ¶
type LabelValues []LabelValue
LabelValues is a sortable LabelValue slice. It implements sort.Interface.
func (LabelValues) Len ¶
func (l LabelValues) Len() int
func (LabelValues) Less ¶
func (l LabelValues) Less(i, j int) bool
func (LabelValues) Swap ¶
func (l LabelValues) Swap(i, j int)
type Metric ¶
type Metric map[LabelName]LabelValue
A Metric is similar to a LabelSet, but the key difference is that a Metric is a singleton and refers to one and only one stream of samples.
func (Metric) Fingerprint ¶
func (m Metric) Fingerprint() Fingerprint
Fingerprint returns a Metric's Fingerprint.
func (Metric) MergeFromLabelSet ¶
MergeFromLabelSet merges a label set into this Metric, prefixing a collision prefix to the label names merged from the label set where required.
type Sample ¶
type Sample struct { Metric Metric Value SampleValue Timestamp Timestamp }
Sample is a sample value with a timestamp and a metric.
type SampleValue ¶
type SampleValue float64
A SampleValue is a representation of a value for a given sample at a given time.
func (SampleValue) Equal ¶
func (v SampleValue) Equal(o SampleValue) bool
Equal does a straight v==o.
func (SampleValue) MarshalJSON ¶
func (v SampleValue) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (SampleValue) String ¶
func (v SampleValue) String() string
type Samples ¶
type Samples []*Sample
Samples is a sortable Sample slice. It implements sort.Interface.
type Timestamp ¶
type Timestamp int64
Timestamp is the number of milliseconds since the epoch (1970-01-01 00:00 UTC) excluding leap seconds.
func TimestampFromTime ¶
func TimestampFromTime(t native_time.Time) Timestamp
TimestampFromTime returns the Timestamp equivalent to the time.Time t.
func TimestampFromUnix ¶
TimestampFromUnix returns the Timestamp equivalent to the Unix timestamp t provided in seconds.
func TimestampFromUnixNano ¶
TimestampFromUnixNano returns the Timestamp equivalent to the Unix timestamp t provided in nanoseconds.
func (Timestamp) Add ¶
func (t Timestamp) Add(d native_time.Duration) Timestamp
Add returns the Timestamp t + d.
func (Timestamp) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Timestamp) Sub ¶
func (t Timestamp) Sub(o Timestamp) native_time.Duration
Sub returns the Duration t - o.
func (Timestamp) Time ¶
func (t Timestamp) Time() native_time.Time
Time returns the time.Time representation of t.