You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/specs/om/open_metrics_spec_2_0.md
+79-67Lines changed: 79 additions & 67 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,7 +116,9 @@ Ingestors MAY discard exemplars.
116
116
117
117
#### Metric
118
118
119
-
Metrics are defined by a unique LabelSet within a MetricFamily. Metrics MUST contain a list of one or more MetricPoints. Metrics with the same name for a given MetricFamily SHOULD have the same set of label names in their LabelSet.
119
+
Metrics are defined by a unique LabelSet within a MetricFamily. Metrics MUST contain a list of one or more MetricPoints.
120
+
121
+
Metrics with the same name for a given MetricFamily SHOULD have the same set of label names in their LabelSet.
120
122
121
123
MetricPoints SHOULD NOT have explicit timestamps.
122
124
@@ -128,27 +130,21 @@ A MetricFamily MAY have zero or more Metrics. A MetricFamily MUST have a name, H
128
130
129
131
##### Name
130
132
131
-
MetricFamily names are a string and MUST be unique within a MetricSet. Names SHOULD be in snake_case. Names SHOULD follow the restrictions in the ABNF section under `metricname`. Metric names MAY be any quoted and escaped UTF-8 string as described in the ABNF section. Be aware that exposing UTF-8 metrics is still experimental and may reduce usability, especially when suffixes are not included.
132
-
133
-
Colons in MetricFamily names are RESERVED to signal that the MetricFamily is the result of a calculation or aggregation of a general purpose monitoring system.
133
+
MetricFamily name:
134
134
135
-
MetricFamily names beginning with underscores are RESERVED and MUST NOT be used unless specified by this standard.
135
+
* MUST be string.
136
+
* MUST be unique within a MetricSet.
137
+
* MUST be the same as every MetricPoint's MetricName in the family. TODO(bwplotka): This assumes complex values will be introduced. Otherwise, we need to keep suffixes section for histograms and summaries.
136
138
137
-
###### Suffixes
139
+
> NOTE: [OpenMetrics 1.0](https://prometheus.io/docs/specs/om/open_metrics_spec/#suffixes) was allowing different MetricFamily Name vs MetricName in the same family. For example MetricFamily Name `foo` for a counter with a MetricName `foo_total`. This is no longer accepted thanks to ComplexValue and for parser reliability and future compatibility.
138
140
139
-
The name of a MetricFamily MUST NOT result in a potential clash for sample metric names as per the ABNF with another MetricFamily in the Text Format within a MetricSet. An example would be a gauge called "foo_total" as a counter called "foo" could create a "foo_total" in the text format.
141
+
Names SHOULD be in snake_case. Names SHOULD follow the restrictions in the ABNF section under `metricname`. Metric names MAY be any quoted and escaped UTF-8 string as described in the ABNF section. Be aware that exposing UTF-8 metrics is still experimental and may reduce usability, especially when `_total` or unit suffixes are not included.
142
+
143
+
Colons in MetricFamily names are RESERVED to signal that the MetricFamily is the result of a calculation or aggregation of a general purpose monitoring system.
140
144
141
-
Exposers SHOULD avoid names that could be confused with the suffixes that text format sample metric names use.
145
+
MetricFamily names beginning with underscores are RESERVED and MUST NOT be used unless specified by this standard.
142
146
143
-
* Suffixes for the respective types are:
144
-
* Counter: `_total`
145
-
* Summary: `_count`, `_sum`, `` (empty)
146
-
* Histogram: `_count`, `_sum`, `_bucket`
147
-
* GaugeHistogram: `_gcount`, `_gsum`, `_bucket`
148
-
* Info: `_info`
149
-
* Gauge: `` (empty)
150
-
* StateSet: `` (empty)
151
-
* Unknown: `` (empty)
147
+
MetricFamily name CAN be used to connect [MetricFamily metadata](#metricfamily-metadata) with [MetricPoint](#metricpoint-1) in the [text format](#text-format).
152
148
153
149
##### Type
154
150
@@ -190,13 +186,13 @@ A gauge MAY be used to encode an enum where the enum has many states and changes
190
186
191
187
Counters measure discrete events. Common examples are the number of HTTP requests received, CPU seconds spent, or bytes sent. For counters how quickly they are increasing over time is what is of interest to a user.
192
188
193
-
A MetricPoint in a Metric with the type Counter MUST have one value called Total. A Total is a non-NaN and MUST be monotonically non-decreasing over time, starting from 0.
194
-
195
-
A MetricPoint in a Metric with the type Counter SHOULD have a Timestamp value called Start Timestamp. This can help ingestors discern between new metrics and long-running ones it did not see before.
189
+
A Counter MetricPoint's value MUST be a Number. The value MUST NOT be NaN and MUST be monotonically non-decreasing over time, starting from 0.
196
190
197
-
A MetricPoint in a Metric's Counter's Total MAY reset to 0. If present, the corresponding Start Timestamp MUST also be set to the timestamp of the reset.
191
+
A Counter MetricPoint SHOULD have a Timestamp value called Start Timestamp. This can help ingestors discern between new metrics and long-running ones it did not see before.
198
192
199
-
A MetricPoint in a Metric's Counter's Total MAY have an exemplar.
193
+
A Counter MetricPoint MAY reset to 0. If present, the corresponding Start Timestamp MUST also be set to the timestamp of the reset.
194
+
195
+
A Counter MetricPoint MAY have an exemplar.
200
196
201
197
#### StateSet
202
198
@@ -424,6 +420,7 @@ Line endings MUST be signalled with line feed (\n) and MUST NOT contain carriage
424
420
425
421
An example of a complete exposition:
426
422
423
+
TODO(bwplotka): acme_http_router_request_seconds breaks MetricFamily rule until complex types are introduced.
# HELP go_goroutines Number of goroutines that currently exist.
437
434
go_goroutines 69
438
-
# TYPE process_cpu_seconds counter
439
-
# UNIT process_cpu_seconds seconds
440
-
# HELP process_cpu_seconds Total user and system CPU time spent in seconds.
435
+
# TYPE process_cpu_seconds_total counter
436
+
# UNIT process_cpu_seconds_total seconds
437
+
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
441
438
process_cpu_seconds_total 4.20072246e+06
442
439
# EOF
443
440
```
@@ -489,53 +486,60 @@ Timestamps SHOULD NOT use exponential float rendering for timestamps if nanoseco
489
486
490
487
#### MetricFamily
491
488
492
-
There MUST NOT be an explicit separator between MetricFamilies. The next MetricFamily MUST be signalled with either metadata or a new sample metric name which cannot be part of the previous MetricFamily.
493
-
489
+
There MUST NOT be an explicit separator between MetricFamilies. The next MetricFamily MUST be signalled with either metadata or a new sample metric name.
494
490
495
491
MetricFamilies MUST NOT be interleaved.
496
492
497
493
##### MetricFamily metadata
498
494
499
-
There are four pieces of metadata: The MetricFamily name, TYPE, UNIT and HELP. An example of the metadata for a counter Metric called foo is:
495
+
There are four pieces of metadata: The MetricFamily name, TYPE, UNIT and HELP. An example of the metadata for a counter Metric called foo is:
500
496
501
497
```openmetrics-add-eof
502
-
# TYPE foo counter
498
+
# TYPE foo_total counter
503
499
```
504
500
505
501
If no TYPE is exposed, the MetricFamily MUST be of type Unknown.
506
502
507
-
If a unit is specified it MUST be provided in a UNIT metadata line. In addition, an underscore and the unit SHOULD be the suffix of the MetricFamily name.
503
+
If a unit is specified it MUST be provided in a UNIT metadata line. In addition, an underscore and the unit SHOULD be part of the suffix chain of the MetricFamily name.
508
504
509
-
Be aware that exposing metrics without the unit being a suffix of the MetricFamily name directly to end-users may reduce the usability due to confusion about what the metric's unit is.
505
+
Be aware that exposing metrics without the unit being part of the suffix of the MetricFamily name directly to end-users may reduce the usability due to confusion about what the metric's unit is.
510
506
511
-
A valid example for a foo_seconds metric with a unit of "seconds":
507
+
A valid example for a foo_seconds metric gauge with a unit of "seconds":
512
508
513
509
```openmetrics-add-eof
514
-
# TYPE foo_seconds counter
510
+
# TYPE foo_seconds gauge
515
511
# UNIT foo_seconds seconds
512
+
```
513
+
514
+
A valid example for a foo_seconds_total metric counter with a unit of "seconds":
515
+
516
+
```openmetrics-add-eof
517
+
# TYPE foo_seconds_total counter
518
+
# UNIT foo_seconds_total seconds
516
519
```
517
520
518
-
A valid, but discouraged example, where the unit is not a suffix on the name:
521
+
522
+
A valid, but discouraged example, where the unit is not part of the suffix on the name:
519
523
520
524
```openmetrics-add-eof
521
-
# TYPE foo counter
522
-
# UNIT foo seconds
525
+
# TYPE foo_total counter
526
+
# UNIT foo_total seconds
523
527
```
524
528
525
529
It is also valid to have:
526
530
527
531
```openmetrics-add-eof
528
-
# TYPE foo_seconds counter
532
+
# TYPE foo_seconds_total counter
529
533
```
530
534
531
535
If the unit is known it SHOULD be provided.
532
536
533
537
The value of a UNIT or HELP line MAY be empty. This MUST be treated as if no metadata line for the MetricFamily existed.
534
538
535
539
```openmetrics-add-eof
536
-
# TYPE foo_seconds counter
537
-
# UNIT foo_seconds seconds
538
-
# HELP foo_seconds Some text and \n some \" escaping
540
+
# TYPE foo_seconds_total counter
541
+
# UNIT foo_seconds_total seconds
542
+
# HELP foo_seconds_total Some text and \n some \" escaping
539
543
```
540
544
541
545
There MUST NOT be more than one of each type of metadata line for a MetricFamily. The ordering SHOULD be TYPE, UNIT, HELP.
@@ -546,8 +550,10 @@ Aside from this metadata and the EOF line at the end of the message, you MUST NO
546
550
547
551
Metrics MUST NOT be interleaved.
548
552
549
-
See the example in "Text format -> MetricPoint".
550
-
Labels
553
+
See the example in [MetricPoint](#metricpoint).
554
+
555
+
##### Labels
556
+
551
557
A sample without labels or a timestamp and the value 0 MUST be rendered either like:
552
558
553
559
```openmetrics-add-eof
@@ -574,6 +580,7 @@ MetricPoints MUST NOT be interleaved.
574
580
575
581
A correct example where there were multiple MetricPoints and Samples within a MetricFamily would be:
576
582
583
+
TODO(bwplotka): foo_seconds breaks MetricFamily rule until complex types are introduced.
An incorrect example where MetricPoints are interleaved:
602
610
611
+
TODO(bwplotka): foo_seconds breaks MetricFamily rule until complex types are introduced.
603
612
```
604
613
# TYPE foo_seconds summary
605
614
# UNIT foo_seconds seconds
@@ -613,8 +622,6 @@ foo_seconds_sum{a="bb"} 0 456
613
622
614
623
##### Gauge
615
624
616
-
The Sample MetricName for the value of a MetricPoint for a MetricFamily of type Gauge MUST NOT have a suffix.
617
-
618
625
An example MetricFamily with a Metric with no labels and a MetricPoint with no timestamp:
619
626
620
627
```openmetrics-add-eof
@@ -660,35 +667,37 @@ foo 18.0 456
660
667
661
668
##### Counter
662
669
663
-
The MetricPoint's Total Value Sample MetricName SHOULD have the suffix `_total`. If present, the MetricPoint's Start Timestamp MUST be inlined with the Metric point with a `st@` prefix. If the value's timestamp is present, the Start Timestamp MUST be added right after it. If exemplar is present, the Start Timestamp MUST be added before it.
670
+
The Counter MetricPoint's MetricName SHOULD have the suffix `_total`. Be aware that exposing metrics
671
+
without `_total` suffix may reduce the usability due to confusion about what the metric's type is.
664
672
665
-
Be aware that exposing metrics without `_total` being a suffix of the MetricFamily name directly to end-users may reduce the usability due to confusion about what the metric's type is.
673
+
// TODO Shouldn't it be before t@?
674
+
If present, the MetricPoint's Start Timestamp MUST be inlined with the Metric point with a `st@` prefix, right after the MetricPoint's Timestamp if any, and before any MetricPoint's Exemplar.
666
675
667
676
An example with a Metric with no labels, and a MetricPoint with no timestamp and no Start Timestamp:
668
677
669
678
```openmetrics-add-eof
670
-
# TYPE foo counter
679
+
# TYPE foo_total counter
671
680
foo_total 17.0
672
681
```
673
682
674
683
An example with a Metric with no labels, and a MetricPoint with a timestamp and no Start Timestamp:
675
684
676
685
```openmetrics-add-eof
677
-
# TYPE foo counter
686
+
# TYPE foo_total counter
678
687
foo_total 17.0 1520879607.789
679
688
```
680
689
681
690
An example with a Metric with no labels, and a MetricPoint with no timestamp and a Start Timestamp:
The Sample MetricName for the value of a MetricPoint for a MetricFamily of type StateSet MUST NOT have a suffix.
714
-
715
722
StateSets MUST have one sample per State in the MetricPoint. Each State's sample MUST have a label with the MetricFamily name as the label name and the State name as the label value. The State sample's value MUST be 1 if the State is true and MUST be 0 if the State is false.
716
723
717
724
An example with the states "a", "bb", and "ccc" in which only the value bb is enabled and the metric name is foo:
@@ -792,6 +803,7 @@ Buckets MUST be sorted in number increasing order of "le", and the value of the
792
803
793
804
An example of a Metric with no labels and a MetricPoint with Sum, Count, and Start Timestamp values, and with 12 buckets. A wide and atypical but valid variety of “le” values is shown on purpose:
794
805
806
+
TODO(bwplotka): foo breaks MetricFamily rule until complex types are introduced.
@@ -816,6 +828,7 @@ Exemplars without Labels MUST represent an empty LabelSet as {}.
816
828
An example of Exemplars showcasing several valid cases:
817
829
The "0.01" bucket has no Exemplar. The 0.1 bucket has an Exemplar with no Labels. The 1 bucket has an Exemplar with one Label. The 10 bucket has an Exemplar with a Label and a timestamp. In practice all buckets SHOULD have the same style of Exemplars.
818
830
831
+
TODO(bwplotka): foo breaks MetricFamily rule until complex types are introduced.
@@ -836,6 +849,7 @@ Buckets MUST be sorted in number increasing order of "le", and the value of the
836
849
837
850
An example of a Metric with no labels, and one MetricPoint value with no Exemplar with no Exemplars in the buckets:
838
851
852
+
TODO(bwplotka): foo breaks MetricFamily rule until complex types are introduced.
839
853
```openmetrics-add-eof
840
854
# TYPE foo gaugehistogram
841
855
foo_bucket{le="0.01"} 20.0
@@ -849,8 +863,6 @@ foo_gsum 3289.3
849
863
850
864
##### Unknown
851
865
852
-
The sample metric name for the value of the MetricPoint for a MetricFamily of type Unknown MUST NOT have a suffix.
853
-
854
866
An example with a Metric with no labels and a MetricPoint with no timestamp:
855
867
856
868
```openmetrics-add-eof
@@ -1067,8 +1079,8 @@ One approach would be for push-style ingestors to provide target metadata based
1067
1079
The preferred solution is to provide this target metadata as part of the exposition, but in a way that does not impact on the exposition as a whole. Info MetricFamilies are designed for this. An exposer may include an Info MetricFamily called "target" with a single Metric with no labels with the metadata. An example in the text format might be:
@@ -1117,25 +1129,25 @@ All of this is to say that, in general, MetricPoint timestamps should not be exp
1117
1129
Presume you had a counter my_counter which was initialized, and then later incremented by 1 at time 123. This would be a correct way to expose it in the text format:
1118
1130
1119
1131
```
1120
-
# HELP my_counter Good increment example
1121
-
# TYPE my_counter counter
1132
+
# HELP my_counter_total Good increment example
1133
+
# TYPE my_counter_total counter
1122
1134
my_counter_total 1
1123
1135
```
1124
1136
1125
1137
As per the parent section, ingestors should be free to attach their own timestamps, so this would be incorrect:
1126
1138
1127
1139
```
1128
-
# HELP my_counter Bad increment example
1129
-
# TYPE my_counter counter
1140
+
# HELP my_counter_total Bad increment example
1141
+
# TYPE my_counter_total counter
1130
1142
my_counter_total 1 123
1131
1143
```
1132
1144
1133
1145
1134
1146
In case the specific time of the last change of a counter matters, this would be the correct way:
1135
1147
1136
1148
```
1137
-
# HELP my_counter Good increment example
1138
-
# TYPE my_counter counter
1149
+
# HELP my_counter_total Good increment example
1150
+
# TYPE my_counter_total counter
1139
1151
my_counter_total 1
1140
1152
# HELP my_counter_last_increment_timestamp_seconds When my_counter was last incremented
1141
1153
# TYPE my_counter_last_increment_timestamp_seconds gauge
0 commit comments