Can variables be used in elasticsearch index templates?

。_饼干妹妹 提交于 2021-02-20 05:11:32

问题


I have a variety of elasticsearch indices which are created daily by logstash with the format:

"logstash-%{cluster_type}-%{cluster_name}-jobaccounting-v2-%{+YYYY.MM.dd}"

I would like to create an alias in elasticsearch which drops the version number from the index name. I am planning to point my kibana instance at the aliased index rather than the versioned index so that I can change the version numbers without impacting kibana.

index: "logstash-%{cluster_type}-%{cluster_name}-jobaccounting-v2-%{+YYYY.MM.dd}"

alias: "logstash-%{cluster_type}-%{cluster_name}-jobaccounting-%{+YYYY.MM.dd}"

Elasticsearch index templates can be used to create an alias everytime a new index is created. https://www.elastic.co/blog/aliases-ftw

Unfortuantely, I have not found any good way to use variables in the alias name. I would like to avoid having to create a template for every cluster_type, cluster_name, and date.

If I had 2 entries for each variable cluster_name and cluster_type, I would have 4 indices every day, which would require 4 aliases for each day.

If I could use a date variable, then I could just have 4 templates rather than 4 templates for each day.

Is there a way to use a date variable in the alias name? Does taking this approach make sense?


回答1:


The only available placeholder is {index}, so you can't compose more complex alias name inside template. https://www.elastic.co/blog/aliases-ftw



来源:https://stackoverflow.com/questions/36288714/can-variables-be-used-in-elasticsearch-index-templates

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