Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update export_dashboards.go #7101

Merged
merged 4 commits into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ https://github.com/elastic/beats/compare/v6.2.3...master[Check the HEAD diff]
execve, execveat, fork, and vfork syscalls. A custom policy can be configured. {issue}5213[5213]
- Update Sarama to v1.16.0, adding better support for kafka 0.11, 1.0, and 1.1 {pull}7025[7025]
- Ship fields.yml as part of the binary {pull}4834[4834]
- Added options to dev-tools/cmd/dashboards/export_dashboard.go: -indexPattern to include index-pattern in output, -quiet to be quiet. {pull}7101[7101]
- Add Indexer indexing by pod uid. Enable pod uid metadata gathering in add_kubernetes_metadata. Extended Matcher log_path matching to support volume mounts {pull}7072[7072]

*Auditbeat*
Expand Down
15 changes: 12 additions & 3 deletions dev-tools/cmd/dashboards/export_dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func ExtractIndexPattern(body []byte) ([]byte, error) {
if !ok {
return nil, fmt.Errorf("type key not found or not string")
}
if _type != "index-pattern" {
if _type != "index-pattern" || indexPattern {
result = append(result, obj)
}
}
Expand All @@ -68,7 +68,9 @@ func Export(client *http.Client, conn string, dashboard string, out string) erro
params.Add("dashboard", dashboard)

fullURL := makeURL(conn, exportAPI, params)
fmt.Printf("Calling HTTP GET %v\n", fullURL)
if !quiet {
fmt.Printf("Calling HTTP GET %v\n", fullURL)
}

req, err := http.NewRequest("GET", fullURL, nil)

Expand All @@ -95,7 +97,9 @@ func Export(client *http.Client, conn string, dashboard string, out string) erro

err = ioutil.WriteFile(out, body, 0666)

fmt.Printf("The dashboard %s was exported under the %s file\n", dashboard, out)
if !quiet {
fmt.Printf("The dashboard %s was exported under the %s file\n", dashboard, out)
}
return err
}

Expand All @@ -113,11 +117,16 @@ func ReadManifest(file string) ([]map[string]string, error) {
return manifest.Dashboards, nil
}

var indexPattern = false
var quiet = false

func main() {
kibanaURL := flag.String("kibana", "http://localhost:5601", "Kibana URL")
dashboard := flag.String("dashboard", "", "Dashboard ID")
fileOutput := flag.String("output", "output.json", "Output file")
ymlFile := flag.String("yml", "", "Path to the module.yml file containing the dashboards")
flag.BoolVar(&indexPattern, "indexPattern", false, "include index-pattern in output")
flag.BoolVar(&quiet, "quiet", false, "be quiet")

flag.Parse()

Expand Down