Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve conversion of resource attributes to/from prometheus #2381

Merged
merged 10 commits into from
Mar 5, 2022
Prev Previous commit
Next Next commit
be clear on metric family vs metric point
  • Loading branch information
dashpole committed Feb 25, 2022
commit 57e947af8c41d4c2d6505f5b4849f976303d375a
19 changes: 10 additions & 9 deletions specification/metrics/datamodel.md
Original file line number Diff line number Diff line change
Expand Up @@ -1196,11 +1196,12 @@ attributes, and MUST NOT be added as metric attributes:

In addition to the attributes above, the
["target" info](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems)
metric family, if present, MUST be dropped from the batch of metrics.
Additionally, all labels from the "target" info metric MUST be converted to
resource attributes, which MUST be attached to all other metrics which are part
of the same scrape. By default, labels MUST NOT be altered (such as replacing
`_` with `.` characters in keys).
metric family is used to supply additional resource attributes. If present,
"target" info MUST be dropped from the batch of metrics, and all labels from
the "target" info metric family MUST be converted to resource attributes
attached to all other metrics which are part of the scrape. By default, label
keys and values MUST NOT be altered (such as replacing `_` with `.` characters
in keys).
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved

### OTLP Metric points to Prometheus

Expand Down Expand Up @@ -1259,7 +1260,7 @@ OpenTelemetry Metric Attributes MUST be converted to [Prometheus labels](https:/

#### Resource Attributes

In SDK Prometheus (pull) exporters, resource attributes SHOULD be converted to the ["target" info](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems) metric; otherwise, they MUST be dropped, and MUST NOT be attached as labels to other metrics. The "target" info metric MUST be an info-typed metric whose labels MUST include the resource attributes, and MUST NOT include any other labels. There MUST be at most one "target" info metric exposed on a Prometheus endpoint.
In SDK Prometheus (pull) exporters, resource attributes SHOULD be converted to the ["target" info](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems) metric family; otherwise, they MUST be dropped, and MUST NOT be attached as labels to other metric families. The "target" info metric family MUST be an info-typed metric family whose labels MUST include the resource attributes, and MUST NOT include any other labels. There MUST be at most one "target" info metric family exposed on a Prometheus endpoint.

In the Collector's Prometheus pull and push (remote-write) exporters, it is
possible for metrics from multiple targets to be sent together, so targets must
Expand All @@ -1280,12 +1281,12 @@ attributes MUST be combined as `<service.namespace>;<service.name>`, or
`instance` label; otherwise, `instance` should be added with an empty value.
Other resource attributes SHOULD be converted to a
["target" info](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems)
metric, or MUST be dropped. The "target" info metric is an info-typed metric
metric family, or MUST be dropped. The "target" info metric family is an info-typed metric family
whose labels MUST include the resource attributes, and MUST NOT include any
other labels other than `job` and `instance`. There MUST be at most one
"target" info metric exported for each unique combination of `job` and `instance`.
"target" info metric point exported for each unique combination of `job` and `instance`.

If info-typed metrics are not yet supported by the language Prometheus client library, a gauge-typed metric named "target" info with a constant value of 1 MUST be used instead.
If info-typed metric families are not yet supported by the language Prometheus client library, a gauge-typed metric family named "target" info with a constant value of 1 MUST be used instead.

To convert OTLP resource attributes to Prometheus labels, string Attribute values are converted directly to labels, and non-string Attribute values MUST be converted to string attributes following the [attribute specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/common.md#attribute).

Expand Down