diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 5531fcb47ecc..b5c152df27e1 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -174,6 +174,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Fix role_arn to work with access keys for AWS. {pull}25446[25446] - Fix `community_id` processor so that ports greater than 65535 aren't valid. {pull}25409[25409] - Fix ILM alias creation when write alias exists and initial index does not exist {pull}26143[26143] +- Omit full index template from errors that occur while loading the template. {pull}25743[25743] - In the script processor, the `decode_xml` and `decode_xml_wineventlog` processors are now available as `DecodeXML` and `DecodeXMLWineventlog` respectively. - Fix encoding errors when using the disk queue on nested data with multi-byte characters {pull}26484[26484] diff --git a/libbeat/template/load.go b/libbeat/template/load.go index e5ada6ca9e80..45673c2b61bc 100644 --- a/libbeat/template/load.go +++ b/libbeat/template/load.go @@ -40,7 +40,7 @@ var ( } ) -//Loader interface for loading templates +// Loader interface for loading templates. type Loader interface { Load(config TemplateConfig, info beat.Info, fields []byte, migration bool) error } @@ -82,15 +82,15 @@ func NewFileLoader(c FileClient) *FileLoader { return &FileLoader{client: c} } -// Load checks if the index mapping template should be loaded +// Load checks if the index mapping template should be loaded. // In case the template is not already loaded or overwriting is enabled, the -// template is built and written to index +// template is built and written to index. func (l *ESLoader) Load(config TemplateConfig, info beat.Info, fields []byte, migration bool) error { if l.client == nil { return errors.New("can not load template without active Elasticsearch client") } - //build template from config + // build template from config tmpl, err := template(config, info, l.client.GetVersion(), migration) if err != nil || tmpl == nil { return err @@ -108,19 +108,20 @@ func (l *ESLoader) Load(config TemplateConfig, info beat.Info, fields []byte, mi } if exists && !config.Overwrite { - logp.Info("Template %s already exists and will not be overwritten.", templateName) + logp.Info("Template %q already exists and will not be overwritten.", templateName) return nil } - //loading template to ES + // loading template to ES body, err := buildBody(tmpl, config, fields) if err != nil { return err } if err := l.loadTemplate(templateName, config.Type, body); err != nil { - return fmt.Errorf("could not load template. Elasticsearch returned: %v. Template is: %s", err, body.StringToPrint()) + return fmt.Errorf("failed to load template: %w", err) } - logp.Info("template with name '%s' loaded.", templateName) + + logp.Info("Template with name %q loaded.", templateName) return nil } diff --git a/libbeat/tests/system/test_template.py b/libbeat/tests/system/test_template.py index 35dc8915a082..3fb3eb53351e 100644 --- a/libbeat/tests/system/test_template.py +++ b/libbeat/tests/system/test_template.py @@ -107,7 +107,7 @@ def test_json_template(self): proc = self.start_beat() self.wait_until(lambda: self.log_contains("mockbeat start running.")) self.wait_until(lambda: self.log_contains("Loading json template from file")) - self.wait_until(lambda: self.log_contains("template with name 'bla' loaded")) + self.wait_until(lambda: self.log_contains('Template with name "bla" loaded.')) proc.check_kill_and_wait() result = es.transport.perform_request('GET', '/_template/' + template_name) @@ -149,7 +149,7 @@ def test_template_default(self): self.render_config() proc = self.start_beat() self.wait_until(lambda: self.log_contains("mockbeat start running.")) - self.wait_until(lambda: self.log_contains("template with name 'mockbeat-9.9.9' loaded")) + self.wait_until(lambda: self.log_contains('Template with name "mockbeat-9.9.9" loaded.')) self.wait_until(lambda: self.log_contains("PublishEvents: 1 events have been published")) proc.check_kill_and_wait()