elasticsearch模板-从index_pattern创建别名 [英] elasticsearch templates - create alias from index_pattern

查看:129
本文介绍了elasticsearch模板-从index_pattern创建别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有索引模式的Elasticsearch模板: prefix _ * .

I have an Elasticsearch template with the index pattern: prefix_*.

我也有多个子系统使用此模板并像这样创建索引: prefix_ {subsystem_name} _ {date} (分别替换{subsystem_name}和{name})

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)

例如对于索引"prefix_monitors_20200101",我将具有别名"monitors",对于"prefix_alerts_20200101",我将具有别名"alerts"

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"

我该怎么做?

推荐答案

您将需要为每个子系统创建一个额外的索引模板,例如针对监视器的该示例:

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" : {}
  }
}

创建并匹配该模式的所有新索引将应用您当前的索引模板以及上面的示例模板,该模板在该模式中更加具体.该模板负责为新创建的索引分配别名 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.

这篇关于elasticsearch模板-从index_pattern创建别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