# Index policy or Index template for Elasticsearh

**URL:** <https://discuss.elastic.co/t/index-policy-or-index-template-for-elasticsearh/272931>\
**Category:** Elasticsearch\
**Created:** [May 13, 2021, 4:03pm UTC](https://discuss.elastic.co/t/index-policy-or-index-template-for-elasticsearh/272931 "2021-05-13T16:03:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KA3AXCTAH](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@KA3AXCTAH](https://discuss.elastic.co/u/KA3AXCTAH)\
**Post date:** [May 13, 2021, 4:03pm UTC](https://discuss.elastic.co/t/index-policy-or-index-template-for-elasticsearh/272931/1 "2021-05-13T16:03:34Z")

</div>

I have elasticsearch cluster for storing logs, and i have indices like this

```auto
logs-2021.01.01
logs-2021.01.02
logs.2021.01.03 ...etc

```

so indices creates at daily basis, and i have index template for this indices

```auto
PUT _index_template/template_1
{
  "index_patterns": ["logs*"],
  "template": {
    "settings": {
      "number_of_shards": 6,
      "number_of_replicas": 1
    }

```

but I want to make sure that indexes that are older than 1 day have 0 replicas to save disk space, and indexes that are younger than 1 day remain with 1 replica (so that in case of server loss, I have data for today)

how can i do this using elasticsearch way? i think about bash script that executes by cron , which get all of the indices which older than 1 day and make 0 replica, but i don't want to use external scripts to do that Thank you for you help

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 16, 2021, 2:00pm UTC](https://discuss.elastic.co/t/index-policy-or-index-template-for-elasticsearh/272931/2 "2021-05-16T14:00:43Z")

</div>

You can use [ILM](https://www.elastic.co/guide/en/elasticsearch/reference/7.12/index-lifecycle-management.html) to do this. The [allocate action](https://www.elastic.co/guide/en/elasticsearch/reference/7.12/ilm-allocate.html) should be able to alter the number of replicas.

---

<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:** [June 13, 2021, 2:01pm UTC](https://discuss.elastic.co/t/index-policy-or-index-template-for-elasticsearh/272931/3 "2021-06-13T14:01:33Z")

</div>

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