How do I apply policy to index?

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
opensearch 2.7.0

Describe the issue:
why didn’t apply policy in index?
I follow these steps(refer to Policies - OpenSearch documentation)
The first index created but next index did not create even thought shard’s size over 30gb(setting value in policy)
And In the Opensearch Dashboards - Policy managed indices menu
I can see this - Missing rollover_alias index setting [index=log-2023.06.19-000001]"

  1. creat policy
{
    "id": "data-policy",
    "seqNo": 730,
    "primaryTerm": 2,
    "policy": {
        "policy_id": "data-policy",
        "description": "hot warm delete workflow",
        "last_updated_time": 1687283567536,
        "schema_version": 17,
        "error_notification": null,
        "default_state": "hot",
        "states": [
            {
                "name": "hot",
                "actions": [
                    {
                        "retry": {
                            "count": 3,
                            "backoff": "exponential",
                            "delay": "1m"
                        },
                        "rollover": {
                            "min_index_age": "1d",
                            "min_primary_shard_size": "30gb"
                        }
                    }
                ],
                "transitions": [
                    {
                        "state_name": "warm"
                    }
                ]
            },
            {
                "name": "warm",
                "actions": [
                    {
                        "retry": {
                            "count": 3,
                            "backoff": "exponential",
                            "delay": "1m"
                        },
                        "replica_count": {
                            "number_of_replicas": 5
                        }
                    }
                ],
                "transitions": [
                    {
                        "state_name": "delete",
                        "conditions": {
                            "min_index_age": "63d"
                        }
                    }
                ]
            },
            {
                "name": "delete",
                "actions": [
                    {
                        "retry": {
                            "count": 3,
                            "backoff": "exponential",
                            "delay": "1m"
                        },
                        "delete": {}
                    }
                ],
                "transitions": []
            }
        ],
        "ism_template": [
            {
                "index_patterns": [
                    "log*"
                ],
                "priority": 0,
                "last_updated_time": 1686594538983
            }
        ]
    }
}
  1. put /_template/ism_rollover_app
PUT /_template/ism_rollover_app
{
  "index_patterns": "log*",
  "settings":{
    "index":{
      "opendistro.index_state_management.rollover_alias": "log"
      }
  }
}
  1. create index template
{
  "index_patterns": [
    "log*"
  ],
  "template": {
    "settings": {
      "index.number_of_shards": "3",
      "index.number_of_replicas": "1"
    },
    "aliases": {
      "log": {}
    }
  },
  "composed_of": [],
  "priority": "0",
  "_meta": {
    "flow": "simple"
  },
  "name": "log"
}
  1. put first data
PUT /%3Clog-%7Bnow%2Fd%7D-000001%3E
{
  "aliases": {
    "log": {
      "is_write_index": true
    }
  }
}
  1. making first index
log-2023.06.19-000001

Why did you use opendistro in OpenSearch? Also, this doesn’t fit the example provided in the mentioned documentation. As per documentation you must configure _index_template with rollover_alias and not the _template.

Please have a look at step 2.
image

1 Like

thank you @pablo I miss it…
so I solved it like this

step1 → skip step2 → step 3(add “plugins.index_state_management.rollover_alias”) → step 4

{
  "index_patterns": [
    "log*"
  ],
  "template": {
    "settings": {
      "index.number_of_shards": "3",
      "index.number_of_replicas": "1",
      "plugins.index_state_management.rollover_alias": "log"
    },
    "aliases": {
      "log": {}
    }
  },
  "composed_of": [],
  "priority": "0",
  "_meta": {
    "flow": "simple"
  },
  "name": "log"
}

@pablo
After editting yesterday, I thought fixed it.
But today, I found another error

{ "cause": "Rollover alias [log] can point to multiple indices, found duplicated alias [[log]] in index template [log]", "message": "Failed to rollover index [index=log-2023.06.22-000001]" }

Is there another solution?

@cucukaka Did you remove the old alias?