GKman
GKman

Reputation: 533

elasticsearch templates - create alias from index_pattern

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?

Upvotes: 0

Views: 1177

Answers (1)

ibexit
ibexit

Reputation: 3667

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.

Upvotes: 2

Related Questions