Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change template loading configuration to be part of setup #4080

Merged
merged 1 commit into from
May 4, 2017

Conversation

ruflin
Copy link
Member

@ruflin ruflin commented Apr 21, 2017

  • 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

@ruflin ruflin added in progress Pull request is currently in progress. libbeat labels Apr 21, 2017
@ruflin ruflin force-pushed the move-template-to-setup branch 2 times, most recently from 31c0e65 to c93d68c Compare April 24, 2017 11:57
@ruflin ruflin changed the title [WIP] Change template loading to be part of the setup Change template loading to be part of the setup Apr 24, 2017
@ruflin ruflin added the review label Apr 24, 2017
@@ -252,6 +254,11 @@ func (b *Beat) launch(bt Creator) error {
return err
}

err = b.loadTemplate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. This just go a lot trickier to implement as it now uses its own client.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

@@ -447,6 +454,48 @@ func (b *Beat) loadDashboards() error {
return nil
}

func (b *Beat) loadTemplate() error {
if *setup {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template should be always loaded, not only on -setup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be always loaded. The check on line 472 is different from the Dashboard one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but then this check here is not needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you run -setup but have setup.template.enabled: false what is the expected behaviour?

esConfig := b.Config.Output["elasticsearch"]

// Loads template by default if esOutput is enabled
if (b.Config.Template == nil && esConfig.Enabled()) || (b.Config.Dashboards != nil && b.Config.Template.Enabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a reference to b.Config.Dasboards there, by mistake?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@ruflin ruflin force-pushed the move-template-to-setup branch from 6a14fab to 27755db Compare April 25, 2017 09:07
@@ -71,6 +71,12 @@ type Connection struct {
version string
}

var connectCallbackRegister connectCallback
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@ruflin ruflin force-pushed the move-template-to-setup branch from 27755db to 5133bf6 Compare April 28, 2017 11:04
@ruflin ruflin removed the in progress Pull request is currently in progress. label Apr 28, 2017
@@ -0,0 +1,10 @@
package beat

type TemplateConfig struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type TemplateConfig should have comment or be unexported

@@ -0,0 +1,17 @@
package template

type TemplateConfig struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type TemplateConfig should have comment or be unexported

@@ -0,0 +1,17 @@
package template

type TemplateConfig struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
comment on exported type ESClient should be of the form "ESClient ..." (with optional leading article)

GetVersion() string
}

type Loader struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported function NewLoader should have comment or be unexported

}, nil
}

// loadTemplate checks if the index mapping template should be loaded
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
comment on exported method Loader.Load should be of the form "Load ..."

@tsg tsg merged commit 4ae0b89 into elastic:master May 4, 2017
@monicasarbu monicasarbu deleted the move-template-to-setup branch May 7, 2017 21:12
@monicasarbu monicasarbu changed the title Change template loading to be part of the setup Change template loading configuration to be part of setup May 8, 2017
@tsg tsg mentioned this pull request Jul 24, 2017
28 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants