How to create aliases for all indices of a pattern?

(Paul Nibin) #1

I want to add multiple filtered alilases to all indexes of the pattern "metrics-DD.MM.YYYY".

Each filtered alias is for particular(the user field in the document has the userInformation. This is the field, I have used for filtering in the alias.).

I tried creating the alias for the pattern.

curl -XPOST 'http://localhost:9200/_aliases' -d '{
"actions" : [
        "add" : {
             "index" : "metrics-*",
             "alias" : "kimchy-metrics",
             "filter" : { "term" : { "user" : "kimchy" } }


This adds the alias for the indexes, with the pattern metrics-*, till the alias creation. But next day, when a new index "metrics-28.08.2015" is created, the alias is not created for that.

The following is from the elasticsearch reference.

In this case, the alias is a point-in-time alias that will group all current indices that match, it will not automatically update as new indices that match this pattern are added/removed.

So I suppose this approach won't work.

Other way to do this, is through index templates. However, during the index template creation, I do not have details about all the users. New users can be added in runtime. One way to achieve this is to update the index template, whenever a new user is created. Is that the suggested way to do this? Is there any limitations to no of aliases, that can be specified in an index template? How about 100s or 1000s of filtered aliases? Will ES support that many aliases in the template? Will there be performance implications, when a new index of that pattern is created(As ES has to add all the configured aliases to the new index)?

I also tried alias over an alias approach. In index template, I used a common alias called "all-metrics", so that all the newly created indexes will be added to this alias. And the actual user alias is over "all-metrics" instead of "metrics-*". Unfortunately, this approach also did not work.

Another way would be to run a SchduledTask, which will run @ 12 AM every day, which will add the newly created index to all user aliases.

All these approaches looks like a hack, to get a feature which should be available in ES. Am I missing a feature here? Is there any other way in ES to do what I want?


(Paul Nibin) #2

I am using ElasticSearch 1.7.1, if that matters.

(Mark Walkom) #3

You can use Elasticsearch Curator to do that.

But there is no way other than templates to make this "proactive".

(system) #4