# Delete the indexes of more than 7 days

**URL:** <https://discuss.elastic.co/t/delete-the-indexes-of-more-than-7-days/197141>\
**Category:** Elasticsearch\
**Created:** [August 28, 2019, 2:44pm UTC](https://discuss.elastic.co/t/delete-the-indexes-of-more-than-7-days/197141 "2019-08-28T14:44:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Oceans](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_oceans/32/51452_2.png) [@David\_Oceans](https://discuss.elastic.co/u/David_Oceans)\
**Post date:** [August 28, 2019, 2:44pm UTC](https://discuss.elastic.co/t/delete-the-indexes-of-more-than-7-days/197141/1 "2019-08-28T14:44:33Z")

</div>

Hi!

I was reading this two links in order to create a policy to delete the indexes of more than 7 days.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-index-lifecycle-management.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-index-lifecycle-management.html)  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/applying-policy-to-template.html#applying-policy-to-template](https://www.elastic.co/guide/en/elasticsearch/reference/current/applying-policy-to-template.html#applying-policy-to-template)

This is my template  
GET /\_template/company\_template

```
  {
      "company_template" : {
        "order" : 0,
        "index_patterns" : [
          "gke_prod_*",
          "gke_stage_*"
        ],
        "settings" : {
          "index" : {
            "lifecycle" : {
              "name" : "company_policy"
            },
            "number_of_shards" : "1",
            "number_of_replicas" : "1"
          }
        },
        "mappings" : { },
        "aliases" : { }
      }
    }

```

This is my policy  
GET \_ilm/policy/company\_policy

```
{
  "company_policy" : {
    "version" : 1,
    "modified_date" : "2019-08-27T11:30:21.963Z",
    "policy" : {
      "phases" : {
        "delete" : {
          "min_age" : "7d",
          "actions" : {
            "delete" : { }
          }
        }
      }
    }
  }
}

```

However when I go to **Index Lifecycle Policies** in web console I don't see any "Linked indices" 😢 and the index patern is correct.

What I do wrong or how I can debug?

I have a lot of old indexes, this policy should be apply to all indices too or only from today (for new indexes)?

Thank you

---

<div class="post-metadata">

**Author:** ![David\_Oceans](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_oceans/32/51452_2.png) [@David\_Oceans](https://discuss.elastic.co/u/David_Oceans)\
**Post date:** [August 29, 2019, 8:27am UTC](https://discuss.elastic.co/t/delete-the-indexes-of-more-than-7-days/197141/2 "2019-08-29T08:27:02Z")

</div>

When I see the setting for index of today I can see this

```
{
  "settings": {
    "index": {
      "lifecycle": {
        "name": "company_policy"
      },
      "number_of_shards": "1",
      "provided_name": "gke_prod_aaa-2019.08.29",
      "creation_date": "1567036813104",
      "number_of_replicas": "1",
      "uuid": "cNjKnFdgTDKqlDqvgMoLMg",
      "version": {
        "created": "7030099"
      }
    }

```

However in my old indexes no.

```
{
  "settings": {
    "index": {
      "creation_date": "1566950412251",
      "number_of_shards": "1",
      "number_of_replicas": "1",
      "uuid": "eylMA44wRn6-IMMxJbltug",
      "version": {
        "created": "7030099"
      },
      "provided_name": "gke_prod_aaa-2019.08.28"
    }
  },

```

Thats means that only applies for the new indexes and now I won't have old indexes more than 7 days from today, but I can't applying for the old indexes?

---

<div class="post-metadata">

**Author:** ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)\
**Post date:** [August 29, 2019, 11:25am UTC](https://discuss.elastic.co/t/delete-the-indexes-of-more-than-7-days/197141/3 "2019-08-29T11:25:27Z")

</div>

Hi @David_Oceans  
I recommend you to check my reply in this topic:  
[https://discuss.elastic.co/t/how-to-configure-my-index-life-cycle-policy/193468?u=dgonzalezp](https://discuss.elastic.co/t/how-to-configure-my-index-life-cycle-policy/193468)  
You can skip the first step about how to create new index each day.  
If you have any doubt tell me.

---

<div class="post-metadata">

**Author:** ![David\_Oceans](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_oceans/32/51452_2.png) [@David\_Oceans](https://discuss.elastic.co/u/David_Oceans)\
**Post date:** [August 29, 2019, 2:27pm UTC](https://discuss.elastic.co/t/delete-the-indexes-of-more-than-7-days/197141/4 "2019-08-29T14:27:26Z")

</div>

The key is this in the case before? **manage\_template =\> false**?  
In my case I use filebeat, How I should to do?

But as I read in your post, I have it well configured for the new indexes, but my problem then is in those that are already created that does not apply, right?

Regards

---

<div class="post-metadata">

**Author:** ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)\
**Post date:** [August 30, 2019, 6:29am UTC](https://discuss.elastic.co/t/delete-the-indexes-of-more-than-7-days/197141/5 "2019-08-30T06:29:30Z")

</div>

You are right, in your case the indexes already created will not be apply because those didnt use the template to be created then the lifecycle doesnt affect on this ones.  
Anyway you can delete those index manually using the following command:

> DELETE gke\_prod-aaa-2019.08.\*

With that one for example you will delete all the indexes from that month.  
I hope this will be useful for you.

---

<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:** [September 27, 2019, 6:33am UTC](https://discuss.elastic.co/t/delete-the-indexes-of-more-than-7-days/197141/6 "2019-09-27T06:33:34Z")

</div>

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