From 2bb0a349ef7f8077a6ae3561d477af4f1c6a89d4 Mon Sep 17 00:00:00 2001 From: Christoph Wurm Date: Fri, 25 Jan 2019 10:06:48 +0000 Subject: [PATCH] Allow specifying Kibana URL for mage ExportDashboard (#10145) Changes the `mage ExportDashboard` command to take into account a `KIBANA_URL` environment variable that allows specifying a custom Kibana URL like `http://localhost:5603/kva` to allow exporting dashboards. --- dev-tools/cmd/dashboards/export_dashboards.go | 1 + dev-tools/mage/dashboard.go | 8 +++++++- libbeat/kibana/client.go | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dev-tools/cmd/dashboards/export_dashboards.go b/dev-tools/cmd/dashboards/export_dashboards.go index 5424f35361f5..26dbc68d486d 100644 --- a/dev-tools/cmd/dashboards/export_dashboards.go +++ b/dev-tools/cmd/dashboards/export_dashboards.go @@ -66,6 +66,7 @@ func main() { Host: u.Host, Username: user, Password: pass, + Path: u.Path, SpaceID: *spaceID, Timeout: kibanaTimeout, }) diff --git a/dev-tools/mage/dashboard.go b/dev-tools/mage/dashboard.go index 593b7184c3cb..38f6a378e7ab 100644 --- a/dev-tools/mage/dashboard.go +++ b/dev-tools/mage/dashboard.go @@ -36,6 +36,8 @@ func ExportDashboard() error { return fmt.Errorf("Dashboad ID must be specified") } + kibanaURL := EnvOr("KIBANA_URL", "") + beatsDir, err := ElasticBeatsDir() if err != nil { return err @@ -49,5 +51,9 @@ func ExportDashboard() error { "-output", file, "-dashboard", id, ) - return dashboardCmd() + if kibanaURL != "" { + return dashboardCmd("-kibana", kibanaURL) + } else { + return dashboardCmd() + } } diff --git a/libbeat/kibana/client.go b/libbeat/kibana/client.go index 115a1bffc299..d759ad432fbc 100644 --- a/libbeat/kibana/client.go +++ b/libbeat/kibana/client.go @@ -217,8 +217,8 @@ func (client *Client) readVersion() error { code, result, err := client.Connection.Request("GET", "/api/status", nil, nil, nil) if err != nil || code >= 400 { - return fmt.Errorf("HTTP GET request to /api/status fails: %v. Response: %s.", - err, truncateString(result)) + return fmt.Errorf("HTTP GET request to %s/api/status fails: %v. Response: %s.", + client.Connection.URL, err, truncateString(result)) } var versionString string