# Add life cycle policy on metricbeat indices

**URL:** <https://discuss.elastic.co/t/add-life-cycle-policy-on-metricbeat-indices/313905>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [September 7, 2022, 3:59pm UTC](https://discuss.elastic.co/t/add-life-cycle-policy-on-metricbeat-indices/313905 "2022-09-07T15:59:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Idan\_Ahal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/idan_ahal/32/105421_2.png) [@Idan\_Ahal](https://discuss.elastic.co/u/Idan_Ahal)\
**Post date:** [September 7, 2022, 3:59pm UTC](https://discuss.elastic.co/t/add-life-cycle-policy-on-metricbeat-indices/313905/1 "2022-09-07T15:59:47Z")

</div>

I'm trying to add a life cycle policy to my indices through Kibana. I created an index template and a lifecycle policy but I get this error: `setting [index.lifecycle.rollover_alias] for index [jobmetrics-preprod-2022.09.01] is empty or not defined`  
Why is that and why do I need to configure an alias for that?  
This is the metricbeat.yml ({{}} - We replace depending on the environment).

```auto
logging.level: error
cloud.id: {{ elastic.cloud.id }}
cloud.auth: {{ elastic.cloud.auth }}
fields:
  class: {{ ec2InstanceClass }}
output.elasticsearch:
    allow_older_versions: true
    indices:
        - index: "jobmetrics-{{ hostenv }}-%{+yyyy.MM.dd}"
setup.template:
    name: "jobmetrics-{{ hostenv }}"
    pattern: "jobmetrics-{{ hostenv }}-*"
    enabled: true
    settings:
      index.number_of_shards: 1
setup.ilm.enabled: false

```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 7, 2022, 10:37pm UTC](https://discuss.elastic.co/t/add-life-cycle-policy-on-metricbeat-indices/313905/2 "2022-09-07T22:37:22Z")

</div>

Does [Troubleshooting index lifecycle management errors | Elasticsearch Guide [8.4] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-error-handling.html#_setting_index_lifecycle_rollover_alias_for_index_y_is_empty_or_not_defined) help?

---

<div class="post-metadata">

**Author:** ![Idan\_Ahal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/idan_ahal/32/105421_2.png) [@Idan\_Ahal](https://discuss.elastic.co/u/Idan_Ahal)\
**Post date:** [September 9, 2022, 12:55pm UTC](https://discuss.elastic.co/t/add-life-cycle-policy-on-metricbeat-indices/313905/3 "2022-09-09T12:55:36Z")

</div>

I think it's because I'm using the `setup.template` option. I think I can't use lifecycle management with it. I'm not sure.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 9, 2022, 2:29pm UTC](https://discuss.elastic.co/t/add-life-cycle-policy-on-metricbeat-indices/313905/4 "2022-09-09T14:29:49Z")

</div>

perhaps take a look at, it is for filebeat but hold true for metricbeat as well.  
In short if you have already created a template in elasticsearch set and want to set your own index name

`setup.template.enabled: false`

> [@Filebeat writing to its own index](https://discuss.elastic.co/t/filebeat-writing-to-its-own-index/310842/28):
>
> As explained in the post I linked, You have a moduled enabled in your configuration whether it is important now or not... It overrides the output settings in some cases but let's put that aside there are other issues... Also from the docs [here](https://www.elastic.co/guide/en/beats/filebeat/7.12/elasticsearch-output.html#index-option-es)... which is your key issue... When [index lifecycle management (ILM)](https://www.elastic.co/guide/en/beats/filebeat/7.12/ilm.html) is enabled, the default index is "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}-%{index\_num}" , for example, "filebeat-7.12.1-2022-07-28-000001" . Custom index settings are ignored when…

---

<div class="post-metadata">

**Author:** ![Idan\_Ahal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/idan_ahal/32/105421_2.png) [@Idan\_Ahal](https://discuss.elastic.co/u/Idan_Ahal)\
**Post date:** [September 11, 2022, 10:53am UTC](https://discuss.elastic.co/t/add-life-cycle-policy-on-metricbeat-indices/313905/5 "2022-09-11T10:53:45Z")

</div>

Maybe I just need to add "-%{index\_num}" to my template? Because I now get error saying something like, I need numbers in the end of the name

---

<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:** [October 9, 2022, 12:54pm UTC](https://discuss.elastic.co/t/add-life-cycle-policy-on-metricbeat-indices/313905/6 "2022-10-09T12:54:18Z")

</div>

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