diff --git a/redirects.yml b/redirects.yml index 094745877e7..c47b9ef4a2f 100644 --- a/redirects.yml +++ b/redirects.yml @@ -7,6 +7,13 @@ redirects: 'solutions/security/alertzero/requirements.md': 'solutions/security/alertzero/set-up-alertzero.md' # related to https://github.com/elastic/docs-content/pull/9304 'solutions/security/alertzero/review-first-proposed-action.md': 'solutions/security/alertzero/work-in-alertzero.md' + # The Managed OTLP Endpoint routing section moved to the dedicated Data routing page. + 'reference/managed-inputs/managed-otlp-endpoint.md': + to: 'reference/managed-inputs/managed-otlp-endpoint.md' + many: + - to: 'reference/managed-inputs/data-routing.md' + anchors: + 'routing-telemetry-to-dedicated-datasets-or-namespace': 'routing-telemetry-to-dedicated-datasets-or-namespace' # related to https://github.com/elastic/docs-content/pull/4251 'explore-analyze/visualize/supported-chart-types.md': 'explore-analyze/visualize/lens.md' # related to https://github.com/elastic/docs-content/issues/7502 diff --git a/reference/managed-inputs/authentication-delivery-and-failure-handling.md b/reference/managed-inputs/authentication-delivery-and-failure-handling.md index 87dd9a9f532..12643b025d3 100644 --- a/reference/managed-inputs/authentication-delivery-and-failure-handling.md +++ b/reference/managed-inputs/authentication-delivery-and-failure-handling.md @@ -22,7 +22,7 @@ This page covers what all managed inputs share: how you authenticate, how data i Managed inputs authenticate with an {{es}} API key that includes the `event:write` privilege for the `apm` application. The same `event:write` / `apm` privilege applies to every managed endpoint, including the OTLP, Prometheus Remote Write, and _bulk endpoints. :::{note} -Index-level privilege scoping is not supported for managed inputs. +Index-level privilege scoping is not supported for managed inputs. The same API key works for every managed input, and it grants write access to all data streams the inputs can write to. For example, through the OTLP endpoint the key can write to any data stream with a `logs-`, `metrics-`, or `traces-` prefix, and any client that holds the key can route data to any of them. If you need write access scoped to specific indices or data streams, send data to {{es}} through a self-managed Collector, such as [{{agent}} configured as an OTel Collector and deployed as a gateway](elastic-agent://reference/edot-collector/modes.md#edot-collector-as-gateway), using an API key with index-level privileges. ::: You can create this API key in one of the following ways: diff --git a/reference/managed-inputs/data-routing.md b/reference/managed-inputs/data-routing.md new file mode 100644 index 00000000000..4097a9ec47c --- /dev/null +++ b/reference/managed-inputs/data-routing.md @@ -0,0 +1,72 @@ +--- +navigation_title: Data routing +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. +applies_to: + serverless: + observability: ga + security: ga + deployment: + ech: ga +products: + - id: cloud-serverless + - id: observability + - id: edot-collector +--- + +# Data routing with the Managed OTLP Endpoint + +By default, the {{motlp}} routes each signal to a data stream based on its type and its `service.name` attribute. 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](authentication-delivery-and-failure-handling.md#authentication). +::: + +## Routing telemetry to dedicated datasets or namespace [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 {{edot-cf}} 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 [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](elastic-agent://reference/edot-collector/components/elasticsearchexporter.md#document-routing) in the {{es}} 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-default") where log.attributes["event.domain"] == "audit" +``` + +The target index name must start with the `logs-`, `metrics-`, or `traces-` prefix. As with data stream routing, data routed to other prefixes is silently dropped and doesn't appear in {{es}}. + +:::{warning} +When you route data with `elasticsearch.index`, the {{motlp}} writes it to a data stream with that name, so the target must match an index template with a data stream definition, and you are responsible for that template and its mappings. The built-in OpenTelemetry index templates that Elastic provides only cover the default data stream naming scheme, such as `logs-*.otel-*`. If another matching template exists, such as the built-in `logs-*-*` template, data is indexed with that template's mappings. If no template matches, documents fail indexing asynchronously and are silently dropped. Refer to [Indexing errors and the failure store](authentication-delivery-and-failure-handling.md#failure-store) for more information. +::: + +## Troubleshooting unexpected routing [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 is landing in an unexpected data stream, inspect a sample document from that data stream for the field `resource.attributes.data_stream.dataset`. If the field is present and matches the unexpected data stream name, the attribute was set in the payload, not by the pipeline. The `elasticsearch.index` attribute is removed from the final document, so check your collector and SDK configuration for it instead. + +To restore default routing, remove the `data_stream.dataset`, `data_stream.namespace`, and `elasticsearch.index` attributes from your OTLP payload configuration. Once removed, the {{motlp}} falls back to routing based on `service.name`. diff --git a/reference/managed-inputs/managed-otlp-endpoint.md b/reference/managed-inputs/managed-otlp-endpoint.md index 827a57267ee..41a41ba3025 100644 --- a/reference/managed-inputs/managed-otlp-endpoint.md +++ b/reference/managed-inputs/managed-otlp-endpoint.md @@ -56,41 +56,16 @@ export OTEL_EXPORTER_OTLP_ENDPOINT="https://" export OTEL_EXPORTER_OTLP_HEADERS="Authorization=ApiKey " ``` -### Routing telemetry to dedicated datasets or namespace +## Data routing -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 {{edot-cf}} 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` attributes is also honored for all signals: logs, metrics, and traces. - -:::{important} -Any `data_stream.dataset` or `data_stream.namespace` resource attribute present in an OTLP payload overrides mOTLP's default routing for that signal. This applies whether the attribute is set intentionally or by a collector, SDK, or integration. - -If data is landing in an unexpected data stream, inspect a sample document from that data stream for the field `resource.attributes.data_stream.dataset`. If the field is present and matches the unexpected data stream name, the attribute was set in the payload, not by the pipeline. - -To restore default routing, remove the `data_stream.dataset` and `data_stream.namespace` resource attributes from your OTLP payload configuration. Once removed, mOTLP falls back to routing based on `service.name`. -::: +By default, the {{motlp}} routes each signal to a data stream based on its type and its `service.name` attribute. To route telemetry to dedicated datasets or namespaces, or to a specific index, refer to [Data routing with the Managed OTLP Endpoint](data-routing.md). ## Authentication Managed inputs use a shared authentication model. Refer to [Authentication](authentication-delivery-and-failure-handling.md#authentication) for the required API key format and generation steps. :::{note} -Index-level privilege scoping is not supported for managed inputs. +Index-level privilege scoping is not supported for managed inputs. Through the {{motlp}}, the API key can write to any data stream with a `logs-`, `metrics-`, or `traces-` prefix, and any client that holds the key can route data to any of them using the [routing attributes](data-routing.md). Take this into consideration when you decide how to distribute the key. ::: ## OTLP client configuration diff --git a/reference/managed-inputs/toc.yml b/reference/managed-inputs/toc.yml index 81751c77833..42f17cd2226 100644 --- a/reference/managed-inputs/toc.yml +++ b/reference/managed-inputs/toc.yml @@ -4,6 +4,7 @@ toc: - file: rate-limiting.md - file: managed-otlp-endpoint.md children: + - file: data-routing.md - file: troubleshooting.md - file: prometheus-remote-write.md - file: elasticsearch-bulk.md