Date Math Support in index names while defining SLM policy

Hi,

I want to backup only last months index using SLM policy and trying to use date Math while configuring the indices in SLM policy. Unfortunately, it doesn't work and can't find the index. However the same date math pattern works in dev tools.

Index Name : logs-2021.02

SLM policy :

PUT /_slm/policy/snapshot1
{
  "schedule": "0 35 4 * * ?", 
  "name": "<snap-{now/d}>", 
  "repository": "snapshot_1", 
  "config": { 
    "indices": ["%3Clogs-%7Bnow%2FM%7Byyyy.MM%7D%7D%3E"] 
  }
}

Error details :

"details" : """{"type":"index_not_found_exception","reason":"no such index [%3Clogs-%7Bnow%2FM%7Byyyy.MM%7D%7D%3E]", "resource.type":"index_or_alias","resource.id":"%3Clogs-%7Bnow%2FM%7Byyyy.MM%7D%7D%3E","index_uuid":"na","index":"%3Clogs-%7Bnow%2FM%7Byyyy.MM%7D%7D%3E","stack_trace":"[%3Clogs-%7Bnow%2FM%7Byyyy.MM%7D%7D%3E] IndexNotFoundException[no such index [%3Clogs-%7Bnow%2FM%7Byyyy.MM%7D%7D%3E]]

Does SLM indices support date Math? If not, what is the alternative to snapshot only specific timeseries indices from a list of indices?

Hi @ParashB

Have you managed to find a workaround for this?

Kind regards
Marc

Hi Marc,

Yes, I did manage to make this work. Please find the SLM policy configuration:

{
  "schedule": "0 35 4 * * ?", 
  "name": "<snap-{now/d}>", 
  "repository": "snapshot_1", 
  "config": { 
    "indices": [<logs-*{now/M{yyyy.MM}}>
  }
}

Note that you need to insert the wildcard character although you don't have anything between logs & the date pattern.

2 Likes

Thank you @ParashB!

That did the trick