# Rollover alias with date

**URL:** <https://discuss.elastic.co/t/rollover-alias-with-date/192308>\
**Category:** Elasticsearch\
**Created:** [July 25, 2019, 7:31pm UTC](https://discuss.elastic.co/t/rollover-alias-with-date/192308 "2019-07-25T19:31:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abaullosa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abaullosa/32/52274_2.png) [@abaullosa](https://discuss.elastic.co/u/abaullosa)\
**Post date:** [July 25, 2019, 7:31pm UTC](https://discuss.elastic.co/t/rollover-alias-with-date/192308/1 "2019-07-25T19:31:04Z")

</div>

Hi.

I need some help with the Rollover API.

I need to have a new index every day with the name + datetime (index-YYYYMMDD)

This is what I have now so far..

My app is sending the data to an an alias called alias\_1 this alias point to my real index : index-1  
and I have my rollover job setup to create a new index after the main one is 1day old. it does the job but I dont know how to tell my template or rollover job to add the date on the index name once it create it.

Im not using curator, Im on Elastic Cloud running version 7 and doing this trough Kibana.

Thanks a lot in advance

---

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [July 26, 2019, 10:16pm UTC](https://discuss.elastic.co/t/rollover-alias-with-date/192308/2 "2019-07-26T22:16:36Z")

</div>

Hi Angel, from the docs it looks like the Rollover API allows you to define the rollover index with a date math expression in the name: [https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html#\_using\_date\_math\_with\_the\_rollover\_api](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html#_using_date_math_with_the_rollover_api)

For example, from looking at the [date math docs](https://www.elastic.co/guide/en/elasticsearch/reference/master/date-math-index-names.html) I believe this would accomplish your goal:

```auto
# URI encoded /<index-{now/d{YYYYMMDD}}>
PUT /%3Cindex-%7Bnow%2Fd%7BYYYYMMDD%7D%7D%3E
{
  "aliases": {
    "logs_write": {}
  }
}

```

This will create an index each day named with the pattern `index-YYYYMMDD`.

---

<div class="post-metadata">

**Author:** ![abaullosa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abaullosa/32/52274_2.png) [@abaullosa](https://discuss.elastic.co/u/abaullosa)\
**Post date:** [August 13, 2019, 8:10pm UTC](https://discuss.elastic.co/t/rollover-alias-with-date/192308/3 "2019-08-13T20:10:56Z")

</div>

Thanks a lot!

It worked perfectly!

Thanks

---

<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 10, 2019, 8:10pm UTC](https://discuss.elastic.co/t/rollover-alias-with-date/192308/4 "2019-09-10T20:10:58Z")

</div>

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