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.
Metric types and their sample suffixes
| Type | Required suffixes | Optional suffixes | Use for |
|---|---|---|---|
counter | _total | _created | Monotonically increasing values (requests, errors) |
gauge | (base name) | — | Values that go up and down (memory, queue depth) |
histogram | _bucket, _sum, _count | _created | Measured distributions with configurable buckets |
summary | _sum, _count | quantile samples | Pre-aggregated quantiles (percentile latency) |
info | _info | — | Static metadata labels (build version, library) |
stateset | (base name per state) | — | Named boolean states (feature flags) |
gaugehistogram | _bucket, _gsum, _gcount | — | Histogram values that can decrease (in-flight sizes) |
unknown | (base name) | — | Unclassified; avoid in new code |
Tips and examples
A minimal valid counter 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 gauge needs no _total suffix — just the base name:
# HELP memory_used_bytes Current process memory usage.
# TYPE memory_used_bytes gauge
# UNIT memory_used_bytes bytes
memory_used_bytes 48234496 1700000000.0
# EOF
A histogram bucket with an exemplar linking to a trace:
http_latency_seconds_bucket{le="0.1"} 8 # {trace_id="abc123"} 0.067 1700000000.0
Key differences from Prometheus text format
# EOFis mandatory in OpenMetrics; the older Prometheus format has no terminator, so parsers cannot detect truncation.- Counters must use
_totalin OpenMetrics; Prometheus allows the metric name itself to be the value. # UNITis new — Prometheus has no unit metadata line.- Exemplars are native in OpenMetrics; in Prometheus they are a later experimental addition.
InfoandStateSettypes are new; Prometheus models these with gauge labels or special conventions.
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.