Remove alias from closed index automatically

Hi,
I configured an index policy in order to manage better my cluster, with the below policy:

Policy configuration

{
  "policy": {
    "description": "netflow-monitoring index policy",
    "default_state": "hot",
    "schema_version": 1,
    "states": [
      {
        "name": "hot",
        "actions": [
          {
            "replica_count": {
                "number_of_replicas": 2
            },
            "rollover": {
                "min_index_age": "12h",
                "min_size": "2gb"
            }
          }
        ],
        "transitions": [
          { 
            "state_name": "warm"
          }
        ]
      },
      {
        "name": "warm",
        "actions": [
          {
            "replica_count": {
                "number_of_replicas": 1
            }
          }
        ],
        "transitions": [
            {
                "state_name": "cold",
                "conditions": {
                    "min_index_age": "1h"
                }
            }
        ]
      },
      {
          "name": "cold",
          "actions": [
              {
                "close": {}
              }
          ]
      }
    ],
    "ism_template": {
      "index_patterns": ["netflow-monitoring*"]
    }
  }
}

Template configuration

{
    "index_patterns": [
        "netflow-monitoring*"
    ],
    "settings": {
        "plugins.index_state_management.rollover_alias": "netflow-monitoring-alias"
    }
}

Index configuration

{
  "aliases": {
    "netflow-monitoring-alias": {
      "is_write_index": true
    }
  }
}

Result
These configuration work perfectly,

But, I need to remove alias in warm state or in rollover stage. In other word I need the last index have the alias.

We don’t currently support modifying aliases from ISM directly, but we have a GitHub feature request for it which you can comment on and +1.

https://github.com/opensearch-project/index-management/issues/35

1 Like

Thank you, and sure… @dbbaughe

Hi @dbbaughe ,
I also had same usecase. I am trying to remove alias manually from earlier index and assign it to new index.

Ref link: Index aliases - OpenSearch documentation

Manual Approach:

How to add new TS index my_index-000010`` in Alias, to push doc in my_index-000011 index.

Step 1: Create TS new index at 12 AM using py script:

PUT my_index-000010

Step 2: Run the command which will remove alias from index my_index-000010`` and add alias to my_index-* wildcard to without write property, write property will be added to index ` `my_index-000011 (latest) where all new data will be pushed to latest index.

POST _aliases
{
  "actions": [
    {
      "remove": {
        "index": "my_index-000010",
        "alias": "my_index"  
      }
    },
    {
        "add": {
        "index": "my_index-*",
        "alias": "my_index"
      }
    },
    {
      "add": {
        "index": "my_index-000011",
        "alias": "my_index",
        "is_write_index": "true"
      }
    }
  ]
}`