Skip to content

Commit 63e50e9

Browse files
Update OM 2.0 with proposal#43 Created Timestamp syntax (#2636)
* Update OM 2.0 with proposal#43 * Update ABNF representation of Created Values Signed-off-by: Arthur Silva Sens <[email protected]> Signed-off-by: George Krajcsovits <[email protected]> Co-authored-by: George Krajcsovits <[email protected]>
1 parent bbf3583 commit 63e50e9

File tree

1 file changed

+61
-53
lines changed

1 file changed

+61
-53
lines changed

docs/specs/om/open_metrics_spec_2_0.md

Lines changed: 61 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ MetricFamily names beginning with underscores are RESERVED and MUST NOT be used
124124

125125
###### Suffixes
126126

127-
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_created" as a counter called "foo" could create a "foo_created" in the text format.
127+
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.
128128

129129
Exposers SHOULD avoid names that could be confused with the suffixes that text format sample metric names use.
130130

131131
* Suffixes for the respective types are:
132-
* Counter: `_total`, `_created`
133-
* Summary: `_count`, `_sum`, `_created`, `` (empty)
134-
* Histogram: `_count`, `_sum`, `_bucket`, `_created`
132+
* Counter: `_total`
133+
* Summary: `_count`, `_sum`, `` (empty)
134+
* Histogram: `_count`, `_sum`, `_bucket`
135135
* GaugeHistogram: `_gcount`, `_gsum`, `_bucket`
136136
* Info: `_info`
137137
* Gauge: `` (empty)
@@ -216,7 +216,7 @@ MetricFamilies of type Info MUST have an empty Unit string.
216216

217217
Histograms measure distributions of discrete events. Common examples are the latency of HTTP requests, function runtimes, or I/O request sizes.
218218

219-
A Histogram MetricPoint MUST contain at least one bucket, and SHOULD contain Sum, and Created values. Every bucket MUST have a threshold and a value.
219+
A Histogram MetricPoint MUST contain at least one bucket, and SHOULD contain Sum, and Created Values. Every bucket MUST have a threshold and a value.
220220

221221
Histogram MetricPoints MUST have one bucket with an +Inf threshold. Buckets MUST be cumulative. As an example for a metric representing request latency in seconds its values for buckets with thresholds 1, 2, 3, and +Inf MUST follow value_1 <= value_2 <= value_3 <= value_+Inf. If ten requests took 1 second each, the values of the 1, 2, 3, and +Inf buckets MUST equal 10.
222222

@@ -321,7 +321,7 @@ metric = *sample
321321
metric-type = counter / gauge / histogram / gaugehistogram / stateset
322322
metric-type =/ info / summary / unknown
323323
324-
sample = metricname [labels] SP number [SP timestamp] [exemplar] LF
324+
sample = metricname [labels] SP number [SP timestamp] [SP created] [exemplar] LF
325325
326326
exemplar = SP HASH SP labels SP number [SP timestamp]
327327
@@ -383,6 +383,9 @@ escaped-char =/ BS normal-char
383383
384384
; Any unicode character, except newline, double quote, and backslash
385385
normal-char = %x00-09 / %x0B-21 / %x23-5B / %x5D-D7FF / %xE000-10FFFF
386+
387+
; Lowercase ct @ timestamp
388+
created = %d99.116 "@" timestamp
386389
```
387390

388391
#### Overall Structure
@@ -403,12 +406,10 @@ An example of a complete exposition:
403406
# TYPE acme_http_router_request_seconds summary
404407
# UNIT acme_http_router_request_seconds seconds
405408
# HELP acme_http_router_request_seconds Latency though all of ACME's HTTP request router.
406-
acme_http_router_request_seconds_sum{path="/api/v1",method="GET"} 9036.32
407-
acme_http_router_request_seconds_count{path="/api/v1",method="GET"} 807283.0
408-
acme_http_router_request_seconds_created{path="/api/v1",method="GET"} 1605281325.0
409-
acme_http_router_request_seconds_sum{path="/api/v2",method="POST"} 479.3
410-
acme_http_router_request_seconds_count{path="/api/v2",method="POST"} 34.0
411-
acme_http_router_request_seconds_created{path="/api/v2",method="POST"} 1605281325.0
409+
acme_http_router_request_seconds_sum{path="/api/v1",method="GET"} 9036.32 [email protected]
410+
acme_http_router_request_seconds_count{path="/api/v1",method="GET"} 807283.0 [email protected]
411+
acme_http_router_request_seconds_sum{path="/api/v2",method="POST"} 479.3 [email protected]
412+
acme_http_router_request_seconds_count{path="/api/v2",method="POST"} 34.0 [email protected]
412413
# TYPE go_goroutines gauge
413414
# HELP go_goroutines Number of goroutines that currently exist.
414415
go_goroutines 69
@@ -633,7 +634,7 @@ foo 18.0 456
633634

634635
##### Counter
635636

636-
The MetricPoint's Total Value Sample MetricName MUST have the suffix `_total`. If present the MetricPoint's Created Value Sample MetricName MUST have the suffix `_created`.
637+
The MetricPoint's Total Value Sample MetricName MUST have the suffix `_total`. If present, the MetricPoint's Created Value MUST be inlined with the Metric point with a `ct@` prefix. If the value's timestamp is present, the Created Value MUST be added right after it. If exemplar is present, the Created Value MUST be added before it.
637638

638639
An example with a Metric with no labels, and a MetricPoint with no timestamp and no created:
639640

@@ -642,31 +643,36 @@ An example with a Metric with no labels, and a MetricPoint with no timestamp and
642643
foo_total 17.0
643644
```
644645

