Skip to content

Commit

Permalink
Disable the option of running setup --machine-learning on its own
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch committed Jul 28, 2020
1 parent c2906f4 commit 927f54b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion filebeat/tests/system/test_ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _run_ml_test(self, modules_flag):

# Skipping dashboard loading to speed up tests
cmd += ["-E", "setup.dashboards.enabled=false"]
cmd += ["setup", "--machine-learning"]
cmd += ["setup", "--machine-learning", "--dashboards"]
if modules_flag:
cmd += ["--modules=nginx"]

Expand Down
7 changes: 7 additions & 0 deletions libbeat/cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ func genSetupCmd(settings instance.Settings, beatCreator beat.Creator) *cobra.Co
}
}

// XXX this is a workaround for installing index template patterns
// before enabling ML for modules
if s.MachineLearning && !s.Dashboard {
fmt.Fprintf(os.Stderr, "--dashboards must be specified when choosing --machine-learning\n")
os.Exit(1)
}

if err = beat.Setup(settings, beatCreator, s); err != nil {
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion libbeat/ml-importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func SetupModule(kibanaClient MLSetupper, module, prefix string) error {
prefixPayload := fmt.Sprintf("{\"prefix\": \"%s\"}", prefix)
status, response, err := kibanaClient.Request("POST", setupURL, nil, nil, strings.NewReader(prefixPayload))
if status != 200 {
return errors.Errorf("cannot set up ML with prefix: %s", prefix)
return errors.Errorf("cannot set up ML with prefix: %s, response: %s", prefix, string(response))
}
if err != nil {
return err
Expand Down

0 comments on commit 927f54b

Please sign in to comment.