Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/user-guide/ingest-data/for-observability/opentelemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ If you have not ingested any OTLP metrics before, it will automatically use the
Otherwise, it will remain the old data format with the existing table, but use the new data format for any newly created tables.

GreptimeDB pre-processes the incoming data before persisting them, including:
1. Converting the metric names(table names) and the label names to the Prometheus style(e.g: replace `.` with `_`). See [here](https://opentelemetry.io/docs/specs/otel/compatibility/prometheus_and_openmetrics/#metric-metadata-1) for details.
1. Converting the metric names(table names) and the label names to the Prometheus style(e.g: replace `.` with `_`). By default, GreptimeDB also adds Prometheus-style suffixes based on the metric unit and type. See [here](https://opentelemetry.io/docs/specs/otel/compatibility/prometheus_and_openmetrics/#metric-metadata-1) for details.

Here are some examples of the conversion:

Expand All @@ -149,6 +149,19 @@ You can set the HTTP headers to configure the pre-processing behaviors. Here are
2. `x-greptime-otlp-metric-promote-resource-attrs`: If not persisting all resource attributes, the attribute name list to be kept. Use `;` to join the name list.
3. `x-greptime-otlp-metric-ignore-resource-attrs`: If persisting all resource attributes, the attribute name list to be ignored. Use `;` to join the name list.
4. `x-greptime-otlp-metric-promote-scope-attrs`: Whether to persist the scope attributes. Default to `false`.
5. `x-greptime-otlp-metric-translation-strategy`: How to translate OTLP metric names(table names) and label names(tag columns) before persisting them. Default to `UnderscoreEscapingWithSuffixes`.

The `x-greptime-otlp-metric-translation-strategy` header accepts the following values:

| Value | Metric name behavior | Label name behavior | Original names | Translated names |
| :--- | :--- | :--- | :--- | :--- |
| `UnderscoreEscapingWithSuffixes` | Convert unsupported characters to `_`, and add Prometheus-style unit/type suffixes. | Convert unsupported characters to `_`. | Metric: `http.server.request-duration_total` (monotonic sum, unit `ms`)<br />Label: `_http.status-code` | Metric: `http_server_request_duration_milliseconds_total`<br />Label: `key_http_status_code` |
| `UnderscoreEscapingWithoutSuffixes` | Convert unsupported characters to `_`, but do not add unit/type suffixes. | Convert unsupported characters to `_`. | Metric: `http.server.request-duration_total` (monotonic sum, unit `ms`)<br />Label: `_http.status-code` | Metric: `http_server_request_duration_total`<br />Label: `key_http_status_code` |
| `NoUTF8EscapingWithSuffixes` | Keep the original metric name characters, and add Prometheus-style unit/type suffixes. | Keep the original label name characters. | Metric: `http.server.request-duration_total` (monotonic sum, unit `ms`)<br />Label: `_http.status-code` | Metric: `http.server.request-duration_milliseconds_total`<br />Label: `_http.status-code` |
| `NoTranslation` | Keep the original metric name without adding suffixes. | Keep the original label name characters. | Metric: `http.server.request-duration_total` (monotonic sum, unit `ms`)<br />Label: `_http.status-code` | Metric: `http.server.request-duration_total`<br />Label: `_http.status-code` |

The header value is case-sensitive. Invalid values are rejected with a `400 Bad Request` response.
See [OTel specs](https://opentelemetry.io/docs/specs/otel/metrics/sdk_exporters/prometheus/#translation-strategy) and [Prometheus docs](https://prometheus.io/docs/guides/opentelemetry/#utf-8) for more details.

### Data Model

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ exporter = OTLPMetricExporter(
否则,GreptimeDB 会对已经存在的表保留原有的数据模型,只有对新创建的指标表使用兼容模式写入。

GreptimeDB 会首先对数据进行预处理,包括:
1. 将指标名(表名)和标签名转换成 Prometheus 风格的命名(例如:将 `.` 替换为 `_`)。具体信息请参考[这里](https://opentelemetry.io/docs/specs/otel/compatibility/prometheus_and_openmetrics/#metric-metadata-1)
1. 将指标名(表名)和标签名转换成 Prometheus 风格的命名(例如:将 `.` 替换为 `_`)。默认情况下,GreptimeDB 还会根据指标单位和类型添加 Prometheus 风格的后缀。具体信息请参考[这里](https://opentelemetry.io/docs/specs/otel/compatibility/prometheus_and_openmetrics/#metric-metadata-1)

以下是一些转换示例:

Expand All @@ -151,6 +151,19 @@ GreptimeDB 将会直接保存它们,不会进行累计值(cumulative value
2. `x-greptime-otlp-metric-promote-resource-attrs`: 如果不保存所有 resource 资源,需要保存的资源名称列表,用 `;` 连接。
3. `x-greptime-otlp-metric-ignore-resource-attrs`: 如果保存所有的 resource 资源,需要丢弃的资源名称列表,用 `;` 连接。
4. `x-greptime-otlp-metric-promote-scope-attrs`: 是否需要保存 scope 资源。默认是 `false`。
5. `x-greptime-otlp-metric-translation-strategy`: 在保存前如何转换 OTLP 指标名(表名)和标签名(tag 列)。默认是 `UnderscoreEscapingWithSuffixes`。

`x-greptime-otlp-metric-translation-strategy` 请求头支持以下取值:

| 取值 | 指标名行为 | 标签名行为 | 原始名称 | 转换后名称 |
| :--- | :--- | :--- | :--- | :--- |
| `UnderscoreEscapingWithSuffixes` | 将不支持的字符转换为 `_`,并添加 Prometheus 风格的单位和类型后缀。 | 将不支持的字符转换为 `_`。 | 指标:`http.server.request-duration_total`(monotonic sum,单位 `ms`)<br />标签:`_http.status-code` | 指标:`http_server_request_duration_milliseconds_total`<br />标签:`key_http_status_code` |
| `UnderscoreEscapingWithoutSuffixes` | 将不支持的字符转换为 `_`,但不添加单位和类型后缀。 | 将不支持的字符转换为 `_`。 | 指标:`http.server.request-duration_total`(monotonic sum,单位 `ms`)<br />标签:`_http.status-code` | 指标:`http_server_request_duration_total`<br />标签:`key_http_status_code` |
| `NoUTF8EscapingWithSuffixes` | 保留指标名中的原始字符,并添加 Prometheus 风格的单位和类型后缀。 | 保留标签名中的原始字符。 | 指标:`http.server.request-duration_total`(monotonic sum,单位 `ms`)<br />标签:`_http.status-code` | 指标:`http.server.request-duration_milliseconds_total`<br />标签:`_http.status-code` |
| `NoTranslation` | 保留原始指标名,并且不添加后缀。 | 保留标签名中的原始字符。 | 指标:`http.server.request-duration_total`(monotonic sum,单位 `ms`)<br />标签:`_http.status-code` | 指标:`http.server.request-duration_total`<br />标签:`_http.status-code` |

请求头取值区分大小写。无效取值会被拒绝,并返回 `400 Bad Request`。
更多信息请参考 [OTel 规范](https://opentelemetry.io/docs/specs/otel/metrics/sdk_exporters/prometheus/#translation-strategy)和 [Prometheus 文档](https://prometheus.io/docs/guides/opentelemetry/#utf-8)。

### 数据模型

Expand Down
Loading