# Add ILM to existing index

**URL:** https://discuss.elastic.co/t/add-ilm-to-existing-index/295352
**Category:** Kibana
**Tags:** ilm-index-lifecycle-management
**Created:** [January 25, 2022, 1:35pm UTC](https://discuss.elastic.co/t/add-ilm-to-existing-index/295352 "2022-01-25T13:35:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Aviel\_Bashari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviel_bashari/32/92464_2.png) [@Aviel\_Bashari](https://discuss.elastic.co/u/Aviel_Bashari)
#### Post date: [January 25, 2022, 1:35pm UTC](https://discuss.elastic.co/t/add-ilm-to-existing-index/295352/1 "2022-01-25T13:35:28Z")

</div>

Hi,  
im having an index called 'jenkins\_jobs\_logs' and i want to add ILM policy.  
after some investigation, i understood that i must perform a reindex.  
i reindex to the ILM pattern(jenkins\_jobs\_logs --\> jenkins\_jobs\_logs-000001):

```auto
POST _reindex
{
  "source": {
    "index": "jenkins_jobs_logs"
  },
  "dest": {
    "index": "jenkins_jobs_logs-000001"
  }
}

## create ILM
PUT _ilm/policy/jenkins_jobs_logs
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0ms",
        "actions": {
          "rollover": {
            "max_age": "30d",
            "max_size": "50gb"
          },
          "set_priority": {
            "priority": 100
          }
        }
      }
    }
  }
}

## Create template, you can change this latter for shard etc..
PUT _index_template/my_monitoring
{
  "index_patterns": ["jenkins_jobs_logs-*"],
  "template": {
    "settings": {
      "number_of_shards": 3,
      "number_of_replicas": 0,
      "index.lifecycle.name": "jenkins_jobs_logs",
      "index.lifecycle.rollover_alias": "jenkins_jobs_logs"
    }
  }
}

```

**Now what i should do?**  
**do I need to create aמ alias? i tried this but got an error that index/alias already exists...**

```auto
## Create alias

# PUT <my-index-{now/d}-000001>
PUT %3Cjenkins_jobs_logs-%7Bnow%2Fd%7D-000001%3E
{
  "aliases": {
    "jenkins_jobs_logs": {
      "is_write_index": true
    }
  }
}

```

---

<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: [February 22, 2022, 1:36pm UTC](https://discuss.elastic.co/t/add-ilm-to-existing-index/295352/2 "2022-02-22T13:36:29Z")

</div>

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