forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change introduces subcommand interface to all beats. This give us several new features: * Isolated subcommands (version, setup, run...) * Command line help for all of them * Autocompletion and typo hinting * Freedom to add beat specific subcommands where needed Usage examples: ``` $ metricbeat help $ metricbeat version $ metricbeat run -h $ metricbeat run -e -v ``` I've kept root command as an alias for `run`, so old style calls should be still working. About flags: Cobra supports persistent (global) and local flags for each command. I've added config related flags as persistent, common to all subcommands. While keeping runtime related flags under `run`, see the full list here: ``` Flags: -N, --N Disable actual publishing for testing --configtest Test configuration and exit. --cpuprofile string Write cpu profile to file -e, --e Log to stderr and disable syslog/file output -h, --help help for run --httpprof string Start pprof http server --memprofile string Write memory profile to this file --setup Load the sample Kibana dashboards -v, --v Log at INFO level --version Print the version and exit Global Flags: -E, --E Flag Configuration overwrite (default null) -c, --c argList Configuration file, relative to path.config (default beat.yml) -d, --d string Enable certain debug selectors --path.config flagOverwrite Configuration path --path.data flagOverwrite Data path --path.home flagOverwrite Home path --path.logs flagOverwrite Logs path --strict.perms Strict permission checking on config files (default true) ``` In the log term we should aim to deprecate a few of them (setup, version, configtest...) in favor of subcommands. I'm keeping them for now to maintain backwards compatibilty with 5.X.
- Loading branch information
Showing
74 changed files
with
8,213 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package cmd | ||
|
||
import ( | ||
"flag" | ||
|
||
"github.com/spf13/pflag" | ||
|
||
"github.com/elastic/beats/filebeat/beater" | ||
|
||
cmd "github.com/elastic/beats/libbeat/cmd" | ||
) | ||
|
||
// Name of this beat | ||
var Name = "filebeat" | ||
|
||
// RootCmd to handle beats cli | ||
var RootCmd *cmd.BeatsRootCmd | ||
|
||
func init() { | ||
var runFlags = pflag.NewFlagSet(Name, pflag.ExitOnError) | ||
runFlags.AddGoFlag(flag.CommandLine.Lookup("once")) | ||
runFlags.AddGoFlag(flag.CommandLine.Lookup("modules")) | ||
|
||
RootCmd = cmd.GenRootCmdWithRunFlags(Name, "", beater.New, runFlags) | ||
RootCmd.PersistentFlags().AddGoFlag(flag.CommandLine.Lookup("M")) | ||
RootCmd.ConfigTest.Flags().AddGoFlag(flag.CommandLine.Lookup("modules")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/elastic/beats/metricbeat/beater" | ||
|
||
cmd "github.com/elastic/beats/libbeat/cmd" | ||
) | ||
|
||
// Name of this beat | ||
var Name = "{beat}" | ||
|
||
// RootCmd to handle beats cli | ||
var RootCmd = cmd.GenRootCmd(Name, "", beater.New) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cmd | ||
|
||
import cmd "github.com/elastic/beats/libbeat/cmd" | ||
import "github.com/elastic/beats/heartbeat/beater" | ||
|
||
// Name of this beat | ||
var Name = "heartbeat" | ||
|
||
// RootCmd to handle beats cli | ||
var RootCmd = cmd.GenRootCmd(Name, "", beater.New) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.