Conversation
filebeat/cmd/run.go
Outdated
There was a problem hiding this comment.
Any reason this is not also part of libbeat? Is there anything beat specific about RunCmd?
There was a problem hiding this comment.
beater is the specific part, but now you ask, I could add that as a parameter to GenRootCmd
60b565c to
7eaf56e
Compare
ruflin
left a comment
There was a problem hiding this comment.
Awesome stuff. Really looking forward to have this in the beats.
filebeat/main.go
Outdated
There was a problem hiding this comment.
This change brings up the question if we should also change the generator to support this?
libbeat/beat/beat.go
Outdated
There was a problem hiding this comment.
I wonder why lint did not complain :-)
Do we have to make this global?
libbeat/cmd/root.go
Outdated
There was a problem hiding this comment.
I would recommend to put the init on top, at least that is what we did so far.
libbeat/cmd/version.go
Outdated
There was a problem hiding this comment.
Ok, I see why we need it global :-)
5209732 to
f68b962
Compare
0fbe954 to
fe28b23
Compare
|
I wonder how useful is the Here is an example session to show the issue: |
|
Interesting that both |
|
@tsg: Yes, with this change we would have duplicated functionality between subcommands and flags, but purely for backwards compatibility, I'm more in favor of subcommands for all flags that modify run behavior to do a "one shoot" thing. I can include I did some black magic for backwards compatibility, Cobra flags use UNIX style, so it would require |
Ok, I think that's worth a discussion, we could also cut the bandaid with the 6.0 release.
Generally I agree that things that make the Beat stop are better as commands. But the |
|
I played with it and it feels great to me, nice work. Dumping some thoughts / wishlist, but for future PRs:
|
CHANGELOG.asciidoc
Outdated
There was a problem hiding this comment.
We'll likely need to deprecate some things, but that can go in a meta ticket.
|
Thanks for the input, great new ideas!, I didn't think about |
|
I'll review flags for |
|
@exekias There will be some doc updates required for this, too (the topic about CLI options and the places where we show commands). Feel free to create a separate issue to track this work, and assign it to me, if you'd like. TBH, when I look at your description above, the syntax is not entirely clear to me. I'm sure it will make more sense when I can play around with the commands in a build (or have time to look more closely at the code). Also, I’m wondering if we’ve taken consistency with other Elastic products (and their command line syntax) into consideration here. Do customers get frustrated when we aren't consistent across products, or am I overthinking this? |
|
great @dedemorton I will open a new ticket, also input is more than welcomed if you find better naming for any of the added commands. I didn't though about consistency, but it's a good point, I'm going to check how the rest of projects handle this. While I think it's not that important (different projects ==> different ways of using them) perhaps we can achieve something more consistent, which is always good |
|
@exekias Can you rebase this one, I think it will fix some of the test failures. |
c863e3f to
f985346
Compare
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.

This change introduces subcommand interface to all beats.
This give us several new features:
Usage examples:
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 thefull list here:
In the long 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.
In progress: