# Dynamic index name with ILM

**URL:** <https://discuss.elastic.co/t/dynamic-index-name-with-ilm/280563>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [August 5, 2021, 4:48pm UTC](https://discuss.elastic.co/t/dynamic-index-name-with-ilm/280563 "2021-08-05T16:48:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DoctorRobot](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@DoctorRobot](https://discuss.elastic.co/u/DoctorRobot)\
**Post date:** [August 5, 2021, 4:48pm UTC](https://discuss.elastic.co/t/dynamic-index-name-with-ilm/280563/1 "2021-08-05T16:48:24Z")

</div>

Hi,

I currently have this setup which works fine:

```auto
---
apiVersion: beat.k8s.elastic.co/v1beta1
kind: Beat
metadata:
  name: filebeat
  namespace: elasticsearch
...
setup:
  ilm:
    enabled: false
  template:
    name: filebeat
    pattern: 'filebeat-*'
output.elasticsearch:
  index: "filebeat-%{[agent.version]}-%{[kubernetes.container.name]:default}-%{+yyyy.MM.dd}"

```

My problem is: I want to have different ILM depending on the container\_name.

I basically want the container1 index to keep logs for 1 day and the rest (containerX) for 30 days. How can I achieve this? I didn't find this kind of use cases on the forum or in the docs.

Should it be all setup in the interface? I'm not even sure ILM supports it.

---

<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:** [September 2, 2021, 6:48pm UTC](https://discuss.elastic.co/t/dynamic-index-name-with-ilm/280563/2 "2021-09-02T18:48:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
