Rollover alias with date

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

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

For example, from looking at the date math docs I believe this would accomplish your goal:

# 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.

Thanks a lot!

It worked perfectly!

Thanks