Skip to content

Commit 974c4ed

Browse files
krajoramabwplotka
andauthored
fix(om2.0): fixes in type text format (#2903)
* fix(om2.0): fixes in type text format The one major fix is that a gauge histogram doesn't have start time. Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com> * fix(om2): make gauge histogram distinguishable from one line (#2904) Change count and sum to `gcount` and `gsum` in the exposition for gauge histograms. This mirrors OM 1.0 suffixes. There's too many complications if we don't do this. The only downside is that the histogram functions in PromQL don't have a gauge version, but I think we can live with that. Or even add those later if anyone needs them - which I doubt. Also fix that gauge histograms model currently doesn't have start timestamp, but our text format seemed to conflict with this. Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com> * Apply suggestions from code review Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com> Signed-off-by: George Krajcsovits <krajorama@users.noreply.github.com> * make fmt Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com> --------- Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com> Signed-off-by: George Krajcsovits <krajorama@users.noreply.github.com> Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
1 parent 32aba1e commit 974c4ed

1 file changed

Lines changed: 35 additions & 18 deletions

File tree

docs/specs/om/open_metrics_spec_2_0.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ Quantiles are a map from a quantile to a value. An example is a quantile 0.95 wi
371371

372372
Unknown SHOULD NOT be used. Unknown MAY be used when it is impossible to determine the types of individual metrics from 3rd party systems.
373373

374-
A Sample in a metric with the Unknown Type MUST have a Number value.
374+
A Sample in a metric with the Unknown Type MUST have a Number or CompositeValue value.
375375

376376
## Text Format
377377

@@ -497,15 +497,20 @@ escaped-char =/ BS normal-char
497497
normal-char = %x00-09 / %x0B-21 / %x23-5B / %x5D-D7FF / %xE000-10FFFF
498498
499499
; Composite values
500-
composite-value = histogram-value / summary-value
500+
composite-value = histogram-value / gauge-histogram-value / summary-value
501501
502502
; Histograms
503503
histogram-value = h-count "," h-sum "," histogram-buckets
504+
gauge-histogram-value = gh-count "," gh-sum "," histogram-buckets
504505
505506
; count:x
506507
h-count = %d99.111.117.110.116 ":" number
508+
; gcount:x
509+
gh-count = %d103 h-count
507510
; sum:f allows real numbers and +-Inf and NaN
508511
h-sum = %d115.117.109 ":" number
512+
; gsum:x
513+
gh-sum = %d103 h-sum
509514
510515
histogram-buckets = classic-buckets / native-buckets [ "," classic-buckets ]
511516
@@ -587,7 +592,7 @@ process_cpu_seconds_total 4.20072246e+06
587592
# HELP acme_http_request_seconds Latency histogram of all of ACME's HTTP requests.
588593
acme_http_request_seconds{path="/api/v1",method="GET"} {count:2,sum:1.2e2,schema:0,zero_threshold:1e-4,zero_count:0,positive_spans:[1:2],positive_buckets:[1,1],bucket:[0.5:1,1:2,+Inf:2]} st@1605301325.0
589594
# TYPE acme_http_request_seconds:rate5m gaugehistogram
590-
acme_http_request_seconds:rate5m{path="/api/v1",method="GET"} {count:0.01,sum:2.0,schema:0,zero_threshold:1e-4,zero_count:0.0,positive_spans:[1:2],positive_buckets:[0.005,0.005]} st@1605301325.0
595+
acme_http_request_seconds:rate5m{path="/api/v1",method="GET"} {gcount:0.01,gsum:2.0,schema:0,zero_threshold:1e-4,zero_count:0.0,positive_spans:[1:2],positive_buckets:[0.005,0.005]}
591596
# TYPE "foodb.read.errors" counter
592597
# HELP "foodb.read.errors" The number of errors in the read path for fooDb.
593598
{"foodb.read.errors","service.name"="my_service"} 3482
@@ -717,7 +722,7 @@ Label values MAY be any valid UTF-8 value, so escaping MUST be applied as per th
717722
bar_seconds_count{a="x",b="escaping\" example \n "} 0
718723
```
719724

720-
Metric names and label names MAY also be any valid UTF-8 value, and under certain circumstances they MUST be quoted and escaped per the ABNF. See the UTF-8 Quoting section for specifics.
725+
Metric names and label names MAY also be any valid UTF-8 value, and under certain circumstances they MUST be quoted and escaped per the ABNF. See the [UTF-8 Quoting](#utf-8-quoting) section for specifics.
721726

722727
```openmetrics-add-eof
723728
{"\"bar\".seconds.count","b\\"="escaping\" example \n "} 0
@@ -727,6 +732,8 @@ Metric names and label names MAY also be any valid UTF-8 value, and under certai
727732

728733
#### Gauge
729734

735+
The Sample's value MUST be a Number.
736+
730737
There are no recommended suffixes for the MetricFamily name for a MetricFamily of Type Gauge.
731738

732739
An example MetricFamily with a Metric with no labels and a Sample with no timestamp:
@@ -774,6 +781,8 @@ foo 18.0 456
774781

775782
#### Counter
776783

784+
The Sample's value MUST be a Number.
785+
777786
If present, the Sample's Start Timestamp MUST be inlined with the Sample 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.
778787

779788
An example with a Metric with no labels, and a Sample with no timestamp and no Start Timestamp:
@@ -804,7 +813,7 @@ An example with a Metric with no labels, and a Sample with a timestamp and a Sta
804813
foo_total 17.0 1520879607.789 st@1520430000.123
805814
```
806815

807-
An example with a Metric with no labels, and a Sample without the `_total` suffix and with a timestamp and a start timestamp:
816+
An example with a Metric with no labels, and without the `_total` suffix and a Sample with a Timestamp and a Start Timestamp:
808817

809818
```openmetrics-add-eof
810819
# TYPE foo counter
@@ -929,14 +938,14 @@ If present the Sample's Start Timestamp MUST be inlined with the Sample with a `
929938

930939
The quantiles MUST be sorted in increasing order of the quantile.
931940

932-
An example of a Metric with no labels and a Sample with Sum, Count and Start Timestamp values:
941+
An example of a Metric with no labels and a Sample with Sum, Count and Start Timestamp:
933942

934943
```openmetrics-add-eof
935944
# TYPE foo summary
936945
foo {count:17,sum:324789.3,quantile:[]} st@1520430000.123
937946
```
938947

939-
An example of a Metric with no labels and a Sample with two quantiles and Start Timestamp values:
948+
An example of a Metric with no labels and a Sample with two quantiles and Start Timestamp:
940949

941950
```openmetrics-add-eof
942951
# TYPE foo summary
@@ -974,6 +983,8 @@ If there are negative (and/or positive) Native Buckets, then the fields `negativ
974983

975984
Native Bucket values MUST be ordered by their index, and their values MUST be placed in the `negative_buckets` (and/or `positive_buckets`) fields.
976985

986+
> NOTE: Bucket values are absolute counts, as opposed to some implementations that store bucket values as deltas relative to the preceding bucket.
987+
977988
Native Buckets that have a value of 0 SHOULD NOT be present.
978989

979990
To map the `negative_buckets` (and/or `positive_buckets`) back to their indices, the `negative_spans` (and/or `positive_spans`) field MUST be constructed in the following way: Each span consists of a pair of numbers, an integer called offset and an non-negative integer called length. Only the first span in each list can have a negative offset. It defines the index of the first bucket in its corresponding `negative_buckets` (and/or `positive_buckets`). The length defines the number of consecutive buckets the bucket list starts with. The offsets of the following spans define the number of excluded (and thus unpopulated buckets). The lengths define the number of consecutive buckets in the list following the excluded buckets.
@@ -1048,43 +1059,49 @@ foo {count:17,sum:324789.3,schema:0,zero_threshold:1e-4,zero_count:0,positive_sp
10481059

10491060
#### GaugeHistogram with Classic Buckets
10501061

1051-
The Sample's value MUST be a CompositeValue.
1052-
1053-
The CompositeValue MUST include the Gcount, Gsum and Classic Bucket values as the fields `count`, `sum`, `bucket`, in this order.
1054-
1055-
Classic Buckets MUST be sorted in number increasing order of their threshold.
1062+
GaugeHistogram Samples with Classic Buckets follow the same syntax as Histogram Samples with Classic Buckets, except that the Count and Sum are exposed as the fields `gcount` and `gsum` and GaugeHistograms do not have Start Timestamp.
10561063

1057-
An example of a Metric with no labels, and one Sample value with no Exemplar with no Exemplars in the buckets:
1064+
An example of a Metric with no labels, and one Sample value with no Timestamp, and no Exemplars:
10581065

10591066
```openmetrics-add-eof
10601067
# TYPE foo gaugehistogram
1061-
foo {count:42,sum:3289.3,bucket:[0.01:20,0.1:25,1:34,+Inf:42]}
1068+
foo {gcount:42,gsum:3289.3,bucket:[0.01:20,0.1:25,1:34,+Inf:42]}
10621069
```
10631070

10641071
#### GaugeHistogram with Native Buckets
10651072

1066-
GaugeHistogram Samples with Native Buckets follow the same syntax as Histogram Samples with Native Buckets.
1073+
GaugeHistogram Samples with Native Buckets follow the same syntax as Histogram Samples with Native Buckets, except that the Count and Sum are exposed as the fields `gcount` and `gsum` and GaugeHistograms do not have Start Timestamp.
1074+
1075+
An example of a Metric with no labels, and one Sample value with no Timestamp, and no Exemplars:
10671076

10681077
```openmetrics-add-eof
10691078
# TYPE acme_http_request_seconds gaugehistogram
1070-
acme_http_request_seconds{path="/api/v1",method="GET"} {count:59,sum:1.2e2,schema:7,zero_threshold:1e-4,zero_count:0,negative_spans:[1:2],negative_buckets:[5,7],positive_spans:[-1:2,3:4],positive_buckets:[5,7,10,9,8,8]} st@1520430000.123
1079+
acme_http_request_seconds{path="/api/v1",method="GET"} {gcount:59,gsum:1.2e2,schema:7,zero_threshold:1e-4,zero_count:0,negative_spans:[1:2],negative_buckets:[5,7],positive_spans:[-1:2,3:4],positive_buckets:[5,7,10,9,8,8]}
10711080
```
10721081

10731082
#### GaugeHistogram with both Classic and Native buckets
10741083

1075-
GaugeHistogram Samples with both Classic and Native Buckets follow the same syntax as Histogram Samples with both Classic and Native Buckets.
1084+
GaugeHistogram Samples with both Classic and Native Buckets follow the same syntax as Histogram Samples with both Classic and Native Buckets, except that the Count and Sum are exposed as the fields `gcount` and `gsum` and GaugeHistograms do not have Start Timestamp.
10761085

10771086
#### Unknown
10781087

1088+
The Sample's value MUST be a Number or a CompositeValue.
1089+
10791090
There are no recommended suffixes for the MetricFamily name for a MetricFamily of Type Unknown.
10801091

1081-
An example with a Metric with no labels and a Sample with no timestamp:
1092+
An example with a Metric with no labels and a Sample with no Timestamp:
10821093

10831094
```openmetrics-add-eof
10841095
# TYPE foo unknown
10851096
foo 42.23
10861097
```
10871098

1099+
An example with a Metric without MetricFamily metadata and a Sample with no Timestamp:
1100+
1101+
```openmetrics-add-eof
1102+
foo 42.23
1103+
```
1104+
10881105
## Design Considerations
10891106

10901107
### Scope

0 commit comments

Comments
 (0)