elasticsearch templates - create alias from index_pattern

为君一笑 提交于 2021-01-28 19:21:46

问题


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

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