# Seperate the apm indecies per service

**URL:** <https://discuss.elastic.co/t/seperate-the-apm-indecies-per-service/376746>\
**Category:** APM\
**Tags:** java\
**Created:** [April 3, 2025, 1:46pm UTC](https://discuss.elastic.co/t/seperate-the-apm-indecies-per-service/376746 "2025-04-03T13:46:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![questionpls](https://avatars.discourse-cdn.com/v4/letter/q/e36b37/32.png) [@questionpls](https://discuss.elastic.co/u/questionpls)\
**Post date:** [April 3, 2025, 1:46pm UTC](https://discuss.elastic.co/t/seperate-the-apm-indecies-per-service/376746/1 "2025-04-03T13:46:59Z")

</div>

**Kibana version** :  
v 8.17.3

**Elasticsearch version** :

**APM Server version** :  
apm-server/stable,now 8.17.3 amd64

**APM Agent language and version** :  
1.52.2

I'm not sure if this is the correct place to ask but I prompted chatgpt long enough to not figure it out so I've basically exhausted all other resources.

The logic for my configuration is as follows:

1. I have an apm server set up which follows the default configuration.
2. Multiple apm agents on different hosts are sending data to this server.
3. It works fine but the indexes are placed together, which I don't want.
4. I want to be able to separate the indexes according to the service name.
5. How do I achieve this?

When I try adding something like this to the end of the apm-server.yaml configuration it doesn't work

```yaml
output.elasticsearch:
  hosts: ["https://elasticsearch:9200"]
  indices:
    - index: "apm-{service.name}-%{[processor.event]}-%{+yyyy.MM.dd}"
      when.contains:
        service.name: "my-service"
    - index: "apm-{service.name}-%{[processor.event]}-%{+yyyy.MM.dd}"
      when.contains:
        service.name: "other-service-name"

```

It gives me a log such as this.

```json
{
   "function":"github.com/elastic/apm-server/internal/beater/api.apmMiddleware.LogMiddleware.func1.1",
   "file.name":"middleware/log_middleware.go",
   "file.line":62,
   "message":"request accepted",
   "service.name":"apm-server",
   "url.original":"/intake/v2/events",
   "http.request.method":"POST",
   "user_agent.original":"apm-agent-java/1.52.2 (xxxxxx 2025.12.0.02)",
   "source.address":"x.x.x.x",
   "http.request.id":"f45432d8-bd0d-45fc- b4c5-3f6cc6983266",
   "event.duration":10016348694,
   "http.request.body.bytes":8056,
   "http.response.status_code":202,
   "ecs.version":"1.6.0"
}

```

This is my properties file

```properties
service_name=my-service
application_packages=com.x.x
server_url=http://elastic-server-ip:8200

```

As you can see the service.name I've set in my configuration isn't even used  
but If I remove part I specified above from the apm-server.yaml then it uses the service.name
