package model

Import Path
	github.com/prometheus/common/model (on go.dev)

Dependency Relation
	imports 9 packages, and imported by 2 packages

Involved Source Files alert.go fingerprinting.go fnv.go labels.go labelset.go metric.go Package model contains common data structures that are shared across Prometheus components and libraries. signature.go silence.go time.go value.go
Package-Level Type Names (total 30, all are exported)
/* sort exporteds by: | */
Alert is a generic representation of an alert in the Prometheus eco-system. Extra key/value information which does not define alert identity. EndsAt time.Time GeneratorURL string Label value pairs for purpose of aggregation, matching, and disposition dispatching. This must minimally include an "alertname" label. The known time range for this alert. Both ends are optional. Fingerprint returns a unique hash for the alert. It is equivalent to the fingerprint of the alert's label set. Name returns the name of the alert. It is equivalent to the "alertname" label. Resolved returns true iff the activity interval ended in the past. ResolvedAt returns true off the activity interval ended before the given timestamp. Status returns the status of the alert. (*T) String() string Validate checks whether the alert data is inconsistent. *T : github.com/aws/aws-sdk-go/aws/request.Validator *T : github.com/go-git/go-git/v5/plumbing/transport.AuthMethod *T : expvar.Var *T : fmt.Stringer
Alert is a list of alerts that can be sorted in chronological order. HasFiring returns true iff one of the alerts is not resolved. ( T) Len() int ( T) Less(i, j int) bool Status returns StatusFiring iff at least one of the alerts is firing. ( T) Swap(i, j int) T : sort.Interface
func (*Alert).Status() AlertStatus func Alerts.Status() AlertStatus const AlertFiring const AlertResolved
Duration wraps time.Duration. It is used to parse the custom duration format from YAML. This type should not propagate beyond the scope of input/output processing. MarshalYAML implements the yaml.Marshaler interface. Set implements pflag/flag.Value ( T) String() string Type implements pflag.Value UnmarshalYAML implements the yaml.Unmarshaler interface. T : expvar.Var *T : flag.Value T : fmt.Stringer T : gopkg.in/yaml.v2.Marshaler *T : gopkg.in/yaml.v2.Unmarshaler func ParseDuration(durationStr string) (Duration, error)
Fingerprint provides a hash-capable representation of a Metric. For our purposes, FNV-1A 64-bit is used. ( T) String() string T : expvar.Var T : fmt.Stringer func FingerprintFromString(s string) (Fingerprint, error) func ParseFingerprint(s string) (Fingerprint, error) func (*Alert).Fingerprint() Fingerprint func LabelSet.FastFingerprint() Fingerprint func LabelSet.Fingerprint() Fingerprint func Metric.FastFingerprint() Fingerprint func Metric.Fingerprint() Fingerprint
Fingerprints represents a collection of Fingerprint subject to a given natural sorting scheme. It implements sort.Interface. Len implements sort.Interface. Less implements sort.Interface. Swap implements sort.Interface. T : sort.Interface
FingerprintSet is a set of Fingerprints. Equal returns true if both sets contain the same elements (and not more). Intersection returns the elements contained in both sets. func FingerprintSet.Intersection(o FingerprintSet) FingerprintSet func FingerprintSet.Equal(o FingerprintSet) bool func FingerprintSet.Intersection(o FingerprintSet) FingerprintSet
Interval describes an interval between two timestamps. End Time Start Time
A LabelName is a key for a LabelSet or Metric. It has a value associated therewith. IsValid is true iff the label name matches the pattern of LabelNameRE. This method, however, does not use LabelNameRE for the check but a much faster hardcoded implementation. UnmarshalJSON implements the json.Unmarshaler interface. UnmarshalYAML implements the yaml.Unmarshaler interface. T : database/sql/driver.Validator *T : encoding/json.Unmarshaler *T : gopkg.in/yaml.v2.Unmarshaler func SignatureForLabels(m Metric, labels ...LabelName) uint64 func SignatureWithoutLabels(m Metric, labels map[LabelName]struct{}) uint64
LabelNames is a sortable LabelName slice. In implements sort.Interface. ( T) Len() int ( T) Less(i, j int) bool ( T) String() string ( T) Swap(i, j int) T : expvar.Var T : fmt.Stringer T : sort.Interface
LabelPair pairs a name with a value. Name LabelName Value LabelValue
LabelPairs is a sortable slice of LabelPair pointers. It implements sort.Interface. ( T) Len() int ( T) Less(i, j int) bool ( T) Swap(i, j int) T : sort.Interface
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. Before compares the metrics, using the following criteria: If m has fewer labels than o, it is before o. If it has more, it is not. If the number of labels is the same, the superset of all label names is sorted alphanumerically. The first differing label pair found in that order determines the outcome: If the label does not exist at all in m, then m is before o, and vice versa. Otherwise the label value is compared alphanumerically. If m and o are equal, the method returns false. Clone returns a copy of the label set. Equal returns true iff both label sets have exactly the same key/value pairs. FastFingerprint returns the LabelSet's Fingerprint calculated by a faster hashing algorithm, which is, however, more susceptible to hash collisions. Fingerprint returns the LabelSet's fingerprint. Merge is a helper function to non-destructively merge two label sets. ( T) String() string UnmarshalJSON implements the json.Unmarshaler interface. Validate checks whether all names and values in the label set are valid. T : github.com/aws/aws-sdk-go/aws/request.Validator *T : encoding/json.Unmarshaler T : expvar.Var T : fmt.Stringer func LabelSet.Clone() LabelSet func LabelSet.Merge(other LabelSet) LabelSet func LabelSet.Before(o LabelSet) bool func LabelSet.Equal(o LabelSet) bool func LabelSet.Merge(other LabelSet) LabelSet
A LabelValue is an associated value for a LabelName. IsValid returns true iff the string is a valid UTF8. T : database/sql/driver.Validator func IsValidMetricName(n LabelValue) bool
LabelValues is a sortable LabelValue slice. It implements sort.Interface. ( T) Len() int ( T) Less(i, j int) bool ( T) Swap(i, j int) T : sort.Interface
Matcher describes a matches the value of a given label. IsRegex bool Name LabelName Value string (*T) UnmarshalJSON(b []byte) error Validate returns true iff all fields of the matcher have valid values. *T : github.com/aws/aws-sdk-go/aws/request.Validator *T : encoding/json.Unmarshaler
Matrix is a list of time series. ( T) Len() int ( T) Less(i, j int) bool ( T) String() string ( T) Swap(i, j int) ( T) Type() ValueType T : Value T : expvar.Var T : fmt.Stringer T : sort.Interface
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. Before compares the metrics' underlying label sets. Clone returns a copy of the Metric. Equal compares the metrics. FastFingerprint returns a Metric's Fingerprint calculated by a faster hashing algorithm, which is, however, more susceptible to hash collisions. Fingerprint returns a Metric's Fingerprint. ( T) String() string T : expvar.Var T : fmt.Stringer func Metric.Clone() Metric func SignatureForLabels(m Metric, labels ...LabelName) uint64 func SignatureWithoutLabels(m Metric, labels map[LabelName]struct{}) uint64 func Metric.Before(o Metric) bool func Metric.Equal(o Metric) bool
Sample is a sample pair associated with a metric. Metric Metric Timestamp Time Value SampleValue Equal compares first the metrics, then the timestamp, then the value. The semantics of value equality is defined by SampleValue.Equal. MarshalJSON implements json.Marshaler. ( T) String() string UnmarshalJSON implements json.Unmarshaler. T : encoding/json.Marshaler *T : encoding/json.Unmarshaler T : expvar.Var T : fmt.Stringer func (*Sample).Equal(o *Sample) bool var ZeroSample
SamplePair pairs a SampleValue with a Timestamp. Timestamp Time Value SampleValue Equal returns true if this SamplePair and o have equal Values and equal Timestamps. The semantics of Value equality is defined by SampleValue.Equal. MarshalJSON implements json.Marshaler. ( T) String() string UnmarshalJSON implements json.Unmarshaler. T : encoding/json.Marshaler *T : encoding/json.Unmarshaler T : expvar.Var T : fmt.Stringer func (*SamplePair).Equal(o *SamplePair) bool var ZeroSamplePair
Samples is a sortable Sample slice. It implements sort.Interface. Equal compares two sets of samples and returns true if they are equal. ( T) Len() int Less compares first the metrics, then the timestamp. ( T) Swap(i, j int) T : sort.Interface func Samples.Equal(o Samples) bool
SampleStream is a stream of Values belonging to an attached COWMetric. Metric Metric Values []SamplePair ( T) String() string T : expvar.Var T : fmt.Stringer
A SampleValue is a representation of a value for a given sample at a given time. Equal returns true if the value of v and o is equal or if both are NaN. Note that v==o is false if both are NaN. If you want the conventional float behavior, use == to compare two SampleValues. MarshalJSON implements json.Marshaler. ( T) String() string UnmarshalJSON implements json.Unmarshaler. T : encoding/json.Marshaler *T : encoding/json.Unmarshaler T : expvar.Var T : fmt.Stringer func SampleValue.Equal(o SampleValue) bool
Scalar is a scalar value evaluated at the set timestamp. Timestamp Time Value SampleValue MarshalJSON implements json.Marshaler. ( T) String() string (*T) Type() ValueType UnmarshalJSON implements json.Unmarshaler. *T : Value T : encoding/json.Marshaler *T : encoding/json.Unmarshaler T : expvar.Var T : fmt.Stringer
Silence defines the representation of a silence definition in the Prometheus eco-system. Comment string CreatedAt time.Time CreatedBy string EndsAt time.Time ID uint64 Matchers []*Matcher StartsAt time.Time Validate returns true iff all fields of the silence have valid values. *T : github.com/aws/aws-sdk-go/aws/request.Validator
String is a string value evaluated at the set timestamp. Timestamp Time Value string MarshalJSON implements json.Marshaler. (*T) String() string (*T) Type() ValueType UnmarshalJSON implements json.Unmarshaler. *T : Value T : encoding/json.Marshaler *T : encoding/json.Unmarshaler *T : expvar.Var *T : fmt.Stringer
Time is the number of milliseconds since the epoch (1970-01-01 00:00 UTC) excluding leap seconds. Add returns the Time t + d. After reports whether the Time t is after o. Before reports whether the Time t is before o. Equal reports whether two Times represent the same instant. MarshalJSON implements the json.Marshaler interface. String returns a string representation of the Time. Sub returns the Duration t - o. Time returns the time.Time representation of t. Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC. UnixNano returns t as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC. UnmarshalJSON implements the json.Unmarshaler interface. T : encoding/json.Marshaler *T : encoding/json.Unmarshaler T : expvar.Var T : fmt.Stringer T : golang.org/x/net/internal/timeseries.Clock func Now() Time func TimeFromUnix(t int64) Time func TimeFromUnixNano(t int64) Time func Time.Add(d time.Duration) Time func Time.After(o Time) bool func Time.Before(o Time) bool func Time.Equal(o Time) bool func Time.Sub(o Time) time.Duration const Earliest const Latest
Value is a generic interface for values resulting from a query evaluation. ( T) String() string ( T) Type() ValueType Matrix *Scalar *String Vector T : expvar.Var T : fmt.Stringer
MarshalJSON implements json.Marshaler. ( T) String() string (*T) UnmarshalJSON(b []byte) error T : encoding/json.Marshaler *T : encoding/json.Unmarshaler T : expvar.Var T : fmt.Stringer func Matrix.Type() ValueType func (*Scalar).Type() ValueType func (*String).Type() ValueType func Value.Type() ValueType func Vector.Type() ValueType const ValMatrix const ValNone const ValScalar const ValString const ValVector
Vector is basically only an alias for Samples, but the contract is that in a Vector, all Samples have the same timestamp. Equal compares two sets of samples and returns true if they are equal. ( T) Len() int Less compares first the metrics, then the timestamp. ( T) String() string ( T) Swap(i, j int) ( T) Type() ValueType T : Value T : expvar.Var T : fmt.Stringer T : sort.Interface func github.com/prometheus/common/expfmt.ExtractSamples(o *expfmt.DecodeOptions, fams ...*dto.MetricFamily) (Vector, error) func Vector.Equal(o Vector) bool func github.com/prometheus/common/expfmt.(*SampleDecoder).Decode(s *Vector) error
Package-Level Functions (total 15, in which 10 are exported)
FingerprintFromString transforms a string representation into a Fingerprint.
IsValidMetricName returns true iff name matches the pattern of MetricNameRE. This function, however, does not use MetricNameRE for the check but a much faster hardcoded implementation.
LabelsToSignature returns a quasi-unique signature (i.e., fingerprint) for a given label set. (Collisions are possible but unlikely if the number of label sets the function is applied to is small.)
Now returns the current time as a Time.
ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.
ParseFingerprint parses the input string into a fingerprint.
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. The labels passed in will be sorted by this function.
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.
TimeFromUnix returns the Time equivalent to the Unix Time t provided in seconds.
TimeFromUnixNano returns the Time equivalent to the Unix Time t provided in nanoseconds.
Package-Level Variables (total 7, in which 4 are exported)
LabelNameRE is a regular expression matching valid label names. Note that the IsValid method of LabelName performs the same check but faster than a match with this regular expression.
MetricNameRE is a regular expression matching valid metric names. Note that the IsValidMetricName function performs the same check but faster than a match with this regular expression.
ZeroSample is the pseudo zero-value of Sample used to signal a non-existing sample. It is a Sample with timestamp Earliest, value 0.0, and metric nil. Note that the natural zero value of Sample has a timestamp of 0, which is possible to appear in a real Sample and thus not suitable to signal a non-existing Sample.
ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a non-existing sample pair. It is a SamplePair with timestamp Earliest and value 0.0. Note that the natural zero value of SamplePair has a timestamp of 0, which is possible to appear in a real SamplePair and thus not suitable to signal a non-existing SamplePair.
Package-Level Constants (total 29, in which 24 are exported)
AddressLabel is the name of the label that holds the address of a scrape target.
AlertNameLabel is the name of the label containing the an alert's name.
BucketLabel is used for the label that defines the upper bound of a bucket of a histogram ("le" -> "less or equal").
Earliest is the earliest Time representable. Handy for initializing a high watermark.
ExportedLabelPrefix is the prefix to prepend to the label names present in exported metrics if a label of the same name is added by the server.
InstanceLabel is the label name used for the instance label.
JobLabel is the label name indicating the job from which a timeseries was scraped.
Latest is the latest Time representable. Handy for initializing a low watermark.
MetaLabelPrefix is a prefix for labels that provide meta information. Labels with this prefix are used for intermediate label processing and will not be attached to time series.
MetricNameLabel is the label name indicating the metric name of a timeseries.
MetricsPathLabel is the name of the label that holds the path on which to scrape a target.
ParamLabelPrefix is a prefix for labels that provide URL parameters used to scrape a target.
QuantileLabel is used for the label that defines the quantile in a summary.
ReservedLabelPrefix is a prefix which is not legal in user-supplied label names.
SchemeLabel is the name of the label that holds the scheme on which to scrape a target.
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).
TmpLabelPrefix is a prefix for temporary labels as part of relabelling. Labels with this prefix are used for intermediate label processing and will not be attached to time series. This is reserved for use in Prometheus configuration files by users.