# Index RollOver policy and deleting logs after specific time

**URL:** https://discuss.elastic.co/t/index-rollover-policy-and-deleting-logs-after-specific-time/246778
**Category:** Kibana
**Tags:** ilm-index-lifecycle-management
**Created:** [August 28, 2020, 2:02pm UTC](https://discuss.elastic.co/t/index-rollover-policy-and-deleting-logs-after-specific-time/246778 "2020-08-28T14:02:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mfa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mfa/32/87041_2.png) [@mfa](https://discuss.elastic.co/u/mfa)
#### Post date: [August 28, 2020, 2:02pm UTC](https://discuss.elastic.co/t/index-rollover-policy-and-deleting-logs-after-specific-time/246778/1 "2020-08-28T14:02:17Z")

</div>

Hi,  
I have an ElasticCloud that I want to setups indexes on it and a policy to delete the old logs.  
I have created a lifecycle policy for deleting the logs which are older that 30 days:

```auto
    PUT _ilm/policy/deleting_policy
    {
      "policy": {
        "phases": {
          "hot": {
            "actions": {
              "rollover": {
                "max_size": "50GB" 
              }
            }
          },
          "delete": {
            "min_age": "30d",
            "actions": {
              "delete": {} 
            }
          }
        }
      }
    }

```

I created an Index template as following:

```auto
     PUT _component_template/template1
    {
      "template": {
        "mappings": {
          "properties": {
            "@timestamp": {
              "type": "date"
            },
            "ttlInDays": {
              "type": "integer"
            },
            "@log_group": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "@message": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "@owner": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "message": {
              "type": "text"
            }  
          }
        }
      }
    }

    PUT _index_template/template_1
    {
      "index_patterns": ["mytestindex*"],
      "template": {
        "settings": {
          "number_of_shards": 1,
          "index.lifecycle.name": "deleting_policy", 
          "index.lifecycle.rollover_alias": "alias1"
        },
        "mappings": {
          "_source": {
            "enabled": false
          }
        },
       "aliases": {
          "alias1" : {},
          "{index}-001" : {}
        }
      },
      "priority": 200,
      "composed_of": ["template1"],
      "version": 3,
      "_meta": {
        "description": "my template"
      }
    }

```

After creating an Index, I get this error in the rollover part:

```auto
    PUT /mytestindex

```

`illegal_argument_exception: index name [mytestindex] does not match pattern '^.*-\d+$'`

I have checked the following link but it didn't help me, even running the exact command on this link, gives an error:  
[https://www.elastic.co/guide/en/elasticsearch/reference/5.4/indices-rollover-index.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/indices-rollover-index.html)

I just want to setup a policy that deletes the old logs.  
I would appreciate if anyone can help with this issue.

---

<div class="post-metadata">

### Author: ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)
#### Post date: [August 28, 2020, 8:02pm UTC](https://discuss.elastic.co/t/index-rollover-policy-and-deleting-logs-after-specific-time/246778/2 "2020-08-28T20:02:40Z")

</div>

What version of kibana are you using? Have you tried using the UI to create your policy? Have you followed the steps in [https://www.elastic.co/guide/en/kibana/current/creating-index-lifecycle-policies.html](https://www.elastic.co/guide/en/kibana/current/creating-index-lifecycle-policies.html)?

---

<div class="post-metadata">

### Author: ![mfa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mfa/32/87041_2.png) [@mfa](https://discuss.elastic.co/u/mfa)
#### Post date: [August 31, 2020, 7:42am UTC](https://discuss.elastic.co/t/index-rollover-policy-and-deleting-logs-after-specific-time/246778/3 "2020-08-31T07:42:39Z")

</div>

Hi,  
It is version v7.9.0. I have tried it through UI and it gives me the same error:

```
Index lifecycle error

illegal_argument_exception: index name [mytestindex] does not match pattern '^.*-\d+$'
```

---

<div class="post-metadata">

### Author: ![mfa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mfa/32/87041_2.png) [@mfa](https://discuss.elastic.co/u/mfa)
#### Post date: [August 31, 2020, 1:38pm UTC](https://discuss.elastic.co/t/index-rollover-policy-and-deleting-logs-after-specific-time/246778/4 "2020-08-31T13:38:22Z")

</div>

After changing the index name to this: mytestindex-000001 it seems it is fine now and it doesn't give me the error anymore.

```auto
    PUT /mytestindex-000001
    {
      "aliases": {
        "mytestindex": {
          "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: [September 28, 2020, 1:38pm UTC](https://discuss.elastic.co/t/index-rollover-policy-and-deleting-logs-after-specific-time/246778/5 "2020-09-28T13:38:27Z")

</div>

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