You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: specification/metrics/datamodel.md
+50-22
Original file line number
Diff line number
Diff line change
@@ -1022,9 +1022,9 @@ where all points are added, and lost points are ignored.
1022
1022
1023
1023
**Status**: [Experimental](../document-status.md)
1024
1024
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
1026
1026
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.
1028
1028
1029
1029
### Prometheus Labels from Service Discovery
1030
1030
@@ -1044,50 +1044,68 @@ attributes when converting into OpenTelemetry.
1044
1044
1045
1045
### Prometheus Metric points to OTLP
1046
1046
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
1048
1048
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.
1050
1050
1051
-
Prometheus Gauge becomes an OTLP Gauge.
1051
+
#### Gauges
1052
1052
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.
1054
1054
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.
1056
1062
1057
1063
Multiple Prometheus metrics are merged together into a single metric:
1058
1064
1059
1065
* The `le` label on non-suffixed metrics is used to identify histogram bucket boundaries. Each Prometheus line produces one bucket on the resulting histogram.
1060
1066
* Lines with `_count` and `_sum` suffixes are used to determine the histogram's count and sum.
1061
1067
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.
1063
1071
1064
1072
Multiple Prometheus metrics are merged together into a single metric:
1065
1073
1066
1074
* 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.
1067
1075
* Lines with `_count` and `_sum` suffixes are used to determine the summary's count and sum.
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.
1074
1090
1075
1091
### OTLP Metric points to Prometheus
1076
1092
1093
+
#### Gauges
1094
+
1077
1095
OpenTelemetry Gauge becomes a Prometheus Gauge.
1078
1096
1079
-
TODO: Example Gauge Conversions
1097
+
#### Sums
1080
1098
1081
1099
OpenTelemetry Sum follows this logic:
1082
1100
1083
1101
- If the aggregation temporality is cumulative and the sum is monotonic,
1084
1102
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.
1086
1104
- Otherwise the Sum becomes a Prometheus Gauge.
1087
1105
1088
-
TODO: Example Sum Conversions
1106
+
#### Histograms
1089
1107
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:
1091
1109
1092
1110
- A single `{name}_count` metric denoting the count field of the histogram.
1093
1111
All attributes of the histogram point are converted to Prometheus labels.
@@ -1103,9 +1121,13 @@ OpenTelemetry Histogram becomes a metric family with the following:
1103
1121
These points will include a single exemplar that falls within `le` label and
1104
1122
no other `le` labelled point.
1105
1123
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.
1107
1125
1108
-
TODO: Example Histogram conversion
1126
+
#### Dropped Types
1127
+
1128
+
* ExponentialHistogram
1129
+
1130
+
#### Summaries
1109
1131
1110
1132
OpenTelemetry Summary becomes a metric family with the following:
1111
1133
@@ -1121,14 +1143,20 @@ OpenTelemetry Summary becomes a metric family with the following:
1121
1143
starting from lowest to highest, and all being non-negative. The value of
1122
1144
each point is the computed value of the quantile point.
1123
1145
1124
-
TODO: Example Summary conversion
1146
+
#### OpenTelemetry Metric Attributes
1125
1147
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
1129
1149
from OpenTelemetry with unsupported Attribute names should replace invalid characters with the `_` character. This
1130
1150
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.
0 commit comments