From 7589a16ac15edb22ffbd258a57c0e8753f913f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20P=C3=A9rez-Aradros=20Herce?= Date: Wed, 19 Apr 2017 16:58:28 +0200 Subject: [PATCH] Add support for templates `index_patterns`field in ES >= 6.0 The change was introduced in https://github.com/elastic/elasticsearch/pull/21009 and deprecates old `template` field. This change uses the new `index_patterns` field and keeps compatibility with `template` for older version --- CHANGELOG.asciidoc | 1 + libbeat/template/template.go | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 48fb33db0a3..93313024611 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -100,6 +100,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff] - Updated to Go 1.8.1. {pull}4033[4033] - Add kubernetes processor {pull}3888[3888] - Add support for include_labels and include_annotations in kubernetes processor {pull}4043[4043] +- Support new `index_patterns` field when loading templates for Elasticsearch >= 6.0 {pull}4056[4056] *Filebeat* diff --git a/libbeat/template/template.go b/libbeat/template/template.go index 7c5e61664ce..a8e9dd9a226 100644 --- a/libbeat/template/template.go +++ b/libbeat/template/template.go @@ -106,7 +106,13 @@ func (t *Template) generate(properties common.MapStr, dynamicTemplates []common. "settings": common.MapStr{ "index.refresh_interval": "5s", }, - "template": t.GetName() + "-*", + } + + // ES 6 moved from template to index_patterns: https://github.com/elastic/elasticsearch/pull/21009 + if t.esVersion.major >= 6 { + basicStructure.Put("index_patterns", []string{t.GetName() + "-*"}) + } else { + basicStructure.Put("template", t.GetName()+"-*") } if t.esVersion.IsMajor(2) {