# Storing APM data in custom/specific indices

**URL:** <https://discuss.elastic.co/t/storing-apm-data-in-custom-specific-indices/246381>\
**Category:** Elastic Tips and Common Fixes\
**Created:** [August 26, 2020, 4:03am UTC](https://discuss.elastic.co/t/storing-apm-data-in-custom-specific-indices/246381 "2020-08-26T04:03:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [August 26, 2020, 4:03am UTC](https://discuss.elastic.co/t/storing-apm-data-in-custom-specific-indices/246381/1 "2020-08-26T04:03:14Z")

</div>

If you'd like to split your APM indices by the service, you can use the advice from [this topic](https://discuss.elastic.co/t/how-to-create-index-for-each-service/242821).

You can change the index name by setting either [output.elasticsearch.index](https://www.elastic.co/guide/en/apm/server/current/elasticsearch-output.html#index-option-es) or [output.elasticsearch.indices](https://www.elastic.co/guide/en/apm/server/current/elasticsearch-output.html#indices-option-es). These configuration variables take an index name "format string", which can reference fields the events. For your use-case, you can include `%{[service.name]}` in the format string to create an index per service.

e.g.

```auto
output.elasticsearch:
  hosts: ["http://localhost:9200"]
  indices:
   - index: "apm-%{[observer.version]}-sourcemap"
      when.contains:
        processor.event: "sourcemap"

   - index: "apm-%{[observer.version]}-onboarding-%{+yyyy.MM.dd}"
      when.contains:
        processor.event: "onboarding"

   - index: "apm-%{[observer.version]}-%{[service.name]}-error-%{+yyyy.MM.dd}"
      when.contains:
        processor.event: "error"

   - index: "apm-%{[observer.version]}-%{[service.name]}-transaction-%{+yyyy.MM.dd}"
      when.contains:
        processor.event: "transaction"

   - index: "apm-%{[observer.version]}-%{[service.name]}-span-%{+yyyy.MM.dd}"
      when.contains:
        processor.event: "span"

   - index: "apm-%{[observer.version]}-%{[service.name]}-metric-%{+yyyy.MM.dd}"
      when.contains:
        processor.event: "metric"

```

Note that the "onboarding" and "sourcemap" indices are not service-specific, hence we did not include `%{[service.name]}` in their names in this example.

---

<div class="post-metadata">

**Author:** ![Stef\_Nestor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stef_nestor/32/85483_2.png) [@Stef\_Nestor](https://discuss.elastic.co/u/Stef_Nestor)\
**Post date:** [May 19, 2021, 5:13pm UTC](https://discuss.elastic.co/t/storing-apm-data-in-custom-specific-indices/246381/2 "2021-05-19T17:13:35Z")

</div>

Thanks for writing this! As a call out for people following this outline, from the [associated doc](https://www.elastic.co/guide/en/apm/server/7.12/elasticsearch-output.html#index-option-es), note the disclaimer that this turns off the default ILM policy:

> Defining a custom `index` here will disable [_Customize index lifecycle management_](https://www.elastic.co/guide/en/apm/server/7.12/ilm.html).

This implicates a user responsibility to setup customized, self-managed ILM policies if they chose to implement this sub-configuration.

(Not a blocker in any way, but a necessary setup expectation detail 🙂 )

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 4, 2022, 8:11am UTC](https://discuss.elastic.co/t/storing-apm-data-in-custom-specific-indices/246381/3 "2022-11-04T08:11:25Z")

</div>



---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [January 26, 2023, 9:51am UTC](https://discuss.elastic.co/t/storing-apm-data-in-custom-specific-indices/246381/4 "2023-01-26T09:51:51Z")

</div>

Note this is applicable only on APM Server (legacy). For new versions and for APM Integration, the indices are actually data streams.
