I am having some confusions regarding the creation of ISM policies and their application.
I am using opendistro-for-elasticsearch:1.13.2
I have a simple policy like below, which will delete specific indices after 1 hour. It is shown as below:
{
"policy_id": "test_policy_to_delete",
"description": "test policy to delete indices which are 24 hours old",
"last_updated_time": 1645771842635,
"schema_version": 1,
"error_notification": null,
"default_state": "hot",
"states": [
{
"name": "hot",
"actions": [],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "1h"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
],
"transitions": []
}
],
"ism_template": null
}
Now, that I created the policy, I apply it to an index template like below:
PUT _template/slab-firewall
{
"order":4,
"index_patterns": [
"test-firewall-*"
],
"settings": {
"opendistro": {
"index_state_management": {
"policy_id": "test_policy_to_delete"
}
}
},
"mappings": {
"properties": {
"dstport": {
"type": "long"
}
}
}
}
Now after this, I created indices named test-firewall-01, test-firewall-02 etc and checked their settings too,like below:
GET test-firewall-01/_settings
Now, I got the below results indicating that the settings had infact the policy_id , I applied in the previous step. Results of the _settings api below:
{
"test-firewall-01" : {
"settings" : {
"index" : {
"opendistro" : {
"index_state_management" : {
"policy_id" : "test_policy_to_delete"
}
},
"number_of_shards" : "1",
"provided_name" : "test-firewall-01",
"creation_date" : "1645799541885",
"number_of_replicas" : "1",
"uuid" : "JbowZMfLRrKUHpFsstTCaA",
"version" : {
"created" : "7100299"
}
}
}
}
}
Now, after 1 hour, nothing happens.
So I went to the Index Management > Managed Indices and then attach this policy to the indices.
After this, it gets applied.
So I am confused, why this is happening. What I want to achieve is that, to add the policy id to the index templates, so that every index which gets created and satisfies the index templates will undergo the ISM policy which was added to the template.
NOTE: I tried the ISM API too,
POST _opendistro/_ism/add/test-firewall-*
{
"policy_id": "test_policy_to_delete"
}
this will also yield the same results as UI addition, but my objective is to specify the ISM policy to the index template and then to get it applied as any future indices get created.
Anything that I am doing wrong here ?