what is the better way to create a lifecycle index managed by app not Elasticsearch?

Viewed 740

I am using Elasticsearch 7.15 and Kibana for searching text. The way I am creating index is daily index. Every time my application tries to save data to Elasticsearch, it will creates an index with date as the suffix: logs-2022-01-10.

I need to create an index lifecycle to delete the index which is older than 30 days. I have come cross some tutorial like: https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-index-lifecycle-management.html but it is all about creating an index template and let Elasticsearch to create the index when certain threshold is hit.

Is there a simple way to create a delete policy based on the index name pattern without creating index template?

2 Answers

Please check Apply Lifecycle Policy Manually which you can use to assign ILM policy directly to index without template. Below is sample configuration you can set to index for apply policy manually.

PUT test-index
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1,
    "index.lifecycle.name": "my_policy" 
  }
}

To create a lifecycle policy from Kibana, open the menu and go to Stack Management > Index Lifecycle Policies. Click Create policy.

Click on the tiny delete icon to enable Delete Phase.

enter image description here

the only way to do this would be to use Elasticsearch Curator, which is an older generation tool, or to DIY

Related