# Ilm policy on system index

**URL:** https://discuss.elastic.co/t/ilm-policy-on-system-index/183657
**Category:** Elasticsearch
**Created:** [May 31, 2019, 5:27am UTC](https://discuss.elastic.co/t/ilm-policy-on-system-index/183657 "2019-05-31T05:27:10Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![pathri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pathri/32/54484_2.png) [@pathri](https://discuss.elastic.co/u/pathri)
#### Post date: [May 31, 2019, 5:27am UTC](https://discuss.elastic.co/t/ilm-policy-on-system-index/183657/1 "2019-05-31T05:27:10Z")

</div>

I am trying to put a policy on the system generated indices specifically to

".monitoring-es-...._"  
&  
".monitoring-kibana-...._"

i have created a policy which is simply deleting these indices which are having age as 1 day

policy is as below

{  
"delete-system-indices" : {  
"version" : 1,  
"modified\_date" : "2019-05-31T04:19:06.506Z",  
"policy" : {  
"phases" : {  
"hot" : {  
"min\_age" : "0ms",  
"actions" : {  
"set\_priority" : {  
"priority" : 100  
}  
}  
},  
"delete" : {  
"min\_age" : "1d",  
"actions" : {  
"delete" : { }  
}  
}  
}  
}  
}  
}

now i am trying to put the above created policy on the mentioned indices but not able to find out the appropriate command.

Please help

Thanks in advance

---

<div class="post-metadata">

### Author: ![jakelandis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jakelandis/32/36163_2.png) [@jakelandis](https://discuss.elastic.co/u/jakelandis)
#### Post date: [May 31, 2019, 4:25pm UTC](https://discuss.elastic.co/t/ilm-policy-on-system-index/183657/2 "2019-05-31T16:25:45Z")

</div>

Monitoring (which pre-dates ILM) has a means to clean up old indexes. [https://www.elastic.co/guide/en/elasticsearch/reference/7.1/monitoring-settings.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.1/monitoring-settings.html)

The gotcha here is that is only applicable for clusters which are monitoring themselves. So if the cluster that has these indexes is monitoring itself (e.g. local exporter) using the built in cleaner should be preferred:

```auto
GET _cluster/settings?include_defaults=true&filter_path=*.xpack.monitoring.history.duration

PUT _cluster/settings
{
  "persistent": {
    "xpack.monitoring.history.duration" : "1d"
  }
}

```

To answer your question...

To apply a policy to system indices, you will need to create an index template that matches the patterns and apply the policy there.

```auto
PUT _template/ilm_delete_after_1_day
{
  "order": 10,
  "index_patterns": [".monitoring-es-*", ".monitoring-kibana-*"],
  "settings": {
    "index.lifecycle.name": "delete-system-indices"
  }
}

```

Now when a new index is created it will have the ILM policy attached. (this will _not_ apply to existing indexes). You can quickly test this out with the following:

```auto
PUT .monitoring-es-testme
GET .monitoring-es-testme
DELETE .monitoring-es-testme

```

Note - there are some ILM actions that should be avoided with system indices, such as rollover and shrink. Actions that should be avoided are generally ones that may have pre-requisite (such as specific naming) or will result in changes that could break the system which is reading these indices. However, your usecase of deleting time series monitoring data for monitoring is valid (assuming the monitoring suggestion above doesn't apply) .

---

<div class="post-metadata">

### Author: ![pathri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pathri/32/54484_2.png) [@pathri](https://discuss.elastic.co/u/pathri)
#### Post date: [June 10, 2019, 5:02am UTC](https://discuss.elastic.co/t/ilm-policy-on-system-index/183657/3 "2019-06-10T05:02:02Z")

</div>

alright  
thanks for your reply 🙂

---

<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: [July 8, 2019, 5:04am UTC](https://discuss.elastic.co/t/ilm-policy-on-system-index/183657/4 "2019-07-08T05:04:30Z")

</div>

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