Skip to content

Commit 8c8eeae

Browse files
committed
Classic histogram and summary as complex types
Ref: prometheus/OpenMetrics#283 Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
1 parent 3195123 commit 8c8eeae

1 file changed

Lines changed: 42 additions & 41 deletions

File tree

docs/specs/om/open_metrics_spec_2_0.md

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ ComplexValue MUST contain all information necessary to recreate a sample value f
8686

8787
The following Metric Types MUST use ComplexValue for Metric Values:
8888

89-
TODO: Below will switch to Histogram and Summary in the next PR.
90-
* [Histogram](#histogram) MetricFamily Type with [Native Buckets](#native-buckets).
91-
* [GaugeHistogram](#gauge-histogram) MetricFamily Type with [Native Buckets](#native-buckets).
89+
* [Histogram](#histogram) MetricFamily Type.
90+
* [GaugeHistogram](#gauge-histogram) MetricFamily Type.
9291

9392
Other Metric Types MUST use Numbers.
9493

@@ -412,6 +411,7 @@ ABNF as per RFC 5234
412411
```abnf
413412
exposition = metricset HASH SP eof [ LF ]
414413
414+
415415
metricset = *metricfamily
416416
417417
metricfamily = *metric-descriptor *metric
@@ -498,7 +498,7 @@ normal-char = %x00-09 / %x0B-21 / %x23-5B / %x5D-D7FF / %xE000-10FFFF
498498
start-timestamp = %d115.116 "@" timestamp
499499
500500
; Complex values
501-
complex-value = nativehistogram
501+
complex-value = nativehistogram / classic-histogram / classic-summary
502502
503503
nativehistogram = nh-count "," nh-sum "," nh-schema "," nh-zero-threshold "," nh-zero-count [ "," nh-negative-spans "," nh-negative-buckets ] [ "," nh-positive-spans "," nh-positive-buckets ]
504504
@@ -532,6 +532,32 @@ non-negative-integer = ["+"] 1*"0" / ["+"] positive-integer
532532
; Leading 0s explicitly okay.
533533
positive-integer = *"0" positive-digit *DIGIT
534534
positive-digit = "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"
535+
536+
; count:12,sum:100.0,bucket:[0.1:3,05:12,+Inf:12]
537+
classic-histogram = ch-count "," ch-sum "," ch-bucket
538+
539+
; count:x where x is a real number, not +-Inf or NaN
540+
ch-count = %d99.111.117.110.116 ":" non-negative-integer
541+
; sum:x where x is a real number or +-Inf or NaN
542+
ch-sum = %d115.117.109 ":" number
543+
; bucket:[...]
544+
ch-bucket = %d98.117.99.107.101.116 ":" "[" ch-le-counts "]"
545+
ch-le-counts = ch-pos-inf-bucket / (ch-neg-inf-bucket / ch-le-bucket) *("," ch-le-bucket) "," ch-pos-inf-bucket
546+
ch-pos-inf-bucket = "+" %d73.110.102 ":" non-negative-integer
547+
ch-neg-inf-bucket = "-" %d73.110.102 ":" non-negative-integer
548+
ch-le-bucket = realnumber ":" non-negative-integer
549+
550+
; count:12.0,sum:100.0,quantile:[0.9:2.0,0.95:3.0,0.99:20.0]
551+
classic-summary = cs-count "," cs-sum "," cs-quantile
552+
553+
; count:x where x is a real number, not +-Inf or NaN
554+
cs-count = %d99.111.117.110.116 ":" non-negative-integer
555+
; sum:x where x is a real number or +-Inf or NaN
556+
cs-sum = %d115.117.109 ":" number
557+
; quantile:[...]
558+
cs-quantile = %d113.117.97.110.116.105.108.101 ":" "[" cs-q-counts "]"
559+
cs-q-counts = cs-q-count *("," cs-q-count)
560+
cs-q-count = realnumber ":" non-negative-integer
535561
```
536562

537563
#### Overall Structure
@@ -549,13 +575,16 @@ Line endings MUST be signalled with line feed (\n) and MUST NOT contain carriage
549575
An example of a complete exposition:
550576

551577
```openmetrics
578+
# TYPE acme_http_server_request_seconds histogram
579+
# UNIT acme_http_server_request_seconds seconds
580+
# HELP acme_http_server_request_seconds Latency though all of ACME's HTTP request service.
581+
acme_http_router_request_seconds{path="/api/v1",method="GET"} {count:10,sum:100.0,bucket:[0.1:2,0.5:10,+Inf:10]}
582+
acme_http_router_request_seconds{path="/api/v2",method="GET"} {count:1,sum:10.0,bucket:[0.1:1,0.5:1,+Inf:1]}
552583
# TYPE acme_http_router_request_seconds summary
553584
# UNIT acme_http_router_request_seconds seconds
554585
# HELP acme_http_router_request_seconds Latency though all of ACME's HTTP request router.
555-
acme_http_router_request_seconds_sum{path="/api/v1",method="GET"} 9036.32 st@1605281325.0
556-
acme_http_router_request_seconds_count{path="/api/v1",method="GET"} 807283.0 st@1605281325.0
557-
acme_http_router_request_seconds_sum{path="/api/v2",method="POST"} 479.3 st@1605301325.0
558-
acme_http_router_request_seconds_count{path="/api/v2",method="POST"} 34.0 st@1605301325.0
586+
acme_http_router_request_seconds{path="/api/v1",method="GET"} {count:807283,sum:9036.32,quantile:[0.95:2,0.99:20]} st@1605281325.0
587+
acme_http_router_request_seconds{path="/api/v2",method="GET"} {count:34,sum:479.3,quantile:[0.95:2,0.99:2]} st@1605301325.0
559588
# TYPE go_goroutines gauge
560589
# HELP go_goroutines Number of goroutines that currently exist.
561590
go_goroutines 69
@@ -973,19 +1002,7 @@ An example of a Metric with no labels and a MetricPoint with Sum, Count, and Sta
9731002

9741003
```openmetrics-add-eof
9751004
# TYPE foo histogram
976-
foo_bucket{le="0.0"} 0 st@1520430000.123
977-
foo_bucket{le="1e-05"} 0 st@1521430000.123
978-
foo_bucket{le="0.0001"} 5 st@1521430020.123
979-
foo_bucket{le="0.1"} 8 st@1520430321.123
980-
foo_bucket{le="1.0"} 10 st@1522430000.123
981-
foo_bucket{le="10.0"} 11 st@1520430123.123
982-
foo_bucket{le="100000.0"} 11 st@1521430010.123
983-
foo_bucket{le="1e+06"} 15 st@1520430301.123
984-
foo_bucket{le="1e+23"} 16 st@1521430001.123
985-
foo_bucket{le="1.1e+23"} 17 st@1522430220.123
986-
foo_bucket{le="+Inf"} 17 st@1520430000.123
987-
foo_count 17 st@1520430000.123
988-
foo_sum 324789.3 st@1520430000.123
1005+
foo {count:17,sum:324789.3,bucket:[0.0:0,1e-05:0,0.0001:5,0.1:8,1.0:10,10.0:11,100000.0:11,1e+06:15,1e+23:16,1.1e+23:17,+Inf:17]} st@1520430000.123
9891006
```
9901007

9911008
##### Histogram with Native Buckets
@@ -1037,11 +1054,7 @@ The order ensures that implementations can easily skip the Classic Buckets if th
10371054
# UNIT acme_http_request_seconds seconds
10381055
# HELP acme_http_request_seconds Latency histogram of all of ACME's HTTP requests.
10391056
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]}
1040-
acme_http_request_seconds_count{path="/api/v1",method="GET"} 2
1041-
acme_http_request_seconds_sum{path="/api/v1",method="GET"} 1.2e2
1042-
acme_http_request_seconds_buckets{path="/api/v1",method="GET",le="0.5"} 1
1043-
acme_http_request_seconds_buckets{path="/api/v1",method="GET",le="1"} 2
1044-
acme_http_request_seconds_buckets{path="/api/v1",method="GET",le="+Inf"} 2
1057+
acme_http_request_seconds{path="/api/v1",method="GET"} {count:2,sum:1.2e2,bucket:[0.5:1,1:2,+Inf:2]}
10451058
```
10461059

10471060
###### Exemplars
@@ -1054,14 +1067,8 @@ The "0.01" bucket has no Exemplar. The 0.1 bucket has an Exemplar with no Labels
10541067

10551068
```openmetrics-add-eof
10561069
# TYPE foo histogram
1057-
foo {count:10,sum:1.0,schema:0,zero_threshold:1e-4,zero_count:0,positive_spans:[0:2],positive_buckets:[5,5]} st@1520430000.123 # {trace_id="shaZ8oxi"} 0.67 1520879607.789 # {trace_id="ookahn0M"} 1.2 1520879608.589
1058-
foo_bucket{le="0.01"} 0 st@1520430000.123
1059-
foo_bucket{le="0.1"} 8 st@1520430000.123 # {} 0.054
1060-
foo_bucket{le="1"} 11 st@1520430000.123 # {trace_id="KOO5S4vxi0o"} 0.67
1061-
foo_bucket{le="10"} 17 st@1520430000.123 # {trace_id="oHg5SJYRHA0"} 9.8 1520879607.789
1062-
foo_bucket{le="+Inf"} 17 st@1520430000.123
1063-
foo_count 17 st@1520430000.123
1064-
foo_sum 324789.3 st@1520430000.123
1070+
foo {count:17,sum:324789.3,schema:0,zero_threshold:1e-4,zero_count:0,positive_spans:[0:2],positive_buckets:[5,12]} st@1520430000.123 # {trace_id="shaZ8oxi"} 0.67 1520879607.789 # {trace_id="ookahn0M"} 1.2 1520879608.589
1071+
foo {count:17,sum:324789.3,bucket:[0.01:0,0.1:8,1.0:11,10.0:17,+Inf:17]} st@1520430000.123 # {} 0.054 1520879607.7 # {trace_id="KOO5S4vxi0o"} 0.67 1520879602.890 # {trace_id="oHg5SJYRHA0"} 9.8 1520879607.789
10651072
```
10661073

10671074
##### GaugeHistogram with Classic Buckets
@@ -1074,13 +1081,7 @@ An example of a Metric with no labels, and one MetricPoint value with no Exempla
10741081

10751082
```openmetrics-add-eof
10761083
# TYPE foo gaugehistogram
1077-
foo_bucket{le="0.01"} 20.0
1078-
foo_bucket{le="0.1"} 25.0
1079-
foo_bucket{le="1"} 34.0
1080-
foo_bucket{le="10"} 34.0
1081-
foo_bucket{le="+Inf"} 42.0
1082-
foo_gcount 42.0
1083-
foo_gsum 3289.3
1084+
foo {count:42,sum:3289.3,bucket:[0.01:20,0.1:25,1:34,+Inf:42]}
10841085
```
10851086

10861087
##### GaugeHistogram with Native Buckets

0 commit comments

Comments
 (0)