Rollover alias with date does not put the right date


I need to have a new index every day with the myindex + datetime (myindex-YYYY.MM.DD).
I created an index with initial name myindex-2020.09.01-000001.

  index_body = {
        "aliases": {
           "myindex": {
              "is_write_index": True

During the same day on 2020.09.01, I executed the rollover api

POST /myindex/_rollover 
  "conditions": {
    "max_docs":   "1"

A new index was correctly added as myindex-2020.09.01-000002
However on 2020.09.02, the next day, I expected the new rollover index to be named myindex-2020.09.02-000003. But what I noticed is that the newly created rollover index is named myindex-2020.09.01-000003. The date part of the index name does not correctly match th date when the api was executed.
I am on Elastic 7.6.1.
I need help in fixing this rollover alias with date problem.
Thanks in advance for any help.

With ILM, the date in the index name is the date that the policy was first implemented. It does not relate to the date of the index creation. Instead, the counter increases as you are seeing.

Hi @pingz,

When creating your indices you can use date math instead of creating the index with the actual date.

You would need to create the initial index using date math similar to the below:

PUT /%3Cmyindex-%7Bnow%2Fs%7Byyyy-MM-dd-HH-mm-ss%7D%7D-1%3E
  "aliases": {
      "is_write_index": true

You can read more about that here:

Another option which is closer to your example would be:

PUT /%3Cmyindex-%7Bnow%2Fd%7D-000001%3E

Thanks John!. Works as expected now.

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