Skip to content

Commit 70aa8d3

Browse files
committed
om2: MetricFamilyName is MetricName
Fixes prometheus/OpenMetrics#305 Signed-off-by: bwplotka <bwplotka@gmail.com>
1 parent c823cbd commit 70aa8d3

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

docs/specs/om/open_metrics_spec_2_0.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ CompositeValue MUST contain all information necessary to recreate a sample value
8787
The following Metric Types MUST use CompositeValue for Metric Values:
8888

8989
* [Histogram](#histogram) MetricFamily Type.
90-
* [GaugeHistogram](#gauge-histogram) MetricFamily Type.
90+
* [GaugeHistogram](#gaugehistogram) MetricFamily Type.
9191
* [Summary](#summary) MetricFamily Type.
9292

9393
Other Metric Types MUST use Numbers.
@@ -146,27 +146,34 @@ A MetricFamily MAY have zero or more Metrics. A MetricFamily MUST have a name, H
146146

147147
##### Name
148148

149-
MetricFamily names are a string and MUST be unique within a MetricSet. Names SHOULD be in snake_case. Names SHOULD follow the restrictions in the ABNF section under `metricname`. Metric names MAY be any quoted and escaped UTF-8 string as described in the ABNF section. Be aware that exposing UTF-8 metrics is still experimental and may reduce usability, especially when suffixes are not included.
149+
MetricFamily name:
150+
151+
* MUST be string.
152+
* MUST be unique within a MetricSet.
153+
* MUST be the same as every MetricPoint's MetricName in the family.
154+
155+
> NOTE: [OpenMetrics 1.0](https://prometheus.io/docs/specs/om/open_metrics_spec/#suffixes) required mandatory suffixes
156+
> for MetricName and matching MetricFamily names without such suffixes. To improve parser reliability (i.e. matching
157+
> [MetricFamily metadata](#metricfamily-metadata)) and future compatibility, this specification requires MetricFamily name to strictly match MetricNames
158+
> in the same family.
159+
160+
Names SHOULD be in snake_case. Names SHOULD follow the restrictions in the ABNF section under `metricname`. Metric names MAY be any quoted and escaped UTF-8 string as described in the ABNF section. Be aware that exposing UTF-8 metrics may reduce usability, especially when `_total` or unit suffixes are not included in the names.
150161

151162
Colons in MetricFamily names are RESERVED to signal that the MetricFamily is the result of a calculation or aggregation of a general purpose monitoring system.
152163

153164
MetricFamily names beginning with underscores are RESERVED and MUST NOT be used unless specified by this standard.
154165

155-
###### Suffixes
166+
###### Reserved Suffixes
156167

157-
The name of a MetricFamily MUST NOT result in a potential clash for sample metric names as per the ABNF with another MetricFamily in the Text Format within a MetricSet. An example would be a gauge called "foo_total" as a counter called "foo" could create a "foo_total" in the text format.
168+
MetricFamily name SHOULD NOT end with `_count`, `_sum`, `_gcount`, `_gsum`, `_bucket`. Specifically name MUST NOT create
169+
MetricName collision when converted to [the Text OpenMetrics 1.0](https://prometheus.io/docs/specs/om/open_metrics_spec).
158170

159-
Exposers SHOULD avoid names that could be confused with the suffixes that text format sample metric names use.
171+
A non-compliant example would be a gauge called `foo_bucket` and a histogram called `foo`. Exposers negotiating the older
172+
OpenMetrics or Text formats, or ingestors which support only the older data model could end up storing `foo` histogram
173+
in a classic representation (`foo_bucket`, `foo_count`, `foo_sum`) causing clash with the gauge and scrape rejection or dropped data.
160174

161-
* Suffixes for the respective types are:
162-
* Counter: `_total`
163-
* Summary: `_count`, `_sum`, `` (empty)
164-
* Histogram: `_count`, `_sum`, `_bucket`
165-
* GaugeHistogram: `_gcount`, `_gsum`, `_bucket`
166-
* Info: `_info`
167-
* Gauge: `` (empty)
168-
* StateSet: `` (empty)
169-
* Unknown: `` (empty)
175+
> This rule is because this specification is following a shift in Prometheus ecosystem towards [composite values](#compositevalues) instead of [the "classic" representation](https://prometheus.io/docs/specs/om/open_metrics_spec/#histogram-1). However, this transformation will take time.
176+
> Reserving suffixes improves compatibility with older ingestors and the eventual migration process.
170177
171178
##### Type
172179

0 commit comments

Comments
 (0)