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
An index can only rollover if it is the current write index for an alias that's pointing to multiple indexes. To prevent those problems, don't configure aliases in the index template. It's fine to use index templates for settings and mappings, but not for the alias. You configure the alias when you create the first index.
Creating an alias with the lifecycle policy is a 3 step process. Create a lifecycle policy that defines the appropriate phases and actions. Create an index template to apply the policy to each new index. Bootstrap an index as the initial write index. I think you are creating the template AFTER you create the first index.
This works because the alias will have one "write index", which is always pointing to the current active index. When an index rolls over from my_index-000002 to my_index-000003, the write index is automatically adjusted. The error you were seeing has to do with the alias.
This would cause problems indexing the data, because Elasticsearch would not know what index to write the documents to. It also caused problems with the rollover API. An index can only rollover if it is the current write index for an alias that's pointing to multiple indexes.
Creating an alias with the lifecycle policy is a 3 step process.
Elastic provides a great tutorial
In short:
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
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With