# Delete indices older than 30 days using Kibana Index Lifecycle policies

**URL:** https://discuss.elastic.co/t/delete-indices-older-than-30-days-using-kibana-index-lifecycle-policies/242350
**Category:** Elasticsearch
**Created:** [July 23, 2020, 1:51pm UTC](https://discuss.elastic.co/t/delete-indices-older-than-30-days-using-kibana-index-lifecycle-policies/242350 "2020-07-23T13:51:24Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)
#### Post date: [July 23, 2020, 1:51pm UTC](https://discuss.elastic.co/t/delete-indices-older-than-30-days-using-kibana-index-lifecycle-policies/242350/1 "2020-07-23T13:51:24Z")

</div>

Hello. I am new to ELK. I have managed to install and setup ELK 7.6.2 stack on RHEL 7 servers. Now as part of house keeping I need to remove/ delete indices older than 30 days to maintain certain level of available disk space.

Can I do this using Kibana console by navigating through the following:

Management =\> Index Lifecycle policies =\> Create an index lifecycle policy =\> Delete phase =\> Activate delete phase =\> 30 days from rollover

Are there any disadvantages of using the above?

Please note that I want to avoid using Curator (Read about it in this forum)

Thanks

---

<div class="post-metadata">

### Author: ![d.silwon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/d.silwon/32/65853_2.png) [@d.silwon](https://discuss.elastic.co/u/d.silwon)
#### Post date: [July 23, 2020, 8:08pm UTC](https://discuss.elastic.co/t/delete-indices-older-than-30-days-using-kibana-index-lifecycle-policies/242350/2 "2020-07-23T20:08:48Z")

</div>

Hi @zaeemmasood,

You can do this by the following steps:

1. Create proper policy:

```auto
PUT _ilm/policy/cleanup-history
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {}
      },
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

```

1. Assign new policy to existing indexes:

```auto
PUT /index_name-*/_settings?pretty
{
  "lifecycle.name": "cleanup-history"
}

```

1. Create template for new indexes:

```auto
PUT /_template/logging_policy_template?pretty
{
"index_patterns": ["index_name-*", "other_index-*"], "settings": { "index.lifecycle.name": "cleanup-history" }
}

```

Best Regards,  
Dan

---

<div class="post-metadata">

### Author: ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)
#### Post date: [July 24, 2020, 2:11pm UTC](https://discuss.elastic.co/t/delete-indices-older-than-30-days-using-kibana-index-lifecycle-policies/242350/3 "2020-07-24T14:11:39Z")

</div>

Hello Dan. Thanks for a detailed reply. I have a few questions as follows:

1. I have 3 master nodes and 5 data nodes configured. There are three steps provided by you above for creating policy, assigning policy and creating template. Can I paste these one by one in the "Dev Tools" in Kibana and execute? Would it apply to the entire cluster?

2. Names of all my index patterns start with "prod\_xxxx". When following your proposed Step 2 shall I replace:

3. Likewise in following your Step 3 above can I replace as follows:

"index\_patterns": ["index\_name-_", "other\_index-_"], "settings": { "index.lifecycle.name": "cleanup-history" }

with

"index\_patterns": ["prod\_\*"], "settings": { "index.lifecycle.name": "cleanup-history" }

Thanks again!

---

<div class="post-metadata">

### Author: ![d.silwon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/d.silwon/32/65853_2.png) [@d.silwon](https://discuss.elastic.co/u/d.silwon)
#### Post date: [July 24, 2020, 3:05pm UTC](https://discuss.elastic.co/t/delete-indices-older-than-30-days-using-kibana-index-lifecycle-policies/242350/4 "2020-07-24T15:05:55Z")

</div>

Hello @zaeemmasood,

Ad.1 In my opinion you can connect to one node only and execute these three steps there. In addition. In my environment I have 3 master nodes configured. My Kibana connect to all nodes because Kibana setting looks like:

```auto
server.port: 5601
server.host: "192.168.1.100"
server.name: "kibana-srv"
elasticsearch.hosts: ["http://node-01:9200", "http://node-02:9200", "http://node-03:9200"]
elasticsearch.username: "kibana"
elasticsearch.password: "Passw$Ord"

```

If you have any objections please check it on your one node:

```auto
curl -XGET hostname:9200/_cat/nodes

```

This should show you information about all cluster nodes, not for one only.

Ad.2 Correct thinking.

Ad.3 Correct thinking.

Best Regards,  
Daniel

---

<div class="post-metadata">

### Author: ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)
#### Post date: [July 24, 2020, 4:25pm UTC](https://discuss.elastic.co/t/delete-indices-older-than-30-days-using-kibana-index-lifecycle-policies/242350/5 "2020-07-24T16:25:39Z")

</div>

Thanks Dan. For your Step 3 what are the uses of template?

---

<div class="post-metadata">

### Author: ![d.silwon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/d.silwon/32/65853_2.png) [@d.silwon](https://discuss.elastic.co/u/d.silwon)
#### Post date: [July 24, 2020, 4:50pm UTC](https://discuss.elastic.co/t/delete-indices-older-than-30-days-using-kibana-index-lifecycle-policies/242350/6 "2020-07-24T16:50:01Z")

</div>

If I good remember the template is used in case of new indexes, ie. when a new index is created in Elasticsearch, then your deletion policy will be assigned to it.

In step 2 your new deletion policy will be assigned to existing indexes in Elasticsearch only.

PS. Sorry for my "broken" English.

Regards,  
Dan

---

<div class="post-metadata">

### Author: ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)
#### Post date: [July 24, 2020, 7:44pm UTC](https://discuss.elastic.co/t/delete-indices-older-than-30-days-using-kibana-index-lifecycle-policies/242350/7 "2020-07-24T19:44:34Z")

</div>

Thank you so much! Your input was very useful.

Regards,  
Zaeem

---

<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: [August 21, 2020, 7:44pm UTC](https://discuss.elastic.co/t/delete-indices-older-than-30-days-using-kibana-index-lifecycle-policies/242350/8 "2020-08-21T19:44:34Z")

</div>

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