Skip to content

Commit 4c7ae2a

Browse files
committed
add links and headers. Handle exemplars and otel resource attributes.
1 parent 672fa1a commit 4c7ae2a

File tree

1 file changed

+50
-22
lines changed

1 file changed

+50
-22
lines changed

specification/metrics/datamodel.md

+50-22
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,9 @@ where all points are added, and lost points are ignored.
10221022

10231023
**Status**: [Experimental](../document-status.md)
10241024

1025-
This section denotes how to convert from Prometheus scraped metrics to the
1025+
This section denotes how to convert metrics scraped in the [Prometheus exposition](https://github.com/Showmax/prometheus-docs/blob/master/content/docs/instrumenting/exposition_formats.md#exposition-formats) or [OpenMetrics](https://openmetrics.io/) formats to the
10261026
OpenTelemetry metric data model and how to create Prometheus metrics from
1027-
OpenTelemetry metric data.
1027+
OpenTelemetry metric data. Since OpenMetrics has a superset of Prometheus' types, "Prometheus" should be taken to mean "Prometheus or OpenMetrics". "OpenMetrics" refers to OpenMetrics-only concepts.
10281028

10291029
### Prometheus Labels from Service Discovery
10301030

@@ -1044,50 +1044,68 @@ attributes when converting into OpenTelemetry.
10441044

10451045
### Prometheus Metric points to OTLP
10461046

1047-
Prometheus Counter metrics do not include the start time of the metric. When converting Prometheus Counters to OTLP, the `process_start_time_metric` may be used to provide the start time. If the start time is not provided by that mechanism, Prometheus conversion follows [Cumulative streams: handling unknown start time](#cumulative-streams-handling-unknown-start-time).
1047+
#### Counters
10481048

1049-
Prometheus Counter becomes an OTLP Sum.
1049+
[Prometheus Counter](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#counter) becomes an OTLP Sum.
10501050

1051-
Prometheus Gauge becomes an OTLP Gauge.
1051+
#### Gauges
10521052

1053-
Prometheus Unknown becomes an OTLP Gauge.
1053+
[Prometheus Gauge](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#gauge) becomes an OTLP Gauge.
10541054

1055-
Prometheus Histogram becomes an OTLP Histogram.
1055+
#### Unknown
1056+
1057+
[Prometheus Unknown](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#unknown) becomes an OTLP Gauge.
1058+
1059+
#### Histogram
1060+
1061+
[Prometheus Histogram](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram) becomes an OTLP Histogram.
10561062

10571063
Multiple Prometheus metrics are merged together into a single metric:
10581064

10591065
* The `le` label on non-suffixed metrics is used to identify histogram bucket boundaries. Each Prometheus line produces one bucket on the resulting histogram.
10601066
* Lines with `_count` and `_sum` suffixes are used to determine the histogram's count and sum.
10611067

1062-
Prometheus Summary becomes an OTLP Summary.
1068+
#### Summary
1069+
1070+
[Prometheus Summary](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#summary) becomes an OTLP Summary.
10631071

10641072
Multiple Prometheus metrics are merged together into a single metric:
10651073

10661074
* The `quantile` label on non-suffixed metrics is used to identify quantile points in summary metrics. Each Prometheus metrics produces one quantile on the resulting summary.
10671075
* Lines with `_count` and `_sum` suffixes are used to determine the summary's count and sum.
10681076

1069-
Prometheus Gauge Histogram is dropped (TBD).
1077+
#### Dropped Types
10701078

1071-
Prometheus Stateset is dropped (TBD).
1079+
* [OpenMetrics GaugeHistogram](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#gaugehistogram)
1080+
* [OpenMetrics StateSet](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#stateset)
1081+
* [OpenMetrics Info](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#info)
10721082

1073-
Prometheus Info is dropped (TBD).
1083+
#### Start Time
1084+
1085+
Prometheus Cumulative metrics do not include the start time of the metric. When converting Prometheus Counters to OTLP, the `process_start_time_metric` may be used to provide the start time. If the start time is not provided by that mechanism, Prometheus conversion follows [Cumulative streams: handling unknown start time](#cumulative-streams-handling-unknown-start-time).
1086+
1087+
#### Exemplars
1088+
1089+
[Prometheus Exemplars](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#exemplars) may be attached to Prometheus Histogram bucket metrics, which should be converted to exemplars on OpenTelemetry histograms. The Trace ID and Span ID should be retrieved from the `trace_id` and `span_id` label keys, respectively.
10741090

10751091
### OTLP Metric points to Prometheus
10761092

1093+
#### Gauges
1094+
10771095
OpenTelemetry Gauge becomes a Prometheus Gauge.
10781096

1079-
TODO: Example Gauge Conversions
1097+
#### Sums
10801098

10811099
OpenTelemetry Sum follows this logic:
10821100

10831101
- If the aggregation temporality is cumulative and the sum is monotonic,
10841102
it becomes a Prometheus Sum.
1085-
- If the aggregation temporality is delta and the sum is monotonic, it may be converted to a cumulative temporality and become a Prometheus Sum, or it may be dropped.
1103+
- If the aggregation temporality is delta and the sum is monotonic, it should be converted to a cumulative temporality and become a Prometheus Sum, or it may be dropped.
10861104
- Otherwise the Sum becomes a Prometheus Gauge.
10871105

1088-
TODO: Example Sum Conversions
1106+
#### Histograms
10891107

1090-
OpenTelemetry Histogram becomes a metric family with the following:
1108+
OpenTelemetry Histogram with a cumulative aggregation temporality becomes a metric family with the following:
10911109

10921110
- A single `{name}_count` metric denoting the count field of the histogram.
10931111
All attributes of the histogram point are converted to Prometheus labels.
@@ -1103,9 +1121,13 @@ OpenTelemetry Histogram becomes a metric family with the following:
11031121
These points will include a single exemplar that falls within `le` label and
11041122
no other `le` labelled point.
11051123

1106-
_Note: OpenTelemetry DELTA histograms are not exported to Prometheus._
1124+
OpenTelemetry Histograms with Delta aggregation temporality should be aggregated into a Cumulative aggregation temporality, or may be dropped.
11071125

1108-
TODO: Example Histogram conversion
1126+
#### Dropped Types
1127+
1128+
* ExponentialHistogram
1129+
1130+
#### Summaries
11091131

11101132
OpenTelemetry Summary becomes a metric family with the following:
11111133

@@ -1121,14 +1143,20 @@ OpenTelemetry Summary becomes a metric family with the following:
11211143
starting from lowest to highest, and all being non-negative. The value of
11221144
each point is the computed value of the quantile point.
11231145

1124-
TODO: Example Summary conversion
1146+
#### OpenTelemetry Metric Attributes
11251147

1126-
#### OpenTelemetry Attributes to Prometheus Labels
1127-
1128-
In Prometheus metric labels must match the following regex: `[a-zA-Z_:]([a-zA-Z0-9_:])*`. Metrics
1148+
OpenTelemetry Metric Attributes are converted to [Prometheus labels](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). In Prometheus, metric labels must match the following regex: `[a-zA-Z_:]([a-zA-Z0-9_:])*`. Metrics
11291149
from OpenTelemetry with unsupported Attribute names should replace invalid characters with the `_` character. This
11301150
may cause ambiguity in scenarios where multiple similar-named attributes share invalid characters at the same
1131-
location. This is considered an unsupported case, and is highly unlikely.
1151+
location. In such unlikely cases, either value may be used.
1152+
1153+
#### OpenTelemetry Exemplars
1154+
1155+
Exemplars on OpenTelemetry Histograms should be converted to Prometheus exemplars. Exemplars on other OpenTelemetry metric types are dropped. For Prometheus push exporters, multiple exemplars are permitted on each bucket, so all exemplars are converted. For Prometheus pull endpoints, only a single exemplar can be added to each bucket, so the largest exemplar from each bucket is chosen. If no exemplars exist on a bucket, the highest exemplar from a lower bucket should be used, even if it is a duplicate of another bucket. Prometheus Exemplars should use the `trace_id` and `span_id` keys for the trace and span IDs, respectively.
1156+
1157+
#### OpenTelemetry Resource Attributes
1158+
1159+
In the collector, but not in SDKs, only the `job` and `instance` resource attributes are converted to Prometheus metric labels. In all other cases, resource attributes are dropped, and are not attached to Prometheus metrics.
11321160

11331161
## Footnotes
11341162

0 commit comments

Comments
 (0)