Skip to content

Commit bca1e8b

Browse files
committed
OM2.0: Add info and examples for UTF-8
Signed-off-by: Owen Williams <[email protected]>
1 parent 3a44f48 commit bca1e8b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/specs/om/open_metrics_spec_2_0.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,29 @@ go_goroutines 69
439439
# UNIT process_cpu_seconds seconds
440440
# HELP process_cpu_seconds Total user and system CPU time spent in seconds.
441441
process_cpu_seconds_total 4.20072246e+06
442+
# TYPE "foodb.read.errors" counter
443+
# HELP "foodb.read.errors" The number of errors in the read path for fooDb.
444+
{"foodb.read.errors", "service.name"="my_service"} 3482
445+
# EOF
446+
```
447+
448+
##### UTF-8 Quoting
449+
450+
Metric and label names not conforming to the ABNF definition of `metricname` MUST be enclosed in double quotes and the alternative UTF-8 syntax MUST be used.
451+
Quoting and the alternative metric name syntax MAY be used for any metric name, regardless of whether the name conforms to `metricname` or not.
452+
The metric names MUST be enclosed in double quotes in TYPE, UNIT, and HELP lines. The metric name MUST be moved inside the brackets without an operator, in accordance with the ABNF.
453+
Label names not conforming to the `label-name` ABNF definition MUST be enclosed in double quotes. Any label name MAY be enclosed in double quotes.
454+
455+
Complete example:
456+
457+
```openmetrics
458+
# TYPE "process.cpu.seconds" counter
459+
# UNIT "process.cpu.seconds" seconds
460+
# HELP "process.cpu.seconds" Total user and system CPU time spent in seconds.
461+
{"process.cpu.seconds", "node.name"="my_node"} 4.20072246e+06
462+
# TYPE "quoting_example" gauge
463+
# HELP "quoting_example" Number of goroutines that currently exist.
464+
{"quoting_example", "foo"="bar"} 4.5
442465
# EOF
443466
```
444467

@@ -538,6 +561,8 @@ The value of a UNIT or HELP line MAY be empty. This MUST be treated as if no met
538561
# HELP foo_seconds Some text and \n some \" escaping
539562
```
540563

564+
See the UTF-8 Quoting section for circumstances where the metric name MUST be enclosed in double quotes.
565+
541566
There MUST NOT be more than one of each type of metadata line for a MetricFamily. The ordering SHOULD be TYPE, UNIT, HELP.
542567

543568
Aside from this metadata and the EOF line at the end of the message, you MUST NOT expose lines beginning with a #.
@@ -566,6 +591,13 @@ Label values MAY be any valid UTF-8 value, so escaping MUST be applied as per th
566591
bar_seconds_count{a="x",b="escaping\" example \n "} 0
567592
```
568593

594+
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.
595+
See the UTF-8 Quoting section for specifics.
596+
597+
```openmetrics-add-eof
598+
{ "\"bar\".seconds.count", "b\\"="escaping\" example \n "} 0
599+
```
600+
569601
The rendering of values for a MetricPoint can include additional labels (e.g. the "le" label for a Histogram type), which MUST be rendered in the same way as a Metric's own LabelSet.
570602

571603
#### MetricPoint

0 commit comments

Comments
 (0)