Add the option to generate the template into a file#4323
Add the option to generate the template into a file#4323ruflin merged 4 commits intoelastic:masterfrom
Conversation
|
Perhaps we should discuss again with after Or assuming -S is implies |
| } | ||
|
|
||
| // XXX: Should we kill the Beat here or just continue? | ||
| return fmt.Errorf("Stopping after successfully writing the template to the file.") |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
error strings should not be capitalized or end with punctuation or a newline
There was a problem hiding this comment.
In this case, dear reviewdog, we know that the error is final, so the punctuation looks better to the user.
| return nil | ||
| } | ||
|
|
||
| func (l *Loader) Generate() error { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported method Loader.Generate should have comment or be unexported
|
@ruflin Yeah, I guess we should review the whole I have the feeling we can't get a nice solution as part of this PR, so the question is what do we want for the time being? IMO stopping is much nicer in this case, but it's inconsistent with |
|
Agree that we can't find a good solution as part of this PR. +1 on stopping as if you want to manually load the template, you don't want to already send data. |
ruflin
left a comment
There was a problem hiding this comment.
I left a few comments which we should handle in a follow up. Will merge it for now as this is a big step forward.
| } | ||
|
|
||
| esConfig := b.Config.Output["elasticsearch"] | ||
| // Check if outputting to file is enabled, and output to file if it is |
There was a problem hiding this comment.
This comment confused me at first because the check for the file only happens later, but I see you meant it for the "complete" block
| Overwrite bool `config:"overwrite"` | ||
| OutputToFile string `config:"output_to_file"` | ||
| Settings templateSettings `config:"settings"` | ||
| OutputToFile OutputToFile `config:"output_to_file"` |
There was a problem hiding this comment.
Not too much of a fan of the config name, but well :-)
|
|
||
| // Generate generates the template and writes it to a file based on the configuration | ||
| // from `output_to_file`. | ||
| func (l *Loader) Generate() error { |
There was a problem hiding this comment.
We could probably now use this function also in https://github.com/elastic/beats/blob/master/dev-tools/cmd/index_template/index_template.go
There was a problem hiding this comment.
Oh, I didn't realize we have that utility already.
| self.beat_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")) | ||
| self.test_binary = self.beat_path + "/libbeat.test" | ||
| self.beats = [ | ||
| "filebeat", |
There was a problem hiding this comment.
Looks like a beats specifics dependency in libbeat.
There was a problem hiding this comment.
Yeah, only needed for those skipped tets for now, I can delete them.
| beats = ["metricbeat", "packetbeat", "filebeat", "winlogbeat"] | ||
|
|
||
| for beat in beats: | ||
| for beat in self.beats: |
There was a problem hiding this comment.
be aware that these tests are currently skipped.
Part of #3654.
This adds two settings:
setup.template.output_to_file.pathandsetup.template.output_to_file.version. The version refers to the ES version and is optional, we'll use the Beats version if not specified. I put it underoutput_to_fileto make it clear that it only applies when outputting to a file:To generate a config, one can do:
In the current version, the Beat automatically stops after generating the template, but the output might be slightly confusing:
IMO this is better than the alternative of leaving it running.
To generate the template for the 2.x version, one can do:
Remaining TODOs: