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

半城伤御伤魂 提交于 2020-08-05 17:25:07

问题


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


回答1:


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 
        }
    }
}



来源:https://stackoverflow.com/questions/60377948/illegal-argument-exception-index-lifecycle-rollover-alias-metricbeat-6-8-4-ali

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!