创建应用于ElasticSearch中所有索引模板的正确方法



我还是ElasticSearch技术的新手,现在很难创建适用于所有新索引的索引模板,但无法创建正确的索引。

目前正在运行ElasticSearch 7.9.2及其文档索引模板,通知index_patterns字段是必需的,并且应该是通配符数组(*匹配任何字符串(。

当然,我已经尝试通过Kibana的控制台使用["*"]作为模式来请求:

PUT _index_template/template_1
{
"index_patterns": ["*"],
"priority": 0
}

我有:

{
"error" : {
"root_cause" : [
{
"type" : "null_pointer_exception",
"reason" : null
}
],
"type" : "null_pointer_exception",
"reason" : null
},
"status" : 500
}

而对于添加空settings:的请求

PUT _index_template/template_1
{
"index_patterns": ["*"],
"template": {
"settings": {

}
},
"priority": 0
}

我收到了:

#! Deprecation: index template [template_1] has index patterns [*] matching patterns from existing older templates [.monitoring-es,.triggered_watches,.management-beats,.transform-internal-005,.logstash-management,.monitoring-kibana,.kibana-event-log-7.9.2-template,.ml-config,.watch-history-11,.ml-meta,ilm-history,.monitoring-logstash,.ml-state,.slm-history,.ml-inference-000002,.monitoring-beats,.monitoring-alerts-7,.ml-anomalies-,.watches,.ml-notifications-000001,.transform-notifications-000002,.ml-stats] with patterns (.monitoring-es => [.monitoring-es-7-*],.triggered_watches => [.triggered_watches*],.management-beats => [.management-beats],.transform-internal-005 => [.transform-internal-005],.logstash-management => [.logstash],.monitoring-kibana => [.monitoring-kibana-7-*],.kibana-event-log-7.9.2-template => [.kibana-event-log-7.9.2-*],.ml-config => [.ml-config],.watch-history-11 => [.watcher-history-11*],.ml-meta => [.ml-meta],ilm-history => [ilm-history-2*],.monitoring-logstash => [.monitoring-logstash-7-*],.ml-state => [.ml-state*],.slm-history => [.slm-history-2*],.ml-inference-000002 => [.ml-inference-000002],.monitoring-beats => [.monitoring-beats-7-*],.monitoring-alerts-7 => [.monitoring-alerts-7],.ml-anomalies- => [.ml-anomalies-*],.watches => [.watches*],.ml-notifications-000001 => [.ml-notifications-000001],.transform-notifications-000002 => [.transform-notifications-*],.ml-stats => [.ml-stats-*]); this template [template_1] will take precedence during new index creation
{
"acknowledged" : true
}

响应仅取决于空template.settings的存在——它似乎有点bug。

尽管如此,后一种方法似乎有效,但贬低警告听起来很危险,令人沮丧(我曾尝试将优先级设置为0,但无济于事(。然而,"*"的6.8版本运动示例的文档。所以这种功能不久前就存在了。

如果有的话,构造";全部匹配";索引模板?

当前,要匹配所有索引,您确实需要使用*作为索引模式,并且存在警告,因为它将匹配任何内容,包括内部系统索引。

根据模板中的内容,这可能会导致工作不正常或破坏您的系统。

github上有一个悬而未决的问题,主要是关于.security索引,当您使用match-all索引模式时,它也会受到影响,还有另一个悬而未决问题也涉及这个问题。

最新更新