# Creating index on monthly basis

**URL:** https://discuss.elastic.co/t/creating-index-on-monthly-basis/274762
**Category:** Elasticsearch
**Created:** [June 2, 2021, 2:01pm UTC](https://discuss.elastic.co/t/creating-index-on-monthly-basis/274762 "2021-06-02T14:01:55Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Gourav\_Aggarwal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gourav_aggarwal/32/80282_2.png) [@Gourav\_Aggarwal](https://discuss.elastic.co/u/Gourav_Aggarwal)
#### Post date: [June 2, 2021, 2:01pm UTC](https://discuss.elastic.co/t/creating-index-on-monthly-basis/274762/1 "2021-06-02T14:01:55Z")

</div>

Is there any way by which we can create index named `<prefix>-yyyy.mm` on the first day of every month and getting the alias pointed to this newly created index? I learned about date time but that changes the name only when the index rollover take places. I am using Rest High level java client to insert the Json messages into elastic search and kibana for visualization.

---

<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: [June 2, 2021, 11:59pm UTC](https://discuss.elastic.co/t/creating-index-on-monthly-basis/274762/2 "2021-06-02T23:59:52Z")

</div>

Welcome to our community! 😃

We'd recommend using [ILM](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html) to handle that these days.

---

<div class="post-metadata">

### Author: ![Gourav\_Aggarwal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gourav_aggarwal/32/80282_2.png) [@Gourav\_Aggarwal](https://discuss.elastic.co/u/Gourav_Aggarwal)
#### Post date: [June 3, 2021, 4:48am UTC](https://discuss.elastic.co/t/creating-index-on-monthly-basis/274762/3 "2021-06-03T04:48:56Z")

</div>

But the max\_age time units list doesnot contains month, right? Is there any setting so that we can trigger rollover on first of the month?

---

<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: [June 3, 2021, 5:22am UTC](https://discuss.elastic.co/t/creating-index-on-monthly-basis/274762/4 "2021-06-03T05:22:42Z")

</div>

It'd be N days from when the policy first created an index, so that may or may not be the start of the new month.

Is there a reason you want it exactly monthly?

---

<div class="post-metadata">

### Author: ![Gourav\_Aggarwal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gourav_aggarwal/32/80282_2.png) [@Gourav\_Aggarwal](https://discuss.elastic.co/u/Gourav_Aggarwal)
#### Post date: [June 3, 2021, 5:31am UTC](https://discuss.elastic.co/t/creating-index-on-monthly-basis/274762/5 "2021-06-03T05:31:43Z")

</div>

I have one use case where my index name contains the month and year and to store that month data into that month's index only.

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [June 3, 2021, 6:02am UTC](https://discuss.elastic.co/t/creating-index-on-monthly-basis/274762/6 "2021-06-03T06:02:18Z")

</div>

You can probably use this as one method

> **[Date index name processor | Elasticsearch Guide \[7.13\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/date-index-name-processor.html)**

---

<div class="post-metadata">

### Author: ![Gourav\_Aggarwal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gourav_aggarwal/32/80282_2.png) [@Gourav\_Aggarwal](https://discuss.elastic.co/u/Gourav_Aggarwal)
#### Post date: [June 9, 2021, 3:18pm UTC](https://discuss.elastic.co/t/creating-index-on-monthly-basis/274762/7 "2021-06-09T15:18:23Z")

</div>

Thanks for the 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 7, 2021, 3:18pm UTC](https://discuss.elastic.co/t/creating-index-on-monthly-basis/274762/8 "2021-07-07T15:18:48Z")

</div>

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