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