OpenMetrics Exposition Format

OpenMetrics text format keywords, type lines and label syntax reference.

Reference for the OpenMetrics text exposition format including TYPE, HELP, UNIT lines, metric suffixes, label syntax and the EOF terminator. Understand the standard that succeeds Prometheus text format.

How does OpenMetrics differ from the Prometheus text format?

OpenMetrics is a standardized superset based on the Prometheus text format. Key additions are the mandatory # EOF terminator, a # UNIT metadata line, the _total suffix requirement for counters, and native support for exemplars and the Info and StateSet metric types.

OpenMetrics exposition format reference

OpenMetrics is the IETF-track standard for exposing metrics as text, evolved from the Prometheus exposition format. A scrape endpoint returns a plain-text body of metadata lines (# HELP, # TYPE, # UNIT), sample lines, and a mandatory # EOF terminator. This reference lists every keyword and syntax element so you can read or generate a valid exposition.

Filter the elements below by keyword to find the exact line syntax and rules.

How it works

An OpenMetrics document is a sequence of metric families. Each family begins with optional metadata lines: # HELP name text (a description), # TYPE name type (one of counter, gauge, histogram, summary, info, stateset, gaugehistogram, unknown), and # UNIT name unit (the base unit, which must match the metric-name suffix).

Sample lines follow the form metric_name{label="value",...} value [timestamp] [# exemplar]. Counters expose their value with a required _total suffix and may add _created. Histograms expose _bucket{le="..."}, _sum, and _count. Strings in label values are escaped for \, ", and newline. The whole payload ends with a line containing exactly # EOF; a parser treats its absence as truncation. The HTTP Content-Type is application/openmetrics-text; version=1.0.0; charset=utf-8.

Tips and examples

A minimal valid exposition:

# HELP http_requests Total HTTP requests.
# TYPE http_requests counter
# UNIT http_requests requests
http_requests_total{method="GET",code="200"} 1027 1700000000.0
http_requests_created{method="GET",code="200"} 1699990000.0
# EOF

A histogram bucket with an exemplar pointing to a trace:

http_latency_seconds_bucket{le="0.1"} 8 # {trace_id="abc123"} 0.067 1700000000.0

Always terminate with # EOF, keep the _total suffix on counters, and ensure the declared # UNIT matches the name suffix or strict parsers will reject the payload.