# Indexing Traces into Separate Indices Based on Application Names or environment

**URL:** <https://discuss.elastic.co/t/indexing-traces-into-separate-indices-based-on-application-names-or-environment/363287>\
**Category:** APM\
**Tags:** open-telemetry\
**Created:** [July 17, 2024, 2:36pm UTC](https://discuss.elastic.co/t/indexing-traces-into-separate-indices-based-on-application-names-or-environment/363287 "2024-07-17T14:36:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramdas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdas/32/110363_2.png) [@ramdas](https://discuss.elastic.co/u/ramdas)\
**Post date:** [July 17, 2024, 2:36pm UTC](https://discuss.elastic.co/t/indexing-traces-into-separate-indices-based-on-application-names-or-environment/363287/1 "2024-07-17T14:36:01Z")

</div>

Hi @axw @felixbarny

I followed this issue for a month now and i also read following threads  
[https://www.elastic.co/guide/en/observability/current/apm-data-streams.html](https://github.com/elastic/apm-server/issues/url)  
[https://github.com/elastic/apm-data/pull/201](https://github.com/elastic/apm-server/issues/url)

from this what i understand is i can either use reroute processor on custom ingest pipeline to use service.namespace or data\_stream.dataset or data\_stream.namespace to segregate traces.

however another elastic forum post says from version 8.13 it will happen automatically if i have data\_stream.dataset and data\_stream.namespace defined in opentelemetry collector resource attributes, So i upgrade our test environment to 8.13 version but i do not see traces being seperately indexes to different data streams.  
[[https://discuss.elastic.co/t/indexing-application-trace-data-into-separate-indices-based-on-application-names/353437](https://github.com/elastic/apm-server/issues/url)](url)

also the attributes data\_stream.dataset and data\_stream.namespace i passed from opentelemetry collector were getting added through collector and apm server. however traces are going to traces-apm-default index (not datastream) and data\_stream.dataset and data\_stream.namespace get renamed to labels.data\_stream\_dataset and labels.data\_stream\_namespace.

> {  
> "\_index": "traces-apm-default",  
> "\_id": "jbAQwZABcWl2AwZkmZ77",  
> "\_version": 1,  
> "\_score": 0,  
> "\_source": {  
> "[@timestamp](https://github.com/timestamp)": "2024-07-17T14:20:05.966Z",  
> "agent": {  
> "name": "otlp",  
> "version": "unknown"  
> },  
> "data\_stream": {  
> "dataset": "apm",  
> "namespace": "default",  
> "type": "traces"  
> },  
> "event": {  
> "duration": 6600,  
> "outcome": "success"  
> },  
> "labels": {  
> "Min": "40",  
> "Max": "288",  
> "Name": "4.2.0",  
> "Current": "40",  
> **"data\_stream\_dataset": "eastus",**  
> "plan\_id": "669028d75ab8ff7cf71bf98f",  
> "site": "eastus",  
> "plan\_name": "df-rel-01",  
> **"data\_stream\_namespace": "eastus"**  
> },  
> "observer": {  
> "hostname": "elastic-apm-765c57ffdf-9ml55",  
> "type": "apm-server",  
> "version": "8.12.0"  
> },  
> "service": {  
> "framework": {  
> "name": "DI"  
> },  
> "language": {  
> "name": "unknown"  
> },  
> "name": "DI Server",  
> "node": {  
> "name": "43a024dc-cfd9-4fa4-844c-af19bfdfbe0c"  
> }  
> },  
> "span": {  
> "id": "44b3f17f4b7da1a0"  
> },  
> "timestamp": {  
> "us": 1721226005966615  
> },  
> "trace": {  
> "id": "553ca8a5033f4a8f86e809b6a05cb744"  
> },  
> "transaction": {  
> "id": "44b3f17f4b7da1a0",  
> "name": "RequestInspection",  
> "representative\_count": 1,  
> "result": "Success",  
> "sampled": true,  
> "type": "unknown"  
> }  
> }

i also tried to create new apm integration to add namespace i am expecting and also created custom ingest pipeline with following specs but that did not help.

> {  
> "reroute": {  
> "dataset": [  
> "{{data\_stream.dataset}}"  
> ],  
> "namespace": [  
> "{{data\_stream.namespace}}"  
> ]  
> }

i will appreciate if you can help me here to fix it?

**Kibana version** : 8.13

**Elasticsearch version** : 8.13

**APM Server version** : 8.13

**APM Agent language and version** : Opentelemetry collector contrib 0.82.0

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: Deployed on Kubernetes - AKS

**Fresh install or upgraded from other version?** : Fresh

**Steps to reproduce** :

1. Launch OTEL Application, set env variable OTEL\_RESOURCE\_ATTRIBUTES
2. Configure to ship to APM Server
3. Everything goes to the same datastream
