# How to apply ilm policy to index patter tenat-\*

**URL:** https://discuss.elastic.co/t/how-to-apply-ilm-policy-to-index-patter-tenat/328428
**Category:** Elasticsearch
**Created:** [March 24, 2023, 7:21am UTC](https://discuss.elastic.co/t/how-to-apply-ilm-policy-to-index-patter-tenat/328428 "2023-03-24T07:21:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![elasticlog](https://avatars.discourse-cdn.com/v4/letter/e/77aa72/32.png) [@elasticlog](https://discuss.elastic.co/u/elasticlog)
#### Post date: [March 24, 2023, 7:21am UTC](https://discuss.elastic.co/t/how-to-apply-ilm-policy-to-index-patter-tenat/328428/1 "2023-03-24T07:21:38Z")

</div>

Hello Expert,

I have to apply an ilm policy to my index patter so that the space full issue should not occur. Im able to create the policy but not able to apply to index patter as i need to add manually for index pattern timestamp created.

How i will be able to apply this to all index pattern which we have created. Im using kiban version 7.14.1.

---

<div class="post-metadata">

### Author: ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)
#### Post date: [April 12, 2023, 5:04pm UTC](https://discuss.elastic.co/t/how-to-apply-ilm-policy-to-index-patter-tenat/328428/2 "2023-04-12T17:04:46Z")

</div>

Mahesh,  
you have not understand ILM properly.  
you can't apply a ilm to index pattern.

first you have to create ILM, create template and create alias. It is three step process.

for example  
first create ILM

```auto
PUT _ilm/policy/myilm
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0ms",
        "actions": {
          "rollover": {
            "max_primary_shard_size": "25gb",
            "max_age": "365d"
          }
        }
      }
    }
  }
}

```

then create template, what it says that your pattern is myindex-\*,  
when it rolls over it uses myindex--000000 and increament that number  
and you now write to only myindex ( not with date or anything)

```auto
PUT _index_template/myindex_template
{
  "index_patterns": ["myindex-*"],
  "template": {
    "settings": {
      "index": {
        "lifecycle": {
          "name": "myindex",
          "rollover_alias": "myindex"
        },
        "number_of_shards": "1",
        "number_of_replicas": "1"
      }
    },
    "mappings": {}
  }
}

```

and finally you create blank index with date-number etc...  
this will create index "myindex--000001"

```auto
PUT %3Cmyindex-%7Bnow%2Fd%7D-000001%3E
{
  "aliases": {
    "myindex": {
      "is_write_index": true
    }
  }
}

```

once all done. send data to "myindex" and it will write in to myindex--0000001  
once it reaches 25 gig it will automatically create new index called "myindex--0000002"

---

<div class="post-metadata">

### Author: ![elasticlog](https://avatars.discourse-cdn.com/v4/letter/e/77aa72/32.png) [@elasticlog](https://discuss.elastic.co/u/elasticlog)
#### Post date: [April 25, 2023, 10:42am UTC](https://discuss.elastic.co/t/how-to-apply-ilm-policy-to-index-patter-tenat/328428/3 "2023-04-25T10:42:28Z")

</div>

Thank you Sachin.

We have change the ilm policy to delete file older than 7 days.

---

<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: [May 23, 2023, 10:42am UTC](https://discuss.elastic.co/t/how-to-apply-ilm-policy-to-index-patter-tenat/328428/4 "2023-05-23T10:42:29Z")

</div>

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