# HOW-TO create an index automatically per-month

**URL:** https://discuss.elastic.co/t/how-to-create-an-index-automatically-per-month/46027
**Category:** Elasticsearch
**Created:** [April 1, 2016, 6:43am UTC](https://discuss.elastic.co/t/how-to-create-an-index-automatically-per-month/46027 "2016-04-01T06:43:49Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![nskalis](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@nskalis](https://discuss.elastic.co/u/nskalis)
#### Post date: [April 1, 2016, 6:43am UTC](https://discuss.elastic.co/t/how-to-create-an-index-automatically-per-month/46027/1 "2016-04-01T06:43:49Z")

</div>

Good morning guys,

Could you please possibly advise on how to achieve index management on a monthly basis ?

For example, if the index alias is configured like

```
{
    "actions": [
        {
            "add": {
                "index": "{{ item }}",
                "index_routing": "IXmac:cache",
                "search_routing": "IXmac:cache",
                "alias": "TheApp"
            }
        },
        {
            "add": {
                "index": "{{ item }}",
                "index_routing": "IXmac:cache",
                "search_routing": "IXmac:cache",
                "alias": "IXmac"
            }
        }
    ]
}

```

How the index should be configured in order to  
[1] automatically create an index every month  
[2] when querying from Kibana or via curl, the time filter of the query spans more than 1 month, will elasticsearch automatically query the related indices ?

Nikos

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [April 1, 2016, 6:58am UTC](https://discuss.elastic.co/t/how-to-create-an-index-automatically-per-month/46027/2 "2016-04-01T06:58:51Z")

</div>

The only way to create a new index is to request one, there is no way for ES to do that itself.

---

<div class="post-metadata">

### Author: ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)
#### Post date: [April 1, 2016, 10:38am UTC](https://discuss.elastic.co/t/how-to-create-an-index-automatically-per-month/46027/3 "2016-04-01T10:38:02Z")

</div>

You can rely on automatic index creation like logstash does, meaning that the first document that you index into a new index, will cause the index creation as well. The action.auto\_create\_index allows to control which indices can and cannot be created automatically. As for aliases and routing, you can set up an index template that adds aliases to such indices and routing values too.

Cheers  
Luca

---

<div class="post-metadata">

### Author: ![nskalis](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@nskalis](https://discuss.elastic.co/u/nskalis)
#### Post date: [April 1, 2016, 11:14am UTC](https://discuss.elastic.co/t/how-to-create-an-index-automatically-per-month/46027/4 "2016-04-01T11:14:30Z")

</div>

Thank you @javanna @warkolm for the info. Noted.

---

<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 5, 2017, 11:03pm UTC](https://discuss.elastic.co/t/how-to-create-an-index-automatically-per-month/46027/5 "2017-07-05T23:03:19Z")

</div>