645-
An example with a Metric with no labels, and a MetricPoint with a timestamp and no created:
646+
An example with a Metric with no labels, and a MetricPoint with a timestamp and no Created Value:
646647

647648
```openmetrics-add-eof
648649
# TYPE foo counter
649650
foo_total 17.0 1520879607.789
650651
```
651652

652-
An example with a Metric with no labels, and a MetricPoint with no timestamp and a created:
653+
An example with a Metric with no labels, and a MetricPoint with no timestamp and a Created Value:
653654

654655
```openmetrics-add-eof
655656
# TYPE foo counter
656-
foo_total 17.0
657-
foo_created 1520430000.123
657+
foo_total 17.0 [email protected]
658658
```
659659

660-
An example with a Metric with no labels, and a MetricPoint with a timestamp and a created:
660+
An example with a Metric with no labels, and a MetricPoint with a timestamp and a Created Value:
661661

662662
```openmetrics-add-eof
663663
# TYPE foo counter
664-
foo_total 17.0 1520879607.789
665-
foo_created 1520430000.123 1520879607.789
664+
foo_total 17.0 1520879607.789 [email protected]
666665
```
667666

668667
Exemplars MAY be attached to the MetricPoint's Total sample.
669668

669+
An example with a Metric with no labels, and a MetricPoint with a timestamp and a Created Value and an exemplar:
670+
671+
```openmetrics-add-eof
672+
# TYPE foo counter
673+
foo_total 17.0 1520879607.789 [email protected] # {trace_id="KOO5S4vxi0o"} 0.67
674+
```
675+
670676
##### StateSet
671677

672678
The Sample MetricName for the value of a MetricPoint for a MetricFamily of type StateSet MUST NOT have a suffix.
@@ -717,52 +723,55 @@ Metric labels and MetricPoint value labels MAY be in any order.
717723

718724
##### Summary
719725

720-
If present, the MetricPoint's Sum Value Sample MetricName MUST have the suffix `_sum`. If present, the MetricPoint's Count Value Sample MetricName MUST have the suffix `_count`. If present, the MetricPoint's Created Value Sample MetricName MUST have the suffix `_created`. If present, the MetricPoint's Quantile Values MUST specify the quantile measured using a label with a label name of "quantile" and with a label value of the quantile measured.
726+
If present, the MetricPoint's Sum Value Sample MetricName MUST have the suffix `_sum`. If present, the MetricPoint's Count Value MetricName MUST have the suffix `_count`. If present, the MetricPoint's Quantile Values MUST specify the quantile measured using a label with a label name of "quantile" and with a label value of the quantile measured.
727+
728+
If present the MetricPoint's Created Value MUST be inlined with the Metric point with a `ct@` prefix. If the value's timestamp is present, the Created Value MUST be added right after it. If exemplar is present, the Created Value MUST be added before it. Created Value MUST be appended to all Quantile Values, to the MetricPoint's Sum and MetricPoint's Count.
721729

722-
An example of a Metric with no labels and a MetricPoint with Sum, Count and Created values:
730+
An example of a Metric with no labels and a MetricPoint with Sum, Count and Created Values:
723731

724732
```openmetrics-add-eof
725733
# TYPE foo summary
726-
foo_count 17.0
727-
foo_sum 324789.3
728-
foo_created 1520430000.123
734+
foo_count 17.0 [email protected]
735+
foo_sum 324789.3 [email protected]
729736
```
730737

731-
An example of a Metric with no labels and a MetricPoint with two quantiles:
738+
An example of a Metric with no labels and a MetricPoint with two quantiles and Created Values:
732739

733740
```openmetrics-add-eof
734741
# TYPE foo summary
735-
foo{quantile="0.95"} 123.7
736-
foo{quantile="0.99"} 150.0
742+
foo{quantile="0.95"} 123.7 [email protected]
743+
foo{quantile="0.99"} 150.0 [email protected]
737744
```
738745

739746
Quantiles MAY be in any order.
740747

741748
##### Histogram
742749

743-
The MetricPoint's Bucket Values Sample MetricNames MUST have the suffix `_bucket`. If present, the MetricPoint's Sum Value Sample MetricName MUST have the suffix `_sum`. If present, the MetricPoint's Created Value Sample MetricName MUST have the suffix `_created`.
750+
The MetricPoint's Bucket Values Sample MetricNames MUST have the suffix `_bucket`. If present, the MetricPoint's Sum Value Sample MetricName MUST have the suffix `_sum`.
751+
752+
If present the MetricPoint's Created Value MUST be inlined with the Metric point with a `ct@` prefix. If the value's timestamp is present, the Created Value MUST be added right after it. If exemplar is present, the Created Value MUST be added before it. Created Value MUST be appended to all Bucket Values, to the MetricPoint's Sum and MetricPoint's Count.
753+
744754
If and only if a Sum Value is present in a MetricPoint, then the MetricPoint's +Inf Bucket value MUST also appear in a Sample with a MetricName with the suffix "_count".
745755

