Hello every, I hope you all doing well during this time of confinement
So basically what I have is a series of logs indexed daily into Elasticsearch, my logs index pattern is
logs-YYYY.MM.DD
I'm trying to set up a rollover action to delete the index entirely after 30 days. From what I have read in the documentation, we simply create an index lifecycle policy with the delete phase enabled and create an index template which is using the index lifecycle policy above to apply that to all indexes matched the index pattern. My configuration for the index lifecycle policy and the index template are the following:
PUT _ilm/policy/logspolicy
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_age": "30d",
"max_size": "50gb"
},
"set_priority": {
"priority": 100
}
}
},
"delete": {
"min_age": "1d",
"actions": {
"delete": {}
}
}
}
}
}
PUT _template/logs_template
{
"index_patterns": ["logs*"],
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"index.lifecycle.name": "logspolicy",
"index.lifecycle.rollover_alias": ???
}
}
However, I got stuck at the configuration of index.lifecycle.rollover_alias. My case is rather different than the case in the documentation which all the events are indexed into one index logs rather than logs-YYYY.MM.DD. Hence, there is no way for me to define the lifecycle alias for indexes with the date.
Moreover, we also need to bootstrap the rollover process by creating the first index with the suffix -000001 and since my index is created daily and I don't think this will be a feasible option to do it manually every day.
Is there any way to define the index.lifecycle.rollover_alias dynamically based on the date in the index pattern? Thanks