Data routing with the Managed OTLP Endpoint
By default, the Elastic Cloud Managed OTLP Endpoint routes each signal to a data stream based on its signal type. If no routing attributes are set, telemetry is routed to the generic data streams: logs-generic.otel-default, metrics-generic.otel-default, and traces-generic.otel-default.
You can override the default routing by setting routing attributes in your OTLP payload, as described in the following sections.
Any client that holds the API key can use these attributes to write to any data stream with a logs-, metrics-, or traces- prefix. For details on the key's write scope, refer to Authentication.
You can route signals to dedicated datasets by setting the data_stream.dataset attribute on the record. This attribute is used to route the signal to the corresponding dataset.
For example, if you want to route the Elastic Cloud Forwarder logs to custom datasets, you can add the following attributes to the log records:
processors:
transform:
log_statements:
- set(log.attributes["data_stream.dataset"], "aws.cloudtrail") where log.attributes["aws.cloudtrail.event_id"] != nil
You can also set the OTEL_RESOURCE_ATTRIBUTES environment variable to set the data_stream.dataset attribute for all logs. For example:
export OTEL_RESOURCE_ATTRIBUTES="data_stream.dataset=app.orders"
The data_stream.namespace attribute is also honored for all signals: logs, metrics, and traces.
To route a signal to a specific index instead of using data stream routing, set the elasticsearch.index attribute on the record, scope, or resource. When this attribute is present, it takes precedence over the data_stream.dataset and data_stream.namespace attributes, and it is removed from the final document. For the full routing rules, refer to Document routing in the Elasticsearch exporter reference.
For example, to route specific log records to a dedicated index, you can add the attribute in a transform processor:
processors:
transform:
log_statements:
- set(log.attributes["elasticsearch.index"], "logs-audit.otel-default") where resource.attributes["service.name"] == "audit-service"
The target index name must start with the logs-, metrics-, or traces- prefix. Data routed to other prefixes is silently dropped and doesn't appear in Elasticsearch.
The Elastic Cloud Managed OTLP Endpoint writes the data to a data stream with that name, so the target must match an index template that defines a data stream. The built-in OpenTelemetry index templates only cover the default naming scheme, such as logs-*.otel-*. Other log and metric names that follow the <type>-<dataset>-<namespace> pattern fall back to the built-in logs-*-* and metrics-*-* templates, and your data is indexed with those templates' mappings. Traces have no such fallback. You are responsible for the template and mappings of any index you route to.
If no index template with a data stream definition matches the target name, the documents fail indexing after the Elastic Cloud Managed OTLP Endpoint has accepted them, and they are silently dropped. For what happens when indexing fails and how to verify your data was indexed, refer to Indexing errors and the failure store.
Any data_stream.dataset, data_stream.namespace, or elasticsearch.index attribute present in an OTLP payload overrides the default routing for that signal. This applies whether the attribute is set intentionally or by a collector, SDK, or integration.
If data lands in an unexpected data stream, check your SDK, Collector, and processor configuration for data_stream.dataset, data_stream.namespace, or elasticsearch.index attributes. These attributes are removed from the final document, so you can't tell from the stored document whether the payload set them. The top-level data_stream.dataset and data_stream.namespace fields in the document show the resolved values only.
To restore default routing, remove the data_stream.dataset, data_stream.namespace, and elasticsearch.index attributes from your OTLP payload configuration. After you remove them, the Elastic Cloud Managed OTLP Endpoint falls back to the default routing.