Change template loading configuration to be part of setup#4080
Change template loading configuration to be part of setup#4080tsg merged 1 commit intoelastic:masterfrom
Conversation
31c0e65 to
c93d68c
Compare
libbeat/beat/beat.go
Outdated
There was a problem hiding this comment.
Hmm, if I understand it correctly, this means that the template loading is only attempted once at startup not on every connection made to ES? If this is the case, then this is a regression for two reasons:
- If ES is not up when the Beat start, the Beat will fail with an error. It used to "wait" for ES to come up
- If for whatever reason ES is restarted without data, but the Beat is not restarted, the template is not loaded again, resulting in bad mapping.
There was a problem hiding this comment.
Good point. This just go a lot trickier to implement as it now uses its own client.
There was a problem hiding this comment.
TBH this is a deal breaker for me, especially the part where Beats don't start if ES is not up is going to really annoying to users.
Ideally we'd also have the pipelines loaded on each connection. It's currently done only on startup, but that can lead to errors similar to these. I think we need some sort of generic callback mechanism to do this.
libbeat/beat/beat.go
Outdated
There was a problem hiding this comment.
The template should be always loaded, not only on -setup.
There was a problem hiding this comment.
It should be always loaded. The check on line 472 is different from the Dashboard one.
There was a problem hiding this comment.
Ok, but then this check here is not needed?
There was a problem hiding this comment.
if you run -setup but have setup.template.enabled: false what is the expected behaviour?
libbeat/beat/beat.go
Outdated
There was a problem hiding this comment.
There's a reference to b.Config.Dasboards there, by mistake?
6a14fab to
27755db
Compare
There was a problem hiding this comment.
Having this as global means it will also be applied to non-output ES clients (e.g. the one loading the dashboards, or the one loading the pipelines or the one for monitoring). That is perhaps OK, but mentioning it in case someone else thinks of something about that.
Of course, the global is kind of last resort solution. @urso any suggestions on how we can improve this? (Not necessarily in this PR).
There was a problem hiding this comment.
That is also getting interesting in the case we would allow in the setup to define an elasticsearch host to load the template potentially with a different user. We already have something similar for the metrics.
Talking about metrics, this means also for the connection to the monitoring instance it would load the template? Not sure if this is intended.
* Change config option to setup.template.* from outputs.elasticsearch.template.* * Move loading logic into template package * Remove template loading logic from elasticsearch output * Changelog updated * Template tests were moved from output to template package * Documentation was updated. Will need some more work for which a follow up Github issue will be created. * Add `GetVersion()` to elasticsearch client. * Introduce callback registration for elasticsearch output. This should be generalised later. The template loading registers only with the output client factory which means, the template is not loaded when connecting for loading dashboards, pipeline or monitoring data which is intended. This is only migration the existing options. New options like outputting to a json file or load additional config options will be added in a follow up PR. Part of elastic#3654 and elastic#3921
27755db to
5133bf6
Compare
| @@ -0,0 +1,10 @@ | |||
| package beat | |||
|
|
|||
| type TemplateConfig struct { | |||
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported type TemplateConfig should have comment or be unexported
| @@ -0,0 +1,17 @@ | |||
| package template | |||
|
|
|||
| type TemplateConfig struct { | |||
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported type TemplateConfig should have comment or be unexported
| @@ -0,0 +1,17 @@ | |||
| package template | |||
|
|
|||
| type TemplateConfig struct { | |||
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
type name will be used as template.TemplateConfig by other packages, and that stutters; consider calling this Config
| "github.com/elastic/beats/libbeat/paths" | ||
| ) | ||
|
|
||
| // TemplateLoader is a subset of the Elasticsearch client API capable of |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
comment on exported type ESClient should be of the form "ESClient ..." (with optional leading article)
| GetVersion() string | ||
| } | ||
|
|
||
| type Loader struct { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported type Loader should have comment or be unexported
| beatInfo common.BeatInfo | ||
| } | ||
|
|
||
| func NewLoader(cfg *common.Config, client ESClient, beatInfo common.BeatInfo) (*Loader, error) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function NewLoader should have comment or be unexported
| }, nil | ||
| } | ||
|
|
||
| // loadTemplate checks if the index mapping template should be loaded |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
comment on exported method Loader.Load should be of the form "Load ..."
GetVersion()to elasticsearch client.This is only migration the existing options. New options like outputting to a json file or load additional config options will be added in a follow up PR.
Part of elastic#3654 and elastic#3921