746756
Buckets MUST be sorted in number increasing order of "le", and the value of the "le" label MUST follow the rules for Canonical Numbers.
747757

748-
An example of a Metric with no labels and a MetricPoint with Sum, Count, and Created values, and with 12 buckets. A wide and atypical but valid variety of “le” values is shown on purpose:
758+
An example of a Metric with no labels and a MetricPoint with Sum, Count, and Created Values, and with 12 buckets. A wide and atypical but valid variety of “le” values is shown on purpose:
749759

750760
```openmetrics-add-eof
751761
# TYPE foo histogram
752-
foo_bucket{le="0.0"} 0
753-
foo_bucket{le="1e-05"} 0
754-
foo_bucket{le="0.0001"} 5
755-
foo_bucket{le="0.1"} 8
756-
foo_bucket{le="1.0"} 10
757-
foo_bucket{le="10.0"} 11
758-
foo_bucket{le="100000.0"} 11
759-
foo_bucket{le="1e+06"} 15
760-
foo_bucket{le="1e+23"} 16
761-
foo_bucket{le="1.1e+23"} 17
762-
foo_bucket{le="+Inf"} 17
763-
foo_count 17
764-
foo_sum 324789.3
765-
foo_created 1520430000.123
762+
foo_bucket{le="0.0"} 0 [email protected]
763+
foo_bucket{le="1e-05"} 0 [email protected]
764+
foo_bucket{le="0.0001"} 5 [email protected]
765+
foo_bucket{le="0.1"} 8 [email protected]
766+
foo_bucket{le="1.0"} 10 [email protected]
767+
foo_bucket{le="10.0"} 11 [email protected]
768+
foo_bucket{le="100000.0"} 11 [email protected]
769+
foo_bucket{le="1e+06"} 15 [email protected]
770+
foo_bucket{le="1e+23"} 16 [email protected]
771+
foo_bucket{le="1.1e+23"} 17 [email protected]
772+
foo_bucket{le="+Inf"} 17 [email protected]
773+
foo_count 17 [email protected]
774+
foo_sum 324789.3 [email protected]
766775
```
767776

768777
###### Exemplars
@@ -774,14 +783,13 @@ The "0.01" bucket has no Exemplar. The 0.1 bucket has an Exemplar with no Labels
774783

775784
```openmetrics-add-eof
776785
# TYPE foo histogram
777-
foo_bucket{le="0.01"} 0
778-
foo_bucket{le="0.1"} 8 # {} 0.054
779-
foo_bucket{le="1"} 11 # {trace_id="KOO5S4vxi0o"} 0.67
780-
foo_bucket{le="10"} 17 # {trace_id="oHg5SJYRHA0"} 9.8 1520879607.789
781-
foo_bucket{le="+Inf"} 17
782-
foo_count 17
783-
foo_sum 324789.3
784-
foo_created 1520430000.123
786+
foo_bucket{le="0.01"} 0 [email protected]
787+
foo_bucket{le="0.1"} 8 [email protected] # {} 0.054
788+
foo_bucket{le="1"} 11 [email protected] # {trace_id="KOO5S4vxi0o"} 0.67
789+
foo_bucket{le="10"} 17 [email protected] # {trace_id="oHg5SJYRHA0"} 9.8 1520879607.789
790+
foo_bucket{le="+Inf"} 17 [email protected]
791+
foo_count 17 [email protected]
792+
foo_sum 324789.3 [email protected]
785793
```
786794

787795
##### GaugeHistogram
@@ -1120,7 +1128,7 @@ my_time_since_boot_seconds 123
11201128
```
11211129

11221130
Conversely, there are no best practice restrictions on exemplars timestamps.
1123-
Keep in mind that due to race conditions or time not being perfectly synced across devices, that an exemplar timestamp may appear to be slightly in the future relative to a ingestor's system clock or other metrics from the same exposition. Similarly it is possible that a "_created" for a MetricPoint could appear to be slightly after an exemplar or sample timestamp for that same MetricPoint.
1131+
Keep in mind that due to race conditions or time not being perfectly synced across devices, that an exemplar timestamp may appear to be slightly in the future relative to a ingestor's system clock or other metrics from the same exposition. Similarly it is possible that a "ct@" for a MetricPoint could appear to be slightly after an exemplar or sample timestamp for that same MetricPoint.
11241132

11251133
Keep in mind that there are monitoring systems in common use which support everything from nanosecond to second resolution, so having two MetricPoints that have the same timestamp when truncated to second resolution may cause an apparent duplicate in the ingestor. In this case the MetricPoint with the earliest timestamp MUST be used.
11261134

0 commit comments

Comments
 (0)