﻿---
title: Data routing with the Managed OTLP Endpoint
description: How the Elastic Cloud Managed OTLP Endpoint routes telemetry to data streams, and how to override the default routing with data stream attributes or the elasticsearch.index attribute.
url: https://www.elastic.co/elastic/docs-builder/docs/5112/reference/managed-inputs/data-routing
products:
  - Elastic Agent
  - Elastic Cloud Serverless
  - Elastic Documentation
  - Elastic Observability
applies_to:
  - Serverless Observability projects: Generally available
  - Serverless Security projects: Generally available
  - Elastic Cloud Hosted: Generally available
---

# 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.
<note>
  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](/elastic/docs-builder/docs/5112/reference/managed-inputs/authentication-delivery-and-failure-handling#authentication).
</note>


## Routing telemetry to dedicated datasets or namespace

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:
```yaml
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:
```bash
export OTEL_RESOURCE_ATTRIBUTES="data_stream.dataset=app.orders"
```

The `data_stream.namespace` attribute is also honored for all signals: logs, metrics, and traces.

## Routing telemetry to a specific index

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](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/5112/reference/edot-collector/components/elasticsearchexporter#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:
```yaml
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.
<warning>
  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](/elastic/docs-builder/docs/5112/reference/managed-inputs/authentication-delivery-and-failure-handling#failure-store).
</warning>


## Troubleshooting unexpected routing

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.