illegal_argument_exception: index.lifecycle.rollover_alias [metricbeat-6.8.4-alias] does not point to index [metricbeat-6.8.4-2020.02.24]

Yoga Arie picture Yoga Arie · Feb 24, 2020 · Viewed 10.1k times · Source

currently looking for help about setup ilm, i have setup the template, index alias and policy as below

PUT metricbeat-6.8.4-alias-000001
{
  "aliases": {
    "metricbeat-6.8.4-alias": {
      "is_write_index": true
    }
  }
}

PUT _template/metricbeat-6.8.4-alias
{
  "index_patterns": ["metricbeat-6.8.4-*"],                 
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1,
    "index.lifecycle.name": "Delete_Index",      
    "index.lifecycle.rollover_alias": "metricbeat-6.8.4-alias"    
  }
}

but still error ocurred like below

illegal_argument_exception: index.lifecycle.rollover_alias [metricbeat-6.8.4-alias] does not point to index [metricbeat-6.8.4-2020.02.24]

looking for help how i setup correcly the ilm ? thanks

Answer

L.querter picture L.querter · May 13, 2020

Creating an alias with the lifecycle policy is a 3 step process.

Elastic provides a great tutorial

In short:

  1. Create a lifecycle policy that defines the appropriate phases and actions.
  2. Create an index template to apply the policy to each new index.
  3. Bootstrap an index as the initial write index.

I think you are creating the template AFTER you create the first index. You should first create the ilm, after that the template where you specify what ilm policy you want to use for the indexes and finally create the first index (bootstrap).

Example in code:

var indexName = "index_name";
var indexPattern = $"{indexName}-*";
var aliasName = $"{indexName}-alias";
var policyName = $"{indexName}-policy";
var firstIndexName = $"{indexName}-000001";

PUT _ilm/policy/index_name-policy
{
    "policy": {
        "phases": {
            "hot": {
                "actions": {
                    "rollover": {
                        "max_size": "5gb",
                        "max_docs": 10000,
                        "max_age":"2d"
                    }
                }
            },
            "warm": {
                "min_age": "5d",
                "actions": {
                }
            },
            "delete": {
                "min_age": "10d",
                "actions": {
                    "delete": {}
                }
            }
        }
    }
}

PUT _template/index_name-template
{
    "index_patterns": ["{{.IndexPattern}}"],
    "settings": {
        "index.number_of_shards": "1",
        "index.number_of_replicas": "1",
        "index.lifecycle.name": "{{.PolicyName}}", 
        "index.lifecycle.rollover_alias": "{{.AliasName}}" 
    },
    "mappings": {
         "_source": {
            "enabled": true
         },
         "properties": {
            {{Properties}}
        }
    }
}

PUT index_name-000001
{
   "aliases": {
        "{{.AliasName}}":{
            "is_write_index": true 
        }
    }
}