Skip to content

Commit 4c7a987

Browse files
committed
Classic histogram and summary as complex types
Ref: prometheus/OpenMetrics#283 Signed-off-by: György Krajcsovits <[email protected]>
1 parent 19b2d91 commit 4c7a987

File tree

1 file changed

+52
-8
lines changed

1 file changed

+52
-8
lines changed

docs/specs/om/open_metrics_spec_2_0.md

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ This section MUST be read together with the ABNF section. In case of disagreemen
6262

6363
#### Values
6464

65-
Metric values in OpenMetrics MUST be either floating points or integers. Note that ingestors of the format MAY only support float64. The non-real values NaN, +Inf and -Inf MUST be supported. NaN MUST NOT be considered a missing value, but it MAY be used to signal a division by zero.
65+
Metric values in OpenMetrics MUST be either numbers or complex data types.
66+
67+
Numbers MUST be either floating points or integers. Note that ingestors of the format MAY only support float64. The non-real values NaN, +Inf and -Inf MUST be supported. NaN MUST NOT be considered a missing value, but it MAY be used to signal a division by zero.
68+
69+
Complex data types MUST contain all information necessary to recreate a sample of a Metric Type, with the exception of Created Value and Exemplars.
70+
71+
List of complex data types:
72+
- Integer counter classic histogram for the Metric Type Histogram.
73+
- Integer classic summary for the Metric Type Summary.
6674

6775
##### Booleans
6876

@@ -322,8 +330,11 @@ metric-type = counter / gauge / histogram / gaugehistogram / stateset
322330
metric-type =/ info / summary / unknown
323331
324332
sample = metricname [labels] SP number [SP timestamp] [exemplar] LF
333+
sample =/ metricname [labels] SP "{" complextype "}" [SP timestamp] *exemplar-ts LF
325334
326-
exemplar = SP HASH SP labels SP number [SP timestamp]
335+
exemplar = exemplar-base [SP timestamp]
336+
exemplar-ts = exemplar-base SP timestamp
337+
exemplar-base = SP HASH SP labels SP number
327338
328339
labels = "{" [label *(COMMA label)] "}"
329340
@@ -342,6 +353,9 @@ realnumber = [SIGN] 1*DIGIT
342353
realnumber =/ [SIGN] 1*DIGIT ["." *DIGIT] [ "e" [SIGN] 1*DIGIT ]
343354
realnumber =/ [SIGN] *DIGIT "." 1*DIGIT [ "e" [SIGN] 1*DIGIT ]
344355
356+
; Integer counters for complex types.
357+
; Leading 0s explicitly okay.
358+
non-negative-integer = DIGIT *DIGIT
345359
346360
; RFC 5234 is case insensitive.
347361
; Uppercase
@@ -383,6 +397,35 @@ escaped-char =/ BS normal-char
383397
384398
; Any unicode character, except newline, double quote, and backslash
385399
normal-char = %x00-09 / %x0B-21 / %x23-5B / %x5D-D7FF / %xE000-10FFFF
400+
401+
; Complex types
402+
complextype = classic-histogram / classic-summary
403+
404+
; count:12,sum:100.0,bucket:[0.1:3,05:12,+Inf:12]
405+
classic-histogram = ch-count "," ch-sum "," ch-bucket
406+
407+
; count:x where x is a real number, not +-Inf or NaN
408+
ch-count = %d99.111.117.110.116 ":" non-negative-integer
409+
; sum:x where x is a real number or +-Inf or NaN
410+
ch-sum = %d115.117.109 ":" number
411+
; bucket:[...]
412+
ch-bucket = %d98.117.99.107.101.116 ":" "[" ch-le-counts "]"
413+
ch-le-counts = ch-pos-inf-bucket / (ch-neg-inf-bucket / ch-le-bucket) *("," ch-le-bucket) "," ch-pos-inf-bucket
414+
ch-pos-inf-bucket = "+" %d73.110.102 ":" non-negative-integer
415+
ch-neg-inf-bucket = "-" %d73.110.102 ":" non-negative-integer
416+
ch-le-bucket = realnumber ":" non-negative-integer
417+
418+
; count:12.0,sum:100.0,quantile:[0.9:2.0,0.95:3.0,0.99:20.0]
419+
classic-summary = cs-count "," cs-sum "," cs-quantile
420+
421+
; count:x where x is a real number, not +-Inf or NaN
422+
cs-count = %d99.111.117.110.116 ":" non-negative-integer
423+
; sum:x where x is a real number or +-Inf or NaN
424+
cs-sum = %d115.117.109 ":" number
425+
; quantile:[...]
426+
cs-quantile = %d113.117.97.110.116.105.108.101 ":" "[" cs-q-counts "]"
427+
cs-q-counts = cs-q-count *("," cs-q-count)
428+
cs-q-count = realnumber ":" non-negative-integer
386429
```
387430

388431
#### Overall Structure
@@ -400,15 +443,16 @@ Line endings MUST be signalled with line feed (\n) and MUST NOT contain carriage
400443
An example of a complete exposition:
401444

402445
```openmetrics
446+
# TYPE acme_http_server_request_seconds histogram
447+
# UNIT acme_http_server_request_seconds seconds
448+
# HELP acme_http_server_request_seconds Latency though all of ACME's HTTP request service.
449+
acme_http_router_request_seconds{path="/api/v1",method="GET"} {count:10,sum:100.0,bucket:[0.1:2,0.5:10,+Inf:10]}
450+
acme_http_router_request_seconds{path="/api/v2",method="GET"} {count:1,sum:10.0,bucket:[0.1:1,0.5:1,+Inf:1]}
403451
# TYPE acme_http_router_request_seconds summary
404452
# UNIT acme_http_router_request_seconds seconds
405453
# 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
454+
acme_http_router_request_seconds{path="/api/v1",method="GET"} {count:10,sum:100.0,quantile:[0.95:2,0.99:20]}
455+
acme_http_router_request_seconds{path="/api/v2",method="GET"} {count:1,sum:10.0,quantile:[0.95:2,0.99:2]}
412456
# TYPE go_goroutines gauge
413457
# HELP go_goroutines Number of goroutines that currently exist.
414458
go_goroutines 69

0 commit comments

Comments
 (0)