diff --git a/heartbeat/cmd/root.go b/heartbeat/cmd/root.go index 8557971f524..6dee7e2a94b 100644 --- a/heartbeat/cmd/root.go +++ b/heartbeat/cmd/root.go @@ -19,15 +19,36 @@ package cmd import ( // register default heartbeat monitors - _ "github.com/elastic/beats/heartbeat/monitors/defaults" - "github.com/elastic/beats/libbeat/cmd/instance" - "github.com/elastic/beats/heartbeat/beater" + _ "github.com/elastic/beats/heartbeat/monitors/defaults" cmd "github.com/elastic/beats/libbeat/cmd" + "github.com/elastic/beats/libbeat/cmd/instance" ) // Name of this beat var Name = "heartbeat" // RootCmd to handle beats cli -var RootCmd = cmd.GenRootCmdWithSettings(beater.New, instance.Settings{Name: Name}) +var RootCmd *cmd.BeatsRootCmd + +func init() { + RootCmd = cmd.GenRootCmdWithSettings(beater.New, instance.Settings{Name: Name}) + + // remove dashboard from export commands + for _, cmd := range RootCmd.ExportCmd.Commands() { + if cmd.Name() == "dashboard" { + RootCmd.ExportCmd.RemoveCommand(cmd) + } + } + + // only add defined flags to setup command + setup := RootCmd.SetupCmd + setup.Short = "Setup Elasticsearch index template and pipelines" + setup.Long = `This command does initial setup of the environment: + * Index mapping template in Elasticsearch to ensure fields are mapped. + * ILM Policy +` + setup.ResetFlags() + setup.Flags().Bool(cmd.TemplateKey, false, "Setup index template") + setup.Flags().Bool(cmd.ILMPolicyKey, false, "Setup ILM policy") +}