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. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

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.

Metric types and their sample suffixes

TypeRequired suffixesOptional suffixesUse for
counter_total_createdMonotonically increasing values (requests, errors)
gauge(base name)Values that go up and down (memory, queue depth)
histogram_bucket, _sum, _count_createdMeasured distributions with configurable buckets
summary_sum, _countquantile samplesPre-aggregated quantiles (percentile latency)
info_infoStatic metadata labels (build version, library)
stateset(base name per state)Named boolean states (feature flags)
gaugehistogram_bucket, _gsum, _gcountHistogram 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

  • # EOF is mandatory in OpenMetrics; the older Prometheus format has no terminator, so parsers cannot detect truncation.
  • Counters must use _total in OpenMetrics; Prometheus allows the metric name itself to be the value.
  • # UNIT is new — Prometheus has no unit metadata line.
  • Exemplars are native in OpenMetrics; in Prometheus they are a later experimental addition.
  • Info and StateSet types 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.