Change index naming for ism indexes

Opensearch 1.3 running on AWS

Hello,

We have recently spun up and are using opensearch on AWS. The indexes rotate daily then move to warm and finally delete using ISM. Everything is working fine but I want to change the names.

Currently the indexes follow a naming structure like:

index-000001
index-000002
index-000003

and so on. I would like to add the date to naming like

index-2022.11.28-000001
index-2022.11.29-000002
index-2022.11.30-000003

which I believe would be just creating an index like:

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

The issue I am having is how to apply that with ISM running. I see in the index settings after I use the above put

"provided_name" : "<index-{now/d}-000001>"

Can I somehow add that to current template so the next index creation uses that naming?

Otherwise it seems I have to do a series of steps something like:

  1. Create the new date math name index
  2. Then switch the is_write_index alias
  3. But then the old index with the incrementing number fails on daily rollover with:
    "Missing alias or not the write index when rollover"
    which makes sense its not the write index anymore
  4. So I guess I could re-index that into the new index I created.

But if i could just change the template so the new daily index picks up the name it would be much easier and safer.

Thanks!

1 Like

Just in case this can help someone here are my steps for implementation.

# creates new index using data math
# will be named "my-new-index-2022.12.09-000001"
PUT /%3Cmy-new-index-%7Bnow%2Fd%7D-000001%3E


# switch the alias to start writing to the new index
POST _aliases
{
  "actions": [
    {
      "add": {
        "index": "my-old-index-000155",
        "alias": "my-alias", 
        "is_write_index": false
      }
    },
    {
      "add": {
        "index": "my-new-index-2022.12.09-000001",
        "alias": "my-alias", 
        "is_write_index": true
      }
    }
  ]
}


# move data into the new date math index for ism and rollover
# I am doing this right after a rollover so I am not moving a ton of data
POST _reindex
{
   "source":{
      "index":"my-old-index-000155"
   },
   "dest":{
      "index":"my-new-index-2022.12.09-000001"
   }
}

# ISM will complain, see my comment above
DELETE my-old-index-000155