From 3e2ea878c8f2cdd538715844934c2e8fe8af51e9 Mon Sep 17 00:00:00 2001 From: Gil Raphaelli Date: Mon, 11 Jun 2018 05:08:47 -0400 Subject: [PATCH] permit index-pattern only setup (#7285) with setup.dashboards.enabled=true, setup.dashboards.only_index=true always throws "Error importing Kibana dashboards: fail to import the dashboards in Kibana" (cherry picked from commit ee0dc3e8f93f3752facaa4897a98c418314a44d8) --- CHANGELOG.asciidoc | 2 ++ libbeat/dashboards/importer.go | 4 +++- libbeat/tests/system/test_dashboard.py | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 1b13fa9a3b7c..078290421614 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -13,6 +13,8 @@ https://github.com/elastic/beats/compare/v6.3.0...6.3[Check the HEAD diff] *Affecting all Beats* +- Allow index-pattern only setup when setup.dashboards.only_index=true. {pull}7285[7285] + *Auditbeat* *Filebeat* diff --git a/libbeat/dashboards/importer.go b/libbeat/dashboards/importer.go index a3027641652a..7256b3d2fce8 100644 --- a/libbeat/dashboards/importer.go +++ b/libbeat/dashboards/importer.go @@ -278,8 +278,10 @@ func (imp Importer) ImportKibanaDir(dir string) error { if !imp.cfg.OnlyDashboards { check = append(check, "index-pattern") } + wantDashboards := false if !imp.cfg.OnlyIndex { check = append(check, "dashboard") + wantDashboards = true } types := []string{} @@ -306,7 +308,7 @@ func (imp Importer) ImportKibanaDir(dir string) error { } } - if !importDashboards { + if wantDashboards && !importDashboards { return fmt.Errorf("No dashboards to import. Please make sure the %s directory contains a dashboard directory.", dir) } diff --git a/libbeat/tests/system/test_dashboard.py b/libbeat/tests/system/test_dashboard.py index fc9b16637788..8173c954f7d7 100644 --- a/libbeat/tests/system/test_dashboard.py +++ b/libbeat/tests/system/test_dashboard.py @@ -36,6 +36,32 @@ def test_load_dashboard(self): assert self.log_contains("Kibana dashboards successfully loaded") is True + @unittest.skipUnless(INTEGRATION_TESTS, "integration test") + @attr('integration') + def test_load_only_index_patterns(self): + """ + Test loading dashboards + """ + self.render_config_template() + beat = self.start_beat( + logging_args=["-e", "-d", "*"], + extra_args=["setup", + "--dashboards", + "-E", "setup.dashboards.file=" + + os.path.join(self.beat_path, "tests", "files", "testbeat-dashboards.zip"), + "-E", "setup.dashboards.beat=testbeat", + "-E", "setup.dashboards.only_index=true", + "-E", "setup.kibana.protocol=http", + "-E", "setup.kibana.host=" + self.get_kibana_host(), + "-E", "setup.kibana.port=" + self.get_kibana_port(), + "-E", "output.elasticsearch.hosts=['" + self.get_host() + "']", + "-E", "output.file.enabled=false"] + ) + + beat.check_wait(exit_code=0) + + assert self.log_contains("Kibana dashboards successfully loaded") is True + @unittest.skipUnless(INTEGRATION_TESTS, "integration test") @attr('integration') def test_export_dashboard(self):