Skip to content

Commit

Permalink
permit index-pattern only setup (elastic#7285)
Browse files Browse the repository at this point in the history
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 ee0dc3e)
  • Loading branch information
graphaelli authored and ruflin committed Jun 18, 2018
1 parent 385cbb7 commit 3e2ea87
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
4 changes: 3 additions & 1 deletion libbeat/dashboards/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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)
}
Expand Down
26 changes: 26 additions & 0 deletions libbeat/tests/system/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3e2ea87

Please sign in to comment.