diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 9408add3158c..e0800d0888e5 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -18,6 +18,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Fix metrics not being ingested, due to "Limit of total fields [10000] has been exceeded while adding new fields [...]". The total fields limit has been increased to 12500. No significant performance impact on Elasticsearch is anticipated. {pull}41640[41640] - Set default kafka version to 2.1.0 in kafka output and filebeat. {pull}41662[41662] - Fix templates and docs to use correct `--` version of command line arguments. {issue}42038[42038] {pull}42060[42060] +- removed support for a single `-` to precede multi-letter command line arguments. Use `--` instead. {issue}42117[42117] {pull}99999[99999] *Auditbeat* diff --git a/auditbeat/main_test.go b/auditbeat/main_test.go index 8b16fe63a583..f91bc1f94822 100644 --- a/auditbeat/main_test.go +++ b/auditbeat/main_test.go @@ -24,7 +24,6 @@ import ( "testing" "github.com/elastic/beats/v7/auditbeat/cmd" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/tests/system/template" ) @@ -35,14 +34,11 @@ func init() { systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(*testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/auditbeat/tests/system/test_show_command.py b/auditbeat/tests/system/test_show_command.py index 843ab7e829dc..5e14f9af1442 100644 --- a/auditbeat/tests/system/test_show_command.py +++ b/auditbeat/tests/system/test_show_command.py @@ -57,7 +57,7 @@ def test_show_auditd_rules(self): } }] ) - proc = self.start_beat(extra_args=['-strict.perms=false']) + proc = self.start_beat(extra_args=['--strict.perms=false']) # auditbeat adds an extra rule to ignore itself self.wait_log_contains('Successfully added {0} of {0} audit rules.'.format(len(rules) + 1), max_timeout=30) diff --git a/dev-tools/cmd/dashboards/export_dashboards.go b/dev-tools/cmd/dashboards/export_dashboards.go index c6f109375c4e..a2711287b615 100644 --- a/dev-tools/cmd/dashboards/export_dashboards.go +++ b/dev-tools/cmd/dashboards/export_dashboards.go @@ -46,7 +46,7 @@ func main() { insecure := flag.Bool("insecure", false, "Disable TLS verification.") spaceID := flag.String("space-id", "", "Space ID") dashboard := flag.String("dashboard", "", "Dashboard ID") - fileOutput := flag.String("output", "", "Output NDJSON file, when exporting dashboards for Beats, please use -folder instead") + fileOutput := flag.String("output", "", "Output NDJSON file, when exporting dashboards for Beats, please use --folder instead") folderOutput := flag.String("folder", "", "Output folder to save all assets to more human friendly JSON format") ymlFile := flag.String("yml", "", "Path to the module.yml file containing the dashboards") flag.BoolVar(&indexPattern, "indexPattern", false, "include index-pattern in output") @@ -56,7 +56,7 @@ func main() { log.SetFlags(0) if len(*fileOutput) > 0 { - log.Fatalf("-output is configured, please use -folder flag instead to get the expected formatting of assets") + log.Fatalf("-output is configured, please use --folder flag instead to get the expected formatting of assets") } u, err := url.Parse(*kibanaURL) @@ -92,10 +92,10 @@ func main() { if len(*ymlFile) == 0 && len(*dashboard) == 0 { flag.Usage() - log.Fatalf("Please specify a dashboard ID (-dashboard) or a manifest file (-yml)") + log.Fatalf("Please specify a dashboard ID (--dashboard) or a manifest file (--yml)") } if len(*folderOutput) == 0 { - log.Fatalf("Please specify a target folder using -folder flag") + log.Fatalf("Please specify a target folder using --folder flag") } if len(*ymlFile) > 0 { diff --git a/dev-tools/mage/dashboard.go b/dev-tools/mage/dashboard.go index 15f8ce3fb4e0..95596f2c3bcc 100644 --- a/dev-tools/mage/dashboard.go +++ b/dev-tools/mage/dashboard.go @@ -49,8 +49,8 @@ func ExportDashboard() error { folder := CWD("module", module) args := []string{ - "-folder", folder, - "-dashboard", id, + "--folder", folder, + "--dashboard", id, } if kibanaURL := EnvOr("KIBANA_URL", ""); kibanaURL != "" { args = append(args, "-kibana", kibanaURL) diff --git a/dev-tools/mage/gotool/go.go b/dev-tools/mage/gotool/go.go index e507282c15ce..b0d20cc55485 100644 --- a/dev-tools/mage/gotool/go.go +++ b/dev-tools/mage/gotool/go.go @@ -163,7 +163,7 @@ func HasTests(pkg string) (bool, error) { } func (goTest) WithCoverage(to string) ArgOpt { - return combine(flagArg("-cover", ""), flagArgIf("-test.coverprofile", to)) + return combine(flagArg("-cover", ""), flagArgIf("--test.coverprofile", to)) } func (goTest) Short(b bool) ArgOpt { return flagBoolIf("-test.short", b) } func (goTest) Use(bin string) ArgOpt { return extraArgIf("use", bin) } diff --git a/docs/devguide/migrate-dashboards.asciidoc b/docs/devguide/migrate-dashboards.asciidoc index 453b065c90e2..8fd85ebb7e36 100644 --- a/docs/devguide/migrate-dashboards.asciidoc +++ b/docs/devguide/migrate-dashboards.asciidoc @@ -93,6 +93,6 @@ Using the yml file, you can export all the dashboards for a single module or for [source,shell] ---- cd metricbeat/module/system -go run ../../../dev-tools/cmd/dashboards/export_dashboards.go -yml module.yml +go run ../../../dev-tools/cmd/dashboards/export_dashboards.go --yml module.yml ---- diff --git a/docs/devguide/modules-dev-guide.asciidoc b/docs/devguide/modules-dev-guide.asciidoc index cab2b117133a..7e5178cd651c 100644 --- a/docs/devguide/modules-dev-guide.asciidoc +++ b/docs/devguide/modules-dev-guide.asciidoc @@ -100,7 +100,7 @@ Then run `export_dashboards` like this: ---- $ cd dev-tools/cmd/dashboards $ make # if export_dashboard is not built yet -$ ./export_dashboards -yml '../../../filebeat/module/{module}/module.yml' +$ ./export_dashboards --yml '../../../filebeat/module/{module}/module.yml' ---- New Filebeat modules might not be compatible with Kibana 5.x. To export dashboards diff --git a/docs/devguide/newdashboards.asciidoc b/docs/devguide/newdashboards.asciidoc index cb644036d251..9e540abb025a 100644 --- a/docs/devguide/newdashboards.asciidoc +++ b/docs/devguide/newdashboards.asciidoc @@ -253,7 +253,7 @@ MODULE=redis ID=AV4REOpp5NkDleZmzKkE mage exportDashboard [source,shell] --------------- -./filebeat export dashboard -id 7fea2930-478e-11e7-b1f0-cb29bac6bf8b -folder module/redis +./filebeat export dashboard --id 7fea2930-478e-11e7-b1f0-cb29bac6bf8b --folder module/redis --------------- This generates an appropriate folder under module/redis for the dashboard, separating assets into dashboards, searches, vizualizations, etc. @@ -289,12 +289,12 @@ By passing the yml file to the `export_dashboards.go` script or to the Beat, you [source,shell] ------------------- -go run dev-tools/cmd/dashboards/export_dashboards.go -yml filebeat/module/system/module.yml -folder dashboards +go run dev-tools/cmd/dashboards/export_dashboards.go --yml filebeat/module/system/module.yml --folder dashboards ------------------- [source,shell] ------------------- -./filebeat export dashboard -yml filebeat/module/system/module.yml +./filebeat export dashboard --yml filebeat/module/system/module.yml ------------------- diff --git a/filebeat/beater/filebeat.go b/filebeat/beater/filebeat.go index 4909941b90ae..6889aac3a68e 100644 --- a/filebeat/beater/filebeat.go +++ b/filebeat/beater/filebeat.go @@ -166,7 +166,7 @@ func newBeater(b *beat.Beat, plugins PluginFactory, rawConfig *conf.C) (beat.Bea } if *once && config.ConfigInput.Enabled() && config.ConfigModules.Enabled() { - return nil, fmt.Errorf("input configs and -once cannot be used together") + return nil, fmt.Errorf("input configs and --once cannot be used together") } if config.IsInputEnabled("stdin") && len(enabledInputs) > 1 { diff --git a/filebeat/cmd/generate.go b/filebeat/cmd/generate.go index 1e5a4b1a819b..582038716a1e 100644 --- a/filebeat/cmd/generate.go +++ b/filebeat/cmd/generate.go @@ -26,7 +26,6 @@ import ( "github.com/elastic/beats/v7/filebeat/generator/fields" "github.com/elastic/beats/v7/filebeat/generator/fileset" "github.com/elastic/beats/v7/filebeat/generator/module" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/common/cli" "github.com/elastic/elastic-agent-libs/paths" ) @@ -64,9 +63,7 @@ func genGenerateModuleCmd() *cobra.Command { } genModuleCmd.Flags().String("modules-path", defaultHomePath, "Path to modules directory") - cfgfile.AddAllowedBackwardsCompatibleFlag("modules-path") genModuleCmd.Flags().String("es-beats", defaultHomePath, "Path to Elastic Beats") - cfgfile.AddAllowedBackwardsCompatibleFlag("es-beats") return genModuleCmd } @@ -91,9 +88,7 @@ func genGenerateFilesetCmd() *cobra.Command { } genFilesetCmd.Flags().String("modules-path", defaultHomePath, "Path to modules directory") - cfgfile.AddAllowedBackwardsCompatibleFlag("modules-path") genFilesetCmd.Flags().String("es-beats", defaultHomePath, "Path to Elastic Beats") - cfgfile.AddAllowedBackwardsCompatibleFlag("es-beats") return genFilesetCmd } @@ -118,9 +113,7 @@ func genGenerateFieldsCmd() *cobra.Command { } genFieldsCmd.Flags().String("es-beats", defaultHomePath, "Path to Elastic Beats") - cfgfile.AddAllowedBackwardsCompatibleFlag("es-beats") genFieldsCmd.Flags().Bool("without-documentation", false, "Do not add description fields") - cfgfile.AddAllowedBackwardsCompatibleFlag("without-documentation") return genFieldsCmd } diff --git a/filebeat/cmd/root.go b/filebeat/cmd/root.go index 48e9c9d74bce..2420a03efdba 100644 --- a/filebeat/cmd/root.go +++ b/filebeat/cmd/root.go @@ -26,7 +26,6 @@ import ( "github.com/elastic/beats/v7/filebeat/fileset" "github.com/elastic/beats/v7/filebeat/include" "github.com/elastic/beats/v7/filebeat/input" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd" "github.com/elastic/beats/v7/libbeat/cmd/instance" @@ -50,9 +49,7 @@ func FilebeatSettings(moduleNameSpace string) instance.Settings { } runFlags := pflag.NewFlagSet(Name, pflag.ExitOnError) runFlags.AddGoFlag(flag.CommandLine.Lookup("once")) - cfgfile.AddAllowedBackwardsCompatibleFlag("once") runFlags.AddGoFlag(flag.CommandLine.Lookup("modules")) - cfgfile.AddAllowedBackwardsCompatibleFlag("modules") return instance.Settings{ RunFlags: runFlags, Name: Name, @@ -69,10 +66,8 @@ func FilebeatSettings(moduleNameSpace string) instance.Settings { func Filebeat(inputs beater.PluginFactory, settings instance.Settings) *cmd.BeatsRootCmd { command := cmd.GenRootCmdWithSettings(beater.New(inputs), settings) command.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("M")) - cfgfile.AddAllowedBackwardsCompatibleFlag("M") command.TestCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("modules")) command.SetupCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("modules")) - cfgfile.AddAllowedBackwardsCompatibleFlag("modules") command.AddCommand(cmd.GenModulesCmd(Name, "", buildModulesManager)) command.AddCommand(genGenerateCmd()) return command diff --git a/filebeat/main_test.go b/filebeat/main_test.go index b73c88438e6f..0f989a77a355 100644 --- a/filebeat/main_test.go +++ b/filebeat/main_test.go @@ -26,7 +26,6 @@ import ( fbcmd "github.com/elastic/beats/v7/filebeat/cmd" inputs "github.com/elastic/beats/v7/filebeat/input/default-inputs" - "github.com/elastic/beats/v7/libbeat/cfgfile" cmd "github.com/elastic/beats/v7/libbeat/cmd" "github.com/elastic/beats/v7/libbeat/tests/system/template" ) @@ -41,14 +40,11 @@ func init() { systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") fbCommand = fbcmd.Filebeat(inputs.Init, fbcmd.FilebeatSettings("")) fbCommand.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") fbCommand.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(t *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { if err := fbCommand.Execute(); err != nil { os.Exit(1) diff --git a/filebeat/tests/system/test_generate.py b/filebeat/tests/system/test_generate.py index c691a057358a..ba0dffe6a003 100644 --- a/filebeat/tests/system/test_generate.py +++ b/filebeat/tests/system/test_generate.py @@ -11,7 +11,7 @@ def test_generate_module(self): self._create_clean_test_modules() exit_code = self.run_beat( - extra_args=["generate", "module", "my_module", "-modules-path", "test_modules", "-es-beats", self.beat_path]) + extra_args=["generate", "module", "my_module", "--modules-path", "test_modules", "--es-beats", self.beat_path]) assert exit_code == 0 module_root = os.path.join("test_modules", "module", "my_module") @@ -47,11 +47,11 @@ def test_generate_fileset(self): self._create_clean_test_modules() exit_code = self.run_beat( - extra_args=["generate", "module", "my_module", "-modules-path", "test_modules", "-es-beats", self.beat_path]) + extra_args=["generate", "module", "my_module", "--modules-path", "test_modules", "--es-beats", self.beat_path]) assert exit_code == 0 exit_code = self.run_beat( - extra_args=["generate", "fileset", "my_module", "my_fileset", "-modules-path", "test_modules", "-es-beats", self.beat_path]) + extra_args=["generate", "fileset", "my_module", "my_fileset", "--modules-path", "test_modules", "--es-beats", self.beat_path]) assert exit_code == 0 fileset_root = os.path.join("test_modules", "module", "my_module", "my_fileset") @@ -88,11 +88,11 @@ def test_generate_fields_yml(self): self._create_clean_test_modules() exit_code = self.run_beat( - extra_args=["generate", "module", "my_module", "-modules-path", "test_modules", "-es-beats", self.beat_path]) + extra_args=["generate", "module", "my_module", "--modules-path", "test_modules", "--es-beats", self.beat_path]) assert exit_code == 0 exit_code = self.run_beat( - extra_args=["generate", "fileset", "my_module", "my_fileset", "-modules-path", "test_modules", "-es-beats", self.beat_path]) + extra_args=["generate", "fileset", "my_module", "my_fileset", "--modules-path", "test_modules", "--es-beats", self.beat_path]) assert exit_code == 0 test_pipeline_path = os.path.join(self.beat_path, "tests", "system", "input", "my-module-pipeline.json") @@ -102,7 +102,7 @@ def test_generate_fields_yml(self): shutil.copyfile(test_pipeline_path, fileset_pipeline) exit_code = self.run_beat( - extra_args=["generate", "fields", "my_module", "my_fileset", "-es-beats", "test_modules", "-without-documentation"]) + extra_args=["generate", "fields", "my_module", "my_fileset", "--es-beats", "test_modules", "--without-documentation"]) assert exit_code == 0 fields_yml_path = os.path.join("test_modules", "module", "my_module", "my_fileset", "_meta", "fields.yml") diff --git a/filebeat/tests/system/test_keystore.py b/filebeat/tests/system/test_keystore.py index 5946eb645456..ecf716ae0db4 100644 --- a/filebeat/tests/system/test_keystore.py +++ b/filebeat/tests/system/test_keystore.py @@ -55,7 +55,7 @@ def add_secret(self, key, value="hello world\n", force=False): Add new secret using the --stdin option """ args = [self.test_binary, - "-systemTest", + "--systemTest", "-c", os.path.join(self.working_dir, self.beat_name + ".yml"), "-e", "-v", "-d", "*", "keystore", "add", key, "--stdin", diff --git a/filebeat/tests/system/test_modules.py b/filebeat/tests/system/test_modules.py index f5e7bdc2c391..761cb4975058 100644 --- a/filebeat/tests/system/test_modules.py +++ b/filebeat/tests/system/test_modules.py @@ -168,11 +168,11 @@ def run_on_file(self, module, fileset, test_file, cfgfile): self.wait_until(lambda: not self.es.indices.exists(self.index_name)) cmd = [ - self.filebeat, "-systemTest", - "-d", "*", "-once", + self.filebeat, "--systemTest", + "-d", "*", "--once", "-c", cfgfile, "-E", "setup.ilm.enabled=false", - "-modules={}".format(module), + "--modules={}".format(module), "-M", "{module}.*.enabled=false".format(module=module), "-M", "{module}.{fileset}.enabled=true".format( module=module, fileset=fileset), @@ -191,7 +191,7 @@ def run_on_file(self, module, fileset, test_file, cfgfile): module=module, fileset=fileset)) if ".journal" in test_file: - cmd.remove("-once") + cmd.remove("--once") cmd.append("-M") cmd.append("{module}.{fileset}.var.use_journald=true".format( module=module, fileset=fileset)) @@ -224,7 +224,7 @@ def run_on_file(self, module, fileset, test_file, cfgfile): stderr=subprocess.STDOUT, bufsize=0) # The journald input (used by some modules like 'system') does not - # support the -once flag, hence we run Filebeat for at most + # support the --once flag, hence we run Filebeat for at most # 15 seconds, if it does not finish, then kill the process. # If for any reason the Filebeat process gets stuck, only SIGKILL # will terminate it. We use SIGKILL to avoid leaking any running diff --git a/filebeat/tests/system/test_shutdown.py b/filebeat/tests/system/test_shutdown.py index 8e7818377309..36d89dced7fe 100644 --- a/filebeat/tests/system/test_shutdown.py +++ b/filebeat/tests/system/test_shutdown.py @@ -141,7 +141,7 @@ def test_once(self): file.close() - filebeat = self.start_beat(extra_args=["-once"]) + filebeat = self.start_beat(extra_args=["--once"]) # Make sure all lines are read self.wait_until( diff --git a/filebeat/tests/system/test_stdin.py b/filebeat/tests/system/test_stdin.py index 02234a060c21..84914bde96bb 100644 --- a/filebeat/tests/system/test_stdin.py +++ b/filebeat/tests/system/test_stdin.py @@ -58,9 +58,9 @@ def test_stdin_eof(self): close_eof="true", ) - args = [self.test_binary, "-systemTest"] + args = [self.test_binary, "--systemTest"] if os.getenv("TEST_COVERAGE") == "true": - args += ["-test.coverprofile", + args += ["--test.coverprofile", os.path.join(self.working_dir, "coverage.cov")] args += ["-c", os.path.join(self.working_dir, "filebeat.yml"), "-e", "-v", "-d", "*"] diff --git a/heartbeat/cmd/root.go b/heartbeat/cmd/root.go index a1f80a7cda71..fd95013c6fe0 100644 --- a/heartbeat/cmd/root.go +++ b/heartbeat/cmd/root.go @@ -22,7 +22,6 @@ import ( "github.com/elastic/beats/v7/heartbeat/beater" "github.com/elastic/beats/v7/heartbeat/include" - "github.com/elastic/beats/v7/libbeat/cfgfile" cmd "github.com/elastic/beats/v7/libbeat/cmd" "github.com/elastic/beats/v7/libbeat/cmd/instance" "github.com/elastic/beats/v7/libbeat/ecs" @@ -82,7 +81,6 @@ func Initialize(settings instance.Settings) *cmd.BeatsRootCmd { ` setup.ResetFlags() setup.Flags().Bool(cmd.IndexManagementKey, false, "Setup all components related to Elasticsearch index management, including template, ilm policy and rollover alias") - cfgfile.AddAllowedBackwardsCompatibleFlag(cmd.IndexManagementKey) return rootCmd } diff --git a/heartbeat/main_test.go b/heartbeat/main_test.go index 18cc332b63af..a806e1588bd0 100644 --- a/heartbeat/main_test.go +++ b/heartbeat/main_test.go @@ -24,7 +24,6 @@ import ( "testing" "github.com/elastic/beats/v7/heartbeat/cmd" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/tests/system/template" ) @@ -34,14 +33,11 @@ func init() { testing.Init() systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(_ *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/libbeat/cfgfile/cfgfile.go b/libbeat/cfgfile/cfgfile.go index 14e38c5ab7de..94cb1ef37ae8 100644 --- a/libbeat/cfgfile/cfgfile.go +++ b/libbeat/cfgfile/cfgfile.go @@ -22,7 +22,6 @@ import ( "fmt" "os" "path/filepath" - "strings" "sync" "github.com/elastic/beats/v7/libbeat/common" @@ -49,9 +48,7 @@ func Initialize() { // created. See ChangeDefaultCfgfileFlag which should // be called prior to flags.Parse(). configfiles = config.StringArrFlag(nil, "c", "beat.yml", "Configuration file, relative to path.config") - AddAllowedBackwardsCompatibleFlag("c") overwrites = config.SettingFlag(nil, "E", "Configuration overwrite") - AddAllowedBackwardsCompatibleFlag("E") defaults = config.MustNewConfigFrom(map[string]interface{}{ "path": map[string]interface{}{ "home": ".", // to be initialized by beat @@ -61,44 +58,12 @@ func Initialize() { }, }) homePath = config.ConfigOverwriteFlag(nil, overwrites, "path.home", "path.home", "", "Home path") - AddAllowedBackwardsCompatibleFlag("path.home") configPath = config.ConfigOverwriteFlag(nil, overwrites, "path.config", "path.config", "", "Configuration path") - AddAllowedBackwardsCompatibleFlag("path.config") _ = config.ConfigOverwriteFlag(nil, overwrites, "path.data", "path.data", "", "Data path") - AddAllowedBackwardsCompatibleFlag("path.data") _ = config.ConfigOverwriteFlag(nil, overwrites, "path.logs", "path.logs", "", "Logs path") - AddAllowedBackwardsCompatibleFlag("path.logs") }) } -func isAllowedBackwardsCompatibleFlag(f string) bool { - for _, existing := range allowedBackwardsCompatibleFlags { - if existing == f { - return true - } - } - return false -} - -func AddAllowedBackwardsCompatibleFlag(f string) { - if isAllowedBackwardsCompatibleFlag(f) { - return - } - allowedBackwardsCompatibleFlags = append(allowedBackwardsCompatibleFlags, f) -} - -func ConvertFlagsForBackwardsCompatibility() { - // backwards compatibility workaround, convert -flags to --flags: - for i, arg := range os.Args[1:] { - if strings.HasPrefix(arg, "-") && !strings.HasPrefix(arg, "--") { - candidate, _, _ := strings.Cut(strings.TrimPrefix(arg, "-"), "=") - if isAllowedBackwardsCompatibleFlag(candidate) { - os.Args[1+i] = "-" + arg - } - } - } -} - // OverrideChecker checks if a config should be overwritten. type OverrideChecker func(*config.C) bool diff --git a/libbeat/cmd/export/dashboard.go b/libbeat/cmd/export/dashboard.go index 4a4e13167f8c..23c55710074e 100644 --- a/libbeat/cmd/export/dashboard.go +++ b/libbeat/cmd/export/dashboard.go @@ -22,7 +22,6 @@ import ( "github.com/spf13/cobra" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd/instance" "github.com/elastic/beats/v7/libbeat/dashboards" "github.com/elastic/beats/v7/libbeat/version" @@ -41,7 +40,7 @@ func GenDashboardCmd(settings instance.Settings) *cobra.Command { folder, _ := cmd.Flags().GetString("folder") if len(folder) == 0 { - fatalf("-folder must be specified") + fatalf("--folder must be specified") } b, err := instance.NewInitializedBeat(settings) @@ -102,11 +101,8 @@ func GenDashboardCmd(settings instance.Settings) *cobra.Command { } genTemplateConfigCmd.Flags().String("id", "", "Dashboard id") - cfgfile.AddAllowedBackwardsCompatibleFlag("id") genTemplateConfigCmd.Flags().String("yml", "", "Yaml file containing list of dashboard ID and filename pairs") - cfgfile.AddAllowedBackwardsCompatibleFlag("yml") genTemplateConfigCmd.Flags().String("folder", "", "Target folder to save exported assets") - cfgfile.AddAllowedBackwardsCompatibleFlag("folder") return genTemplateConfigCmd } diff --git a/libbeat/cmd/export/ilm_policy.go b/libbeat/cmd/export/ilm_policy.go index 557c62c8aaef..60c97920fd79 100644 --- a/libbeat/cmd/export/ilm_policy.go +++ b/libbeat/cmd/export/ilm_policy.go @@ -20,7 +20,6 @@ package export import ( "github.com/spf13/cobra" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd/instance" "github.com/elastic/beats/v7/libbeat/idxmgmt" "github.com/elastic/beats/v7/libbeat/idxmgmt/lifecycle" @@ -58,9 +57,7 @@ func GenGetILMPolicyCmd(settings instance.Settings) *cobra.Command { } genTemplateConfigCmd.Flags().String("es.version", settings.Version, "Elasticsearch version") - cfgfile.AddAllowedBackwardsCompatibleFlag("es.version") genTemplateConfigCmd.Flags().String("dir", "", "Specify directory for printing policy files. By default policies are printed to stdout.") - cfgfile.AddAllowedBackwardsCompatibleFlag("dir") return genTemplateConfigCmd } diff --git a/libbeat/cmd/export/index_pattern.go b/libbeat/cmd/export/index_pattern.go index 863fc7a72cfe..6b8b8c6839f6 100644 --- a/libbeat/cmd/export/index_pattern.go +++ b/libbeat/cmd/export/index_pattern.go @@ -22,7 +22,6 @@ import ( "github.com/spf13/cobra" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd/instance" "github.com/elastic/beats/v7/libbeat/kibana" libversion "github.com/elastic/elastic-agent-libs/version" @@ -68,7 +67,6 @@ func GenIndexPatternConfigCmd(settings instance.Settings) *cobra.Command { } genTemplateConfigCmd.Flags().String("es.version", settings.Version, "Elasticsearch version") - cfgfile.AddAllowedBackwardsCompatibleFlag("es.version") return genTemplateConfigCmd } diff --git a/libbeat/cmd/export/template.go b/libbeat/cmd/export/template.go index 45a83b986817..ffd957961efe 100644 --- a/libbeat/cmd/export/template.go +++ b/libbeat/cmd/export/template.go @@ -20,7 +20,6 @@ package export import ( "github.com/spf13/cobra" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd/instance" "github.com/elastic/beats/v7/libbeat/idxmgmt" "github.com/elastic/beats/v7/libbeat/idxmgmt/lifecycle" @@ -60,11 +59,8 @@ func GenTemplateConfigCmd(settings instance.Settings) *cobra.Command { } genTemplateConfigCmd.Flags().String("es.version", settings.Version, "Elasticsearch version") - cfgfile.AddAllowedBackwardsCompatibleFlag("es.version") genTemplateConfigCmd.Flags().Bool("noilm", false, "Generate template with ILM disabled") - cfgfile.AddAllowedBackwardsCompatibleFlag("noilm") genTemplateConfigCmd.Flags().String("dir", "", "Specify directory for printing template files. By default templates are printed to stdout.") - cfgfile.AddAllowedBackwardsCompatibleFlag("dir") return genTemplateConfigCmd } diff --git a/libbeat/cmd/instance/beat.go b/libbeat/cmd/instance/beat.go index eeadf06b836b..6941c571216e 100644 --- a/libbeat/cmd/instance/beat.go +++ b/libbeat/cmd/instance/beat.go @@ -998,7 +998,6 @@ func (b *Beat) Setup(settings Settings, bt beat.Creator, setup SetupSettings) er // flags, and it invokes the HandleFlags callback if implemented by // the Beat. func (b *Beat) handleFlags() error { - cfgfile.ConvertFlagsForBackwardsCompatibility() flag.Parse() return cfgfile.HandleFlags() } diff --git a/libbeat/cmd/instance/beat_integration_test.go b/libbeat/cmd/instance/beat_integration_test.go index 1bca1400de61..36fbc00fbae1 100644 --- a/libbeat/cmd/instance/beat_integration_test.go +++ b/libbeat/cmd/instance/beat_integration_test.go @@ -95,7 +95,6 @@ func TestMonitoringNameFromConfig(t *testing.T) { // Set the configuration file path flag so the beat can read it cfgfile.Initialize() _ = flag.Set("c", "testdata/mockbeat.yml") - cfgfile.AddAllowedBackwardsCompatibleFlag("c") _ = instance.Run(mock.Settings, func(_ *beat.Beat, _ *config.C) (beat.Beater, error) { return &mockBeat, nil }) diff --git a/libbeat/cmd/keystore.go b/libbeat/cmd/keystore.go index cfc392020693..da0f5371693c 100644 --- a/libbeat/cmd/keystore.go +++ b/libbeat/cmd/keystore.go @@ -29,7 +29,6 @@ import ( "github.com/spf13/cobra" "golang.org/x/term" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd/instance" "github.com/elastic/beats/v7/libbeat/common/cli" "github.com/elastic/beats/v7/libbeat/common/terminal" @@ -75,7 +74,6 @@ func genCreateKeystoreCmd(settings instance.Settings) *cobra.Command { }), } command.Flags().BoolVar(&flagForce, "force", false, "override the existing keystore") - cfgfile.AddAllowedBackwardsCompatibleFlag("force") return command } @@ -94,9 +92,7 @@ func genAddKeystoreCmd(settings instance.Settings) *cobra.Command { }), } command.Flags().BoolVar(&flagStdin, "stdin", false, "Use the stdin as the source of the secret") - cfgfile.AddAllowedBackwardsCompatibleFlag("stdin") command.Flags().BoolVar(&flagForce, "force", false, "Override the existing key") - cfgfile.AddAllowedBackwardsCompatibleFlag("force") return command } diff --git a/libbeat/cmd/root.go b/libbeat/cmd/root.go index 335b83560d78..cf0a379716fc 100644 --- a/libbeat/cmd/root.go +++ b/libbeat/cmd/root.go @@ -80,30 +80,18 @@ func GenRootCmdWithSettings(beatCreator beat.Creator, settings instance.Settings // Persistent flags, common across all subcommands rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("E")) - cfgfile.AddAllowedBackwardsCompatibleFlag("E") rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("c")) - cfgfile.AddAllowedBackwardsCompatibleFlag("c") rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("d")) - cfgfile.AddAllowedBackwardsCompatibleFlag("d") rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("v")) - cfgfile.AddAllowedBackwardsCompatibleFlag("v") rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("e")) - cfgfile.AddAllowedBackwardsCompatibleFlag("e") rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("environment")) - cfgfile.AddAllowedBackwardsCompatibleFlag("environment") rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("path.config")) - cfgfile.AddAllowedBackwardsCompatibleFlag("path.config") rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("path.data")) - cfgfile.AddAllowedBackwardsCompatibleFlag("path.data") rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("path.logs")) - cfgfile.AddAllowedBackwardsCompatibleFlag("path.logs") rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("path.home")) - cfgfile.AddAllowedBackwardsCompatibleFlag("path.home") rootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("strict.perms")) - cfgfile.AddAllowedBackwardsCompatibleFlag("strict.perms") if f := flag.CommandLine.Lookup("plugin"); f != nil { rootCmd.PersistentFlags().AddGoFlag(f) - cfgfile.AddAllowedBackwardsCompatibleFlag("plugin") } // Inherit root flags from run command diff --git a/libbeat/cmd/run.go b/libbeat/cmd/run.go index d6cadd318cee..b078aadaf89c 100644 --- a/libbeat/cmd/run.go +++ b/libbeat/cmd/run.go @@ -24,7 +24,6 @@ import ( "github.com/spf13/cobra" "github.com/elastic/beats/v7/libbeat/beat" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd/instance" ) @@ -43,13 +42,9 @@ func genRunCmd(settings instance.Settings, beatCreator beat.Creator) *cobra.Comm // Run subcommand flags, only available to *beat run runCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("N")) - cfgfile.AddAllowedBackwardsCompatibleFlag("N") runCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("httpprof")) - cfgfile.AddAllowedBackwardsCompatibleFlag("httpprof") runCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("cpuprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("cpuprofile") runCmd.Flags().AddGoFlag(flag.CommandLine.Lookup("memprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("memprofile") if settings.RunFlags != nil { runCmd.Flags().AddFlagSet(settings.RunFlags) diff --git a/libbeat/cmd/setup.go b/libbeat/cmd/setup.go index 0b28d22f96f4..64d1f41fdeaf 100644 --- a/libbeat/cmd/setup.go +++ b/libbeat/cmd/setup.go @@ -24,7 +24,6 @@ import ( "github.com/spf13/cobra" "github.com/elastic/beats/v7/libbeat/beat" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd/instance" ) @@ -112,16 +111,11 @@ func genSetupCmd(settings instance.Settings, beatCreator beat.Creator) *cobra.Co } setup.Flags().Bool(DashboardKey, false, "Setup dashboards") - cfgfile.AddAllowedBackwardsCompatibleFlag(DashboardKey) setup.Flags().Bool(PipelineKey, false, "Setup Ingest pipelines") - cfgfile.AddAllowedBackwardsCompatibleFlag(PipelineKey) setup.Flags().Bool(IndexManagementKey, false, "Setup all components related to Elasticsearch index management, including template, ilm policy and rollover alias") - cfgfile.AddAllowedBackwardsCompatibleFlag(IndexManagementKey) setup.Flags().Bool("enable-all-filesets", false, "Behave as if all modules and filesets had been enabled") - cfgfile.AddAllowedBackwardsCompatibleFlag("enable-all-filesets") setup.Flags().Bool("force-enable-module-filesets", false, "Behave as if all filesets, within enabled modules, are enabled") - cfgfile.AddAllowedBackwardsCompatibleFlag("force-enable-module-filesets") return &setup } diff --git a/libbeat/common/seccomp/README.md b/libbeat/common/seccomp/README.md index ee78e41dfe2e..d418c0a9d461 100644 --- a/libbeat/common/seccomp/README.md +++ b/libbeat/common/seccomp/README.md @@ -71,7 +71,7 @@ Another profiling option is `strace -c`. This will record all system calls used by the Beat. Then this list can be used to steer the development of a policy. ```sh -sudo strace -c ./metricbeat -strict.perms=false +sudo strace -c ./metricbeat --strict.perms=false % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 79.75 0.002521 97 26 futex diff --git a/libbeat/docs/command-reference.asciidoc b/libbeat/docs/command-reference.asciidoc index b869d7e4956c..64b9067ca799 100644 --- a/libbeat/docs/command-reference.asciidoc +++ b/libbeat/docs/command-reference.asciidoc @@ -590,7 +590,7 @@ Prints the list of devices that are available for sniffing and then exits. endif::[] ifeval::["{beatname_lc}"=="packetbeat"] -*`-dump FILE`*:: +*`--dump FILE`*:: Writes all captured packets to the specified file. This option is useful for troubleshooting {beatname_uc}. endif::[] @@ -907,7 +907,7 @@ ifeval::["{beatname_lc}"=="filebeat"] + ["source","sh",subs="attributes"] ---------------------------------------------------------------------- -{beatname_lc} -modules=nginx -M "nginx.access.var.paths=['/var/log/nginx/access.log*']" -M "nginx.access.var.pipeline=no_plugins" +{beatname_lc} --modules=nginx -M "nginx.access.var.paths=['/var/log/nginx/access.log*']" -M "nginx.access.var.pipeline=no_plugins" ---------------------------------------------------------------------- endif::[] @@ -948,7 +948,7 @@ details. Sets the path for log files. See the <> section for details. *`--strict.perms`*:: -Sets strict permission checking on configuration files. The default is `-strict.perms=true`. +Sets strict permission checking on configuration files. The default is `--strict.perms=true`. ifndef::apm-server[] See {beats-ref}/config-file-permissions.html[Config file ownership and permissions] for more information. diff --git a/libbeat/docs/shared-systemd.asciidoc b/libbeat/docs/shared-systemd.asciidoc index 802eef9858ed..0fccb8a6d051 100644 --- a/libbeat/docs/shared-systemd.asciidoc +++ b/libbeat/docs/shared-systemd.asciidoc @@ -67,7 +67,7 @@ override to change the default options. | Variable | Description | Default value | BEAT_LOG_OPTS | Log options | | BEAT_CONFIG_OPTS | Flags for configuration file path | +-c /etc/{beatname_lc}/{beatname_lc}.yml+ -| BEAT_PATH_OPTS | Other paths | +-path.home /usr/share/{beatname_lc} -path.config /etc/{beatname_lc} -path.data /var/lib/{beatname_lc} -path.logs /var/log/{beatname_lc}+ +| BEAT_PATH_OPTS | Other paths | +--path.home /usr/share/{beatname_lc} --path.config /etc/{beatname_lc} --path.data /var/lib/{beatname_lc} --path.logs /var/log/{beatname_lc}+ |======================================= NOTE: You can use `BEAT_LOG_OPTS` to set debug selectors for logging. However, diff --git a/libbeat/libbeat_test.go b/libbeat/libbeat_test.go index 1f9e1b3ffe8b..e4bac5e309de 100644 --- a/libbeat/libbeat_test.go +++ b/libbeat/libbeat_test.go @@ -21,7 +21,6 @@ import ( "flag" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/tests/system/template" ) @@ -32,14 +31,11 @@ func init() { systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started func TestSystem(t *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/libbeat/tests/integration/dashboard_test.go b/libbeat/tests/integration/dashboard_test.go index 9eaf9fa5c1c0..2319a7b1e5f0 100644 --- a/libbeat/tests/integration/dashboard_test.go +++ b/libbeat/tests/integration/dashboard_test.go @@ -173,7 +173,7 @@ queue.mem: "-E", "setup.kibana.username=beats", "-E", "setup.kibana.password=testing", "-id", "Metricbeat-system-overview", - "-folder", filepath.Join(mockbeat.TempDir(), "system-overview")) + "--folder", filepath.Join(mockbeat.TempDir(), "system-overview")) procState, err = mockbeat.Process.Wait() require.NoError(t, err) require.Equal(t, 0, procState.ExitCode(), "incorrect exit code") @@ -205,8 +205,8 @@ queue.mem: "-E", "setup.kibana.port="+kURL.Port(), "-E", "setup.kibana.username=beats", "-E", "setup.kibana.password=testing", - "-id", "No-such-dashboard", - "-folder", filepath.Join(mockbeat.TempDir(), "system-overview")) + "--id", "No-such-dashboard", + "--folder", filepath.Join(mockbeat.TempDir(), "system-overview")) procState, err := mockbeat.Process.Wait() require.NoError(t, err) require.Equal(t, 1, procState.ExitCode(), "incorrect exit code") diff --git a/libbeat/tests/system/beat/beat.py b/libbeat/tests/system/beat/beat.py index 74d5ab628162..d39498e9e834 100644 --- a/libbeat/tests/system/beat/beat.py +++ b/libbeat/tests/system/beat/beat.py @@ -269,10 +269,10 @@ def start_beat(self, if output is None: output = self.beat_name + "-" + self.today + ".ndjson" - args = [cmd, "-systemTest"] + args = [cmd, "--systemTest"] if os.getenv("TEST_COVERAGE") == "true": args += [ - "-test.coverprofile", + "--test.coverprofile", os.path.join(self.working_dir, "coverage.cov"), ] @@ -281,7 +281,7 @@ def start_beat(self, path_home = home args += [ - "-path.home", path_home, + "--path.home", path_home, "-c", os.path.join(self.working_dir, config), ] diff --git a/libbeat/tests/system/keystore.py b/libbeat/tests/system/keystore.py index 12418ba5a731..34066236f6b9 100644 --- a/libbeat/tests/system/keystore.py +++ b/libbeat/tests/system/keystore.py @@ -12,10 +12,10 @@ def add_secret(self, key, value="hello world\n", force=False): """ Add new secret using the --stdin option """ - args = [self.test_binary, "-systemTest"] + args = [self.test_binary, "--systemTest"] if os.getenv("TEST_COVERAGE") == "true": args += [ - "-test.coverprofile", + "--test.coverprofile", os.path.join(self.working_dir, "coverage.cov"), ] args += [ diff --git a/metricbeat/cmd/root.go b/metricbeat/cmd/root.go index 872f05b8b356..2431f3d52795 100644 --- a/metricbeat/cmd/root.go +++ b/metricbeat/cmd/root.go @@ -24,7 +24,6 @@ import ( "github.com/elastic/elastic-agent-libs/mapstr" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd" "github.com/elastic/beats/v7/libbeat/cmd/instance" "github.com/elastic/beats/v7/libbeat/ecs" @@ -59,7 +58,6 @@ func MetricbeatSettings(moduleNameSpace string) instance.Settings { } runFlags := pflag.NewFlagSet(Name, pflag.ExitOnError) runFlags.AddGoFlag(flag.CommandLine.Lookup("system.hostfs")) - cfgfile.AddAllowedBackwardsCompatibleFlag("system.hostfs") return instance.Settings{ RunFlags: runFlags, Name: Name, diff --git a/metricbeat/main_test.go b/metricbeat/main_test.go index be50210575e7..f2b585d56cab 100644 --- a/metricbeat/main_test.go +++ b/metricbeat/main_test.go @@ -24,7 +24,6 @@ import ( "os" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" cmd "github.com/elastic/beats/v7/libbeat/cmd" "github.com/elastic/beats/v7/libbeat/tests/system/template" mbcmd "github.com/elastic/beats/v7/metricbeat/cmd" @@ -40,14 +39,11 @@ func init() { systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") mbCommand = mbcmd.Initialize(mbcmd.MetricbeatSettings("")) mbCommand.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") mbCommand.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(t *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { if err := mbCommand.Execute(); err != nil { os.Exit(1) diff --git a/metricbeat/module/golang/test_golang.py b/metricbeat/module/golang/test_golang.py index 585dd13656bf..6ce44cfdc233 100644 --- a/metricbeat/module/golang/test_golang.py +++ b/metricbeat/module/golang/test_golang.py @@ -23,7 +23,7 @@ def test_stats(self): "period": "1s" }]) proc = self.start_beat( - extra_args=["-httpprof", "localhost:6060"]) + extra_args=["--httpprof", "localhost:6060"]) self.wait_until(lambda: self.output_lines() > 0) proc.check_kill_and_wait() diff --git a/metricbeat/module/openmetrics/collector/_meta/data.json b/metricbeat/module/openmetrics/collector/_meta/data.json index 000809b8da9a..425e2d297c0b 100644 --- a/metricbeat/module/openmetrics/collector/_meta/data.json +++ b/metricbeat/module/openmetrics/collector/_meta/data.json @@ -11,14 +11,16 @@ }, "openmetrics": { "labels": { - "job": "openmetrics" + "job": "openmetrics", + "listener_name": "http" }, "metrics": { - "up": 1 + "net_conntrack_listener_conn_accepted_total": 3, + "net_conntrack_listener_conn_closed_total": 0 } }, "service": { "address": "127.0.0.1:55555", "type": "openmetrics" } -} +} \ No newline at end of file diff --git a/metricbeat/module/system/test_system.py b/metricbeat/module/system/test_system.py index e4aa935a68cf..ef4e0b20019e 100644 --- a/metricbeat/module/system/test_system.py +++ b/metricbeat/module/system/test_system.py @@ -563,9 +563,9 @@ def test_process_metricbeat(self): output = self.read_output()[0] assert re.match("(?i)metricbeat.test(.exe)?", output["process.name"]) - assert re.match("(?i).*metricbeat.test(.exe)? -systemTest", + assert re.match("(?i).*metricbeat.test(.exe)? --systemTest", output["system.process.cmdline"]) - assert re.match("(?i).*metricbeat.test(.exe)? -systemTest", + assert re.match("(?i).*metricbeat.test(.exe)? --systemTest", output["process.command_line"]) assert isinstance(output["system.process.state"], six.string_types) assert isinstance( diff --git a/packetbeat/cmd/root.go b/packetbeat/cmd/root.go index eb6d14b1692a..7b1c20b34c6e 100644 --- a/packetbeat/cmd/root.go +++ b/packetbeat/cmd/root.go @@ -22,7 +22,6 @@ import ( "github.com/spf13/pflag" - "github.com/elastic/beats/v7/libbeat/cfgfile" cmd "github.com/elastic/beats/v7/libbeat/cmd" "github.com/elastic/beats/v7/libbeat/cmd/instance" "github.com/elastic/beats/v7/libbeat/ecs" @@ -52,15 +51,10 @@ var RootCmd *cmd.BeatsRootCmd func PacketbeatSettings(globals processors.PluginConfig) instance.Settings { runFlags := pflag.NewFlagSet(Name, pflag.ExitOnError) runFlags.AddGoFlag(flag.CommandLine.Lookup("I")) - cfgfile.AddAllowedBackwardsCompatibleFlag("I") runFlags.AddGoFlag(flag.CommandLine.Lookup("t")) - cfgfile.AddAllowedBackwardsCompatibleFlag("t") runFlags.AddGoFlag(flag.CommandLine.Lookup("O")) - cfgfile.AddAllowedBackwardsCompatibleFlag("O") runFlags.AddGoFlag(flag.CommandLine.Lookup("l")) - cfgfile.AddAllowedBackwardsCompatibleFlag("l") runFlags.AddGoFlag(flag.CommandLine.Lookup("dump")) - cfgfile.AddAllowedBackwardsCompatibleFlag("dump") return instance.Settings{ RunFlags: runFlags, diff --git a/packetbeat/docs/troubleshooting.asciidoc b/packetbeat/docs/troubleshooting.asciidoc index ef210371ad07..3adf35590375 100644 --- a/packetbeat/docs/troubleshooting.asciidoc +++ b/packetbeat/docs/troubleshooting.asciidoc @@ -52,7 +52,7 @@ of 10-20 seconds is usually enough. To record the trace, you can use the followi [source,shell] ------------------------------------------------------------ -packetbeat -e -dump trace.pcap +packetbeat -e --dump trace.pcap ------------------------------------------------------------ This command executes Packetbeat in normal mode (all processing happens as usual), but diff --git a/packetbeat/main_test.go b/packetbeat/main_test.go index 2dfcfb4572c5..359e70f161b0 100644 --- a/packetbeat/main_test.go +++ b/packetbeat/main_test.go @@ -23,7 +23,6 @@ import ( "flag" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/tests/system/template" "github.com/elastic/beats/v7/packetbeat/cmd" ) @@ -34,14 +33,11 @@ func init() { testing.Init() systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(*testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/packetbeat/tests/system/packetbeat.py b/packetbeat/tests/system/packetbeat.py index c4727d131837..398060152ff1 100644 --- a/packetbeat/tests/system/packetbeat.py +++ b/packetbeat/tests/system/packetbeat.py @@ -59,11 +59,11 @@ def run_packetbeat(self, pcap, "-e", "-I", os.path.join(self.beat_path + "/tests/system/pcaps", pcap), "-c", os.path.join(self.working_dir, config), - "-systemTest", + "--systemTest", ]) if os.getenv("TEST_COVERAGE") == "true": args += [ - "-test.coverprofile", os.path.join(self.working_dir, "coverage.cov"), + "--test.coverprofile", os.path.join(self.working_dir, "coverage.cov"), ] if extra_args: @@ -107,11 +107,11 @@ def start_packetbeat(self, args = [cmd, "-e", "-c", os.path.join(self.working_dir, config), - "-systemTest", + "--systemTest", ] if os.getenv("TEST_COVERAGE") == "true": args += [ - "-test.coverprofile", os.path.join(self.working_dir, "coverage.cov"), + "--test.coverprofile", os.path.join(self.working_dir, "coverage.cov"), ] if extra_args: diff --git a/packetbeat/tests/system/test_0026_test_config.py b/packetbeat/tests/system/test_0026_test_config.py index d9ea29a89aa9..0848e025dd93 100644 --- a/packetbeat/tests/system/test_0026_test_config.py +++ b/packetbeat/tests/system/test_0026_test_config.py @@ -42,13 +42,13 @@ def run_pb_config_tst(self, exit_code=0): cmd = os.path.join(self.beat_path, "packetbeat.test") args = [ - cmd, "-systemTest", + cmd, "--systemTest", "-c", os.path.join(self.working_dir, config), ] if os.getenv("TEST_COVERAGE") == "true": args += [ - "-test.coverprofile", + "--test.coverprofile", os.path.join(self.working_dir, "coverage.cov"), ] diff --git a/winlogbeat/main_test.go b/winlogbeat/main_test.go index 002c7431f99a..0bbc2e4e5262 100644 --- a/winlogbeat/main_test.go +++ b/winlogbeat/main_test.go @@ -22,7 +22,6 @@ import ( "flag" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/tests/system/template" "github.com/elastic/beats/v7/winlogbeat/cmd" ) @@ -33,15 +32,12 @@ func init() { testing.Init() systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // TestSystem is the function called when the test binary is started. // Only calls main. func TestSystem(*testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/winlogbeat/tests/system/test_config.py b/winlogbeat/tests/system/test_config.py index aefab4344ba8..1f8c7685a35c 100644 --- a/winlogbeat/tests/system/test_config.py +++ b/winlogbeat/tests/system/test_config.py @@ -70,13 +70,13 @@ def run_config_tst(self, pcap=None, exit_code=0): cmd = os.path.join(self.beat_path, "winlogbeat.test") args = [ - cmd, "-systemTest", + cmd, "--systemTest", "-c", os.path.join(self.working_dir, config), ] if os.getenv("TEST_COVERAGE") == "true": args += [ - "-test.coverprofile", + "--test.coverprofile", os.path.join(self.working_dir, "coverage.cov"), ] diff --git a/x-pack/agentbeat/main_test.go b/x-pack/agentbeat/main_test.go index 0333a1ebcdf4..4201d651666e 100644 --- a/x-pack/agentbeat/main_test.go +++ b/x-pack/agentbeat/main_test.go @@ -10,8 +10,6 @@ import ( "testing" "github.com/spf13/cobra" - - "github.com/elastic/beats/v7/libbeat/cfgfile" ) var ( @@ -24,14 +22,11 @@ func init() { systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") abCommand = AgentBeat() abCommand.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") abCommand.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(t *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { if err := abCommand.Execute(); err != nil { os.Exit(1) diff --git a/x-pack/auditbeat/main_test.go b/x-pack/auditbeat/main_test.go index 3456231f5167..5d2376452712 100644 --- a/x-pack/auditbeat/main_test.go +++ b/x-pack/auditbeat/main_test.go @@ -10,7 +10,6 @@ import ( "flag" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/tests/system/template" "github.com/elastic/beats/v7/x-pack/auditbeat/cmd" ) @@ -22,14 +21,11 @@ func init() { systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(*testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/x-pack/filebeat/main_test.go b/x-pack/filebeat/main_test.go index 71b32b9e6e86..3d5424c30884 100644 --- a/x-pack/filebeat/main_test.go +++ b/x-pack/filebeat/main_test.go @@ -9,7 +9,6 @@ import ( "os" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" cmd "github.com/elastic/beats/v7/libbeat/cmd" "github.com/elastic/beats/v7/libbeat/tests/system/template" fbcmd "github.com/elastic/beats/v7/x-pack/filebeat/cmd" @@ -25,14 +24,11 @@ func init() { systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") fbCommand = fbcmd.Filebeat() fbCommand.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") fbCommand.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(t *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { if err := fbCommand.Execute(); err != nil { os.Exit(1) diff --git a/x-pack/heartbeat/main_test.go b/x-pack/heartbeat/main_test.go index 44d5882a9905..91fe8b60ad8c 100644 --- a/x-pack/heartbeat/main_test.go +++ b/x-pack/heartbeat/main_test.go @@ -10,7 +10,6 @@ import ( "testing" "github.com/elastic/beats/v7/heartbeat/cmd" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/tests/system/template" ) @@ -20,14 +19,11 @@ func init() { testing.Init() systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(_ *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/x-pack/libbeat/libbeat_test.go b/x-pack/libbeat/libbeat_test.go index a3df546f3f38..338ebd7e5fbd 100644 --- a/x-pack/libbeat/libbeat_test.go +++ b/x-pack/libbeat/libbeat_test.go @@ -8,7 +8,6 @@ import ( "flag" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/tests/system/template" ) @@ -19,14 +18,11 @@ func init() { systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started func TestSystem(t *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/x-pack/metricbeat/main_test.go b/x-pack/metricbeat/main_test.go index 906782e1f5a5..dd63a8a48b7c 100644 --- a/x-pack/metricbeat/main_test.go +++ b/x-pack/metricbeat/main_test.go @@ -9,7 +9,6 @@ import ( "os" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" cmd "github.com/elastic/beats/v7/libbeat/cmd" "github.com/elastic/beats/v7/libbeat/tests/system/template" mbcmd "github.com/elastic/beats/v7/x-pack/metricbeat/cmd" @@ -25,14 +24,11 @@ func init() { systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") mbCommand = mbcmd.Initialize() mbCommand.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") mbCommand.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(t *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { if err := mbCommand.Execute(); err != nil { os.Exit(1) diff --git a/x-pack/osquerybeat/main_test.go b/x-pack/osquerybeat/main_test.go index 30a9b88efb64..f9ed09ee1a8e 100644 --- a/x-pack/osquerybeat/main_test.go +++ b/x-pack/osquerybeat/main_test.go @@ -10,7 +10,6 @@ import ( "flag" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/x-pack/osquerybeat/cmd" ) @@ -21,14 +20,11 @@ func init() { systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(_ *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/x-pack/packetbeat/main_test.go b/x-pack/packetbeat/main_test.go index a332f5c99353..234d68f81698 100644 --- a/x-pack/packetbeat/main_test.go +++ b/x-pack/packetbeat/main_test.go @@ -8,7 +8,6 @@ import ( "flag" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/tests/system/template" "github.com/elastic/beats/v7/x-pack/packetbeat/cmd" ) @@ -19,14 +18,11 @@ func init() { testing.Init() systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(t *testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/x-pack/packetbeat/tests/system/app_run_agentbeat_test.go b/x-pack/packetbeat/tests/system/app_run_agentbeat_test.go index 487fe6d8c043..ba3fcb17dc6e 100644 --- a/x-pack/packetbeat/tests/system/app_run_agentbeat_test.go +++ b/x-pack/packetbeat/tests/system/app_run_agentbeat_test.go @@ -37,7 +37,7 @@ func runPacketbeat(t testing.TB, args ...string) (stdout, stderr string, err err if err != nil { return "", "", err } - cmd := exec.CommandContext(ctx, agentbeatPath, append([]string{"-systemTest", "packetbeat", "-c", conf}, args...)...) + cmd := exec.CommandContext(ctx, agentbeatPath, append([]string{"--systemTest", "packetbeat", "-c", conf}, args...)...) cmd.Dir = t.TempDir() var stdoutBuf, stderrBuf bytes.Buffer cmd.Stdout = &stdoutBuf diff --git a/x-pack/packetbeat/tests/system/app_run_test.go b/x-pack/packetbeat/tests/system/app_run_test.go index 6e4c1f31a5b3..a9cc9f8fb353 100644 --- a/x-pack/packetbeat/tests/system/app_run_test.go +++ b/x-pack/packetbeat/tests/system/app_run_test.go @@ -37,7 +37,7 @@ func runPacketbeat(t testing.TB, args ...string) (stdout, stderr string, err err if err != nil { return "", "", err } - cmd := exec.CommandContext(ctx, packetbeatPath, append([]string{"-systemTest", "-c", conf}, args...)...) + cmd := exec.CommandContext(ctx, packetbeatPath, append([]string{"--systemTest", "-c", conf}, args...)...) cmd.Dir = t.TempDir() var stdoutBuf, stderrBuf bytes.Buffer cmd.Stdout = &stdoutBuf diff --git a/x-pack/winlogbeat/cmd/export.go b/x-pack/winlogbeat/cmd/export.go index facd2fb0e929..54f9f02e18c8 100644 --- a/x-pack/winlogbeat/cmd/export.go +++ b/x-pack/winlogbeat/cmd/export.go @@ -10,7 +10,6 @@ import ( "github.com/spf13/cobra" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd/instance" "github.com/elastic/beats/v7/winlogbeat/module" libversion "github.com/elastic/elastic-agent-libs/version" @@ -49,9 +48,7 @@ func GenExportPipelineCmd(settings instance.Settings) *cobra.Command { } genExportPipelineCmd.Flags().String("es.version", settings.Version, "Elasticsearch version (required)") - cfgfile.AddAllowedBackwardsCompatibleFlag("es.version") genExportPipelineCmd.Flags().String("dir", "", "Specify directory for exporting pipelines. Default is current directory.") - cfgfile.AddAllowedBackwardsCompatibleFlag("dir") return genExportPipelineCmd } diff --git a/x-pack/winlogbeat/main_test.go b/x-pack/winlogbeat/main_test.go index b4c0f3b124a1..2b8547a81726 100644 --- a/x-pack/winlogbeat/main_test.go +++ b/x-pack/winlogbeat/main_test.go @@ -8,7 +8,6 @@ import ( "flag" "testing" - "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/tests/system/template" "github.com/elastic/beats/v7/x-pack/winlogbeat/cmd" ) @@ -19,14 +18,11 @@ func init() { testing.Init() systemTest = flag.Bool("systemTest", false, "Set to true when running system tests") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("systemTest")) - cfgfile.AddAllowedBackwardsCompatibleFlag("systemTest") cmd.RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("test.coverprofile")) - cfgfile.AddAllowedBackwardsCompatibleFlag("test.coverprofile") } // Test started when the test binary is started. Only calls main. func TestSystem(*testing.T) { - cfgfile.ConvertFlagsForBackwardsCompatibility() if *systemTest { main() } diff --git a/x-pack/winlogbeat/module/security/dashboards.yml b/x-pack/winlogbeat/module/security/dashboards.yml index b50adb307607..d2272222e2c8 100644 --- a/x-pack/winlogbeat/module/security/dashboards.yml +++ b/x-pack/winlogbeat/module/security/dashboards.yml @@ -1,5 +1,5 @@ # To export all dashboards use: -# go run ../../../../dev-tools/cmd/dashboards/export_dashboards.go -yml dashboards.yml +# go run ../../../../dev-tools/cmd/dashboards/export_dashboards.go --yml dashboards.yml dashboards: - id: d401ef40-a7d5-11e9-a422-d144027429da