# Rollover index based on index name

**URL:** <https://discuss.elastic.co/t/rollover-index-based-on-index-name/210210>\
**Category:** Elasticsearch\
**Tags:** curator\
**Created:** [December 2, 2019, 3:44pm UTC](https://discuss.elastic.co/t/rollover-index-based-on-index-name/210210 "2019-12-02T15:44:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![victor.nilsson](https://avatars.discourse-cdn.com/v4/letter/v/eb8c5e/32.png) [@victor.nilsson](https://discuss.elastic.co/u/victor.nilsson)\
**Post date:** [December 2, 2019, 3:44pm UTC](https://discuss.elastic.co/t/rollover-index-based-on-index-name/210210/1 "2019-12-02T15:44:30Z")

</div>

Hi,

We're creating weekly indices and want to rollover whenever there is a new week, using Curator.  
However, we see the only "age" based option is 'max\_age' which is not exactly what we want to do.

If we set the max\_age option to rollover when the index is 7 days old, that is based on the creationdate right? So if i create index1 in the middle of the week, then curator will not rollover the index until the same day next week right?

What we want to do is to let curator determine the age based on the index name, so if we create an index named "logstash-2019.49-00001" curator should look at the name and figure out that the index is for week 49 and as soon as we go over into week 50, curator should rollover.

Is this supported in any way?

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [December 2, 2019, 5:30pm UTC](https://discuss.elastic.co/t/rollover-index-based-on-index-name/210210/2 "2019-12-02T17:30:42Z")

</div>

This is a great question, and the answer is that the problem lies not within Curator but the Rollover API's way of doing things. The Rollover API only provides 3 ways to trigger a rollover: max\_age, max\_docs, and max\_size. As you have correctly identified, max\_age is in seconds since index creation, and therefore is not a good fit for what you're doing.

To truly do weekly indices as described, you would have to have Logstash use its date math functionality to simply create a new index every week, and not use the Rollover API. You would then need to use Curator to manage the index life cycle.

More information on the Joda time string representations can be read [here](https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html#plugins-filters-date-match), in the date filter plugin documentation. You would perhaps be able to generate what you want in the `elasticsearch` output with an index directive like:

```auto
index => "logstash-%{+yyyy.ww}"

```

Where `y` indicates each digit of a 4 digit year, and `w` indicates each digit of a 2 digit week of year.

---

<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:** [December 30, 2019, 5:30pm UTC](https://discuss.elastic.co/t/rollover-index-based-on-index-name/210210/3 "2019-12-30T17:30:43Z")

</div>

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

---

<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:** [December 30, 2019, 5:30pm UTC](https://discuss.elastic.co/t/rollover-index-based-on-index-name/210210/4 "2019-12-30T17:30:45Z")

</div>



---

<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:** [November 4, 2022, 7:35am UTC](https://discuss.elastic.co/t/rollover-index-based-on-index-name/210210/5 "2022-11-04T07:35:44Z")

</div>


