I have the following ilm (ignore the minimum ages, it's for testing):
"somerandomilm": {
"version": 3,
"modified_date": "2020-04-09T16:09:16.952Z",
"policy": {
"phases": {
"warm": {
"min_age": "3m",
"actions": {
"allocate": {
"include": {
"phase_id": "warm"
},
"exclude": {},
"require": {}
},
"shrink": {
"number_of_shards": 1
},
"forcemerge": {
"max_num_segments": 1
},
"set_priority": {
"priority": 25
}
}
},
"cold": {
"min_age": "5m",
"actions": {
"allocate": {
"include": {
"phase_id": "cold"
},
"exclude": {},
"require": {}
},
"set_priority": {
"priority": 25
}
}
},
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_size": "30gb",
"max_age": "3m"
},
"set_priority": {
"priority": 50
}
}
}
}
}
}
and first starting index:
"somerandomindexname-000001": {
"aliases": {
"genericrolloveralias": {
"is_write_index": false
}
},
"mappings": {
"properties": {
"Id": {
"type": "text"
},
"SomeOtherProperty": {
"type": "text"
},
"SomeOtherProperty2": {
"type": "text"
}
}
},
"settings": {
"index": {
"lifecycle": {
"name": "somerandomilm",
"rollover_alias": "genericrolloveralias",
"indexing_complete": "true"
},
"routing": {
"allocation": {
"include": {
"phase_id": "warm"
}
}
},
"number_of_shards": "1",
"provided_name": "somerandomindexname-000001",
"creation_date": "1586447619447",
"priority": "25",
"number_of_replicas": "1",
"uuid": "ByKhH8dnR_Sx50GwWNjJaQ",
"version": {
"created": "7060099"
}
}
}
}
template:
"randomtemplate_template": {
"order": 0,
"index_patterns": [
"somerandomindexname-*"
],
"settings": {
"index": {
"lifecycle": {
"name": "somerandomilm",
"rollover_alias": "genericrolloveralias"
},
"number_of_shards": "1",
"number_of_replicas": "1"
}
},
"mappings": {},
"aliases": {}
},
Is it possible to get elastic to add extra aliases to the indeces depending on what phase it's currently moving to?
Ie: when an index gets moved to warm, could all indeces in warm have an extra alias added indicating what phase it is in? My end goal is to be able to query specific nodes like hot/warm and my understanding is that this is achievable via aliases.
Solved this by making a call to the ILM explain api which provides a list of indices and what their current phase is. Once I have the list I can filter out any indices that have moved or is moving to the warm phase and run a bulk alias operation.
var resp = _client.IndexLifecycleManagement.ExplainLifecycleAsync(new ExplainLifecycleRequest(_hotIndexAlias));
var warmPhaseIndices = resp .Indices.Where(i => i.Value.Phase == "warm").ToList();