|
| 1 | +--- |
| 2 | +navigation_title: "Ingest OTLP metrics" |
| 3 | +applies_to: |
| 4 | + stack: preview 9.2 |
| 5 | + serverless: preview |
| 6 | +products: |
| 7 | + - id: elasticsearch |
| 8 | +--- |
| 9 | + |
| 10 | +# Ingest metrics via the OpenTelemetry Protocol (OTLP) |
| 11 | + |
| 12 | +In addition to the ingestion of metrics data via the bulk API, |
| 13 | +{{es}} offers an alternative way to ingest data via the [OpenTelemetry Protocol (OTLP)](https://opentelemetry.io/docs/specs/otlp). |
| 14 | + |
| 15 | +The endpoint is available under `/_otlp/v1/metrics`. |
| 16 | + |
| 17 | +Ingesting metrics data via this endpoint has the following advantages: |
| 18 | +* Improved ingestion performance, especially if the data contains many resource attributes. |
| 19 | +* Simplified index mapping: |
| 20 | + there's no need to manually create an index template, or define dimensions and metrics. |
| 21 | + Using the OTLP endpoint, metrics are dynamically mapped using the metadata included in the OTLP requests. |
| 22 | + |
| 23 | +## How to send data to the OTLP endpoint |
| 24 | + |
| 25 | +To send data from an OpenTelemetry collector to the {{es}} OTLP endpoint, |
| 26 | +use the [`OTLP/HTTP` exporter](https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlphttpexporter). |
| 27 | +This is an example configuration: |
| 28 | + |
| 29 | +```yaml |
| 30 | +extensions: |
| 31 | + basicauth/elasticsearch: |
| 32 | + client_auth: |
| 33 | + username: <user> |
| 34 | + password: <password> |
| 35 | +exporters: |
| 36 | + otlphttp/elasticsearch: |
| 37 | + endpoint: <es_endpoint>/_otlp |
| 38 | + sending_queue: |
| 39 | + enabled: true |
| 40 | + sizer: requests |
| 41 | + queue_size: 5000 |
| 42 | + block_on_overflow: true |
| 43 | + batch: |
| 44 | + flush_timeout: 5s |
| 45 | + sizer: bytes |
| 46 | + min_size: 2_000_000 |
| 47 | + max_size: 5_000_000 |
| 48 | + auth: |
| 49 | + authenticator: basicauth/elasticsearch |
| 50 | +``` |
| 51 | +Note that at this point, only `encoding: proto` is supported, |
| 52 | +which the `OTLP/HTTP` exporter uses by default. |
| 53 | + |
| 54 | +The supported options for `compression` are `gzip` (default value of the `OTLP/HTTP` exporter) and `none`. |
| 55 | + |
| 56 | +[//]: # (TODO we might actually also support snappy and zstd, test and update accordingly) |
| 57 | + |
| 58 | +To track metrics in your custom application, |
| 59 | +use the [OpenTelemetry language SDK](https://opentelemetry.io/docs/getting-started/dev/) of your choice. |
| 60 | + |
| 61 | +## When not to use the {{es}} OTLP endpoint |
| 62 | + |
| 63 | +On Elastic Cloud, use the [Elastic Cloud Managed OTLP Endpoint](opentelemetry::/reference/motlp.md) instead of connecting directly to the Elasticsearch OTLP endpoint. |
| 64 | + |
| 65 | +It's not recommended to send metrics from applications directly to the Elasticsearch OTLP endpoint, |
| 66 | +especially if there are many individual applications that each periodically send a small amount of metrics. |
| 67 | +Instead, send data to an OpenTelemetry collector first. |
| 68 | +This helps with handling many connections, |
| 69 | +and with creating bigger batches to improve ingestion performance. |
| 70 | +For more details on the recommended way to set up OpenTelemetry-based data ingestion, |
| 71 | +have a look at the [EDOT reference architecture](opentelemetry::/reference/architecture/index.md). |
| 72 | + |
| 73 | +At this point, {{es}} only supports the OTLP metrics endpoint (`/_otlp/v1/metrics`). |
| 74 | +Other signals, are not supported as a native {{es}} OTLP endpoint at the moment. |
| 75 | +To ingest other signals, |
| 76 | +such as logs, traces, and profiles, |
| 77 | +use a distribution of the OpenTelemetry collector that includes the [Elasticsearch exporter](opentelemetry::/reference/edot-collector/components/elasticsearchexporter.md), |
| 78 | +such as the [Elastic distribution of OpenTelemetry (EDOT) Collector](opentelemetry::/reference/edot-collector/index.md). |
| 79 | + |
| 80 | +## Send data to different data streams |
| 81 | + |
| 82 | +By default, metrics are ingested into the `metrics-generic.otel-default` data stream. |
| 83 | +You can influence the target data stream by setting specific attributes on your data: |
| 84 | + |
| 85 | +- `data_stream.dataset` or `data_stream.namespace` in attributes, with the following order of precedence: data point attribute -> scope attribute -> resource attribute |
| 86 | +- Otherwise, if the scope name contains `/receiver/<somereceiver>`, `data_stream.dataset` is set to the receiver name. |
| 87 | +- Otherwise, `data_stream.dataset` falls back to `generic` and `data_stream.namespace` falls back to `default`. |
| 88 | + |
| 89 | +The target data stream name is constructed as `metrics-${data_stream.dataset}.otel-${data_stream.namespace}`. |
| 90 | + |
| 91 | +## Mapping hints |
| 92 | + |
| 93 | +## Limitations |
| 94 | + |
| 95 | +* Histograms are only supported in delta temporality. |
| 96 | + Set the temporality preference to delta in your SDKs, |
| 97 | + or use the [`cumulativetodelta` processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/cumulativetodeltaprocessor) to avoid cumulative histograms to be dropped. |
| 98 | +* Exemplars are not supported. |
0 commit comments