问题
I have an Elasticsearch template with the index pattern: prefix_*
.
I also have multiple subsystems using this template and creating indexes like so: prefix_{subsystem_name}_{date}
(replacing {subsystem_name} and {name} respectively)
I would like to create for each subsystem a separate alias (of its subsystem)
for example for an index "prefix_monitors_20200101" I will have an alias "monitors" and for "prefix_alerts_20200101" I will have an alias "alerts"
How do I do such a thing?
回答1:
You'll need to create a additional index template for each subsystem like this example for monitors:
PUT _template/template_monitor_alias
{
"index_patterns" : ["prefix_monitors_*"],
"aliases" : {
"monitors" : {}
}
}
All new indices created and matchin the pattern will then apply your current index template AND the example template above which is a little more specific in the pattern. The template takes care of assigning the alias monitors
to the newly created indices.
来源:https://stackoverflow.com/questions/59920489/elasticsearch-templates-create-alias-from-index-pattern