|
| 1 | +--- |
| 2 | +navigation_title: Custom data stream routing |
| 3 | +description: Customize data stream routing in EDOT. Learn scenarios, patterns, and risks when modifying `data_stream.namespace` or `data_stream.dataset`. |
| 4 | +applies_to: |
| 5 | + stack: |
| 6 | + serverless: |
| 7 | + observability: |
| 8 | + product: |
| 9 | + edot_collector: ga |
| 10 | +products: |
| 11 | + - id: cloud-serverless |
| 12 | + - id: observability |
| 13 | + - id: edot-collector |
| 14 | +--- |
| 15 | + |
| 16 | +# Custom data stream routing with EDOT |
| 17 | + |
| 18 | +{{edot}} (EDOT) uses opinionated defaults for data stream naming to ensure compatibility with Elastic dashboards, {{product.apm}} visualizations, and curated UIs. |
| 19 | + |
| 20 | +While most use cases rely on these defaults, EDOT also supports advanced dynamic routing. |
| 21 | + |
| 22 | +:::{important} |
| 23 | +We strongly recommend not changing the default data stream names. Customizing data stream routing diverges from the standard ingestion model and there's no guarantee it will be valid for future versions. |
| 24 | +::: |
| 25 | + |
| 26 | +## When to customize data streams |
| 27 | + |
| 28 | +The only recommended use case for customizing data stream routing is to separate data by environment (for example: dev, staging, and prod). |
| 29 | + |
| 30 | +In this case, we recommend changing only `data_stream.namespace`, not `data_stream.dataset`. |
| 31 | + |
| 32 | +## Modifying `namespace` |
| 33 | + |
| 34 | +A data stream name follows this structure: |
| 35 | + |
| 36 | +``` |
| 37 | +<type>-<dataset>-<namespace> |
| 38 | +``` |
| 39 | + |
| 40 | +The `namespace` is intended as the configurable part of the name. Elastic dashboards, detectors, and UIs support multiple namespaces automatically. |
| 41 | + |
| 42 | +## Why not modify `dataset`? |
| 43 | + |
| 44 | +Changing the `dataset` value can cause: |
| 45 | + |
| 46 | +- Dashboards and {{product.apm}} views to fail to load |
| 47 | +- Loss of compatibility with built-in correlations and cross-linking |
| 48 | +- Inconsistent field mappings |
| 49 | +- Proliferation of data streams and increased shard counts |
| 50 | + |
| 51 | +Only modify `dataset` if it's absolutely necessary and you're aware of the trade-offs. |
| 52 | + |
| 53 | +## Configuration example |
| 54 | + |
| 55 | +To enable dynamic data stream routing: |
| 56 | + |
| 57 | +1. Set `mapping.mode: otel` in the {{es}} exporter. When using `otel` mapping mode, the exporter appends `.otel` to the `data_stream.dataset` value automatically. |
| 58 | +2. Use a `resource` processor to set the desired `namespace` or `dataset` from resource attributes. |
| 59 | +3. Add the processor to your pipeline. |
| 60 | + |
| 61 | +:::{note} |
| 62 | +The example is purely illustrative, with no guarantee of it being production ready. |
| 63 | +::: |
| 64 | + |
| 65 | +```yaml |
| 66 | +exporters: |
| 67 | + elasticsearch/otel: |
| 68 | + api_key: ${env:ELASTIC_API_KEY} |
| 69 | + endpoints: [${env:ELASTIC_ENDPOINT}] |
| 70 | + mapping: |
| 71 | + mode: otel |
| 72 | + |
| 73 | +processors: |
| 74 | + resource/env-namespace: # <-- make sure you are using `resource` and not `attributes` |
| 75 | + attributes: |
| 76 | + - key: data_stream.namespace |
| 77 | + from_attribute: k8s.namespace.name |
| 78 | + action: upsert |
| 79 | + |
| 80 | +service: |
| 81 | + pipelines: |
| 82 | + metrics/otel: |
| 83 | + processors: |
| 84 | + - batch |
| 85 | + - resource/env-namespace # <-- add the processor to the pipeline |
| 86 | + exporters: |
| 87 | + - elasticsearch/otel |
| 88 | +``` |
| 89 | +
|
| 90 | +## Valid data stream names |
| 91 | +
|
| 92 | +Any dynamic value used in `data_stream.namespace` or `data_stream.dataset` must comply with {{es}} index naming rules: |
| 93 | + |
| 94 | +- Lowercase only |
| 95 | +- No spaces |
| 96 | +- Must not start with `_` |
| 97 | +- Must not contain: `"`, `\`, `*`, `,`, `<`, `>`, `|`, `?`, `/` |
| 98 | +- Avoid hyphens in environment names (use `produs` instead of `prod-us`) |
| 99 | + |
| 100 | +Invalid names prevent data stream creation. |
| 101 | + |
| 102 | +## Risks and limitations |
| 103 | + |
| 104 | +This configuration diverges from the standard ingestion model. Be aware of the following: |
| 105 | + |
| 106 | +- Future EDOT versions may not support this configuration or may introduce breaking changes. |
| 107 | +- Changes might lead to an increase in data streams and shard counts. |
| 108 | +- Dashboards and UIs may not recognize non-standard datasets. |
| 109 | +- Some data streams might fail to be created if there are non-allowed characters in the values set for `data_stream.namespace` or `data_stream.dataset`. |
| 110 | + |
| 111 | +Use this feature only when necessary and validate in non-production environments first. |
| 112 | + |
| 113 | +## Additional resources |
| 114 | + |
| 115 | +- [Data stream routing reference](docs-content://solutions/observability/apm/opentelemetry/data-stream-routing.md) |
| 116 | +- [EDOT Collector configuration examples](/reference/edot-collector/config/index.md) |
0 commit comments