Skip to content

Commit

Permalink
Allow specifying Kibana URL for mage ExportDashboard (#10145)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Christoph Wurm authored Jan 25, 2019
1 parent 2034fe4 commit 2bb0a34
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions dev-tools/cmd/dashboards/export_dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func main() {
Host: u.Host,
Username: user,
Password: pass,
Path: u.Path,
SpaceID: *spaceID,
Timeout: kibanaTimeout,
})
Expand Down
8 changes: 7 additions & 1 deletion dev-tools/mage/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,5 +51,9 @@ func ExportDashboard() error {
"-output", file, "-dashboard", id,
)

return dashboardCmd()
if kibanaURL != "" {
return dashboardCmd("-kibana", kibanaURL)
} else {
return dashboardCmd()
}
}
4 changes: 2 additions & 2 deletions libbeat/kibana/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2bb0a34

Please sign in to comment.