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

Central management for hb #9254

Merged
merged 2 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ https://github.com/elastic/beats/compare/v6.4.0...v6.5.0[View commits]
- Added support for extra TLS/x509 metadata. {pull}7944[7944]
- Added stats and state metrics for number of monitors and endpoints started. {pull}8621[8621]
- Add last monitor status to dashboard table. Further break out monitors in dashboard table by monitor.ip. {pull}9022[9022]
- Add central management support. {pull}9254[9254]

*Journalbeat*

Expand Down
12 changes: 12 additions & 0 deletions heartbeat/beater/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import (
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/cfgfile"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/common/reload"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/management"
)

// Heartbeat represents the root datastructure of this beat.
Expand Down Expand Up @@ -82,6 +84,10 @@ func (bt *Heartbeat) Run(b *beat.Beat) error {
return err
}

if b.ConfigManager.Enabled() {
bt.RunCentralMgmtMonitors(b)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not registering these always? I'm wondering if there could be a timing issue here, something like:

  • Central Management fetches configs and calls reload, heartbeat.monitors is not yet registered
  • This code registers the reloadable after that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, I just copied from https://github.com/elastic/beats/blob/master/metricbeat/beater/metricbeat.go#L109 but if it isn't necessary I'm glad to remove the conditional.

Is that safe?

Copy link
Contributor

Choose a reason for hiding this comment

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

I checked how it's done in Metricbeat and it could have the same issue, I'm guessing that even in the improbable case of this happening, it would be fixed by the next pass on config apply. 👍 to leave it like this

}

if bt.config.ConfigMonitors.Enabled() {
bt.monitorReloader = cfgfile.NewReloader(b.Publisher, bt.config.ConfigMonitors)
defer bt.monitorReloader.Stop()
Expand Down Expand Up @@ -127,6 +133,12 @@ func (bt *Heartbeat) RunStaticMonitors(b *beat.Beat) error {
return nil
}

// RunCentralMgmtMonitors loads any central management configured configs.
func (bt *Heartbeat) RunCentralMgmtMonitors(b *beat.Beat) {
monitors := cfgfile.NewRunnerList(management.DebugK, bt.dynamicFactory, b.Publisher)
reload.Register.MustRegisterList(b.Info.Beat+".monitors", monitors)
}

// RunReloadableMonitors runs the `heartbeat.config.monitors` portion of the yaml config if present.
func (bt *Heartbeat) RunReloadableMonitors(b *beat.Beat) (err error) {
// Check monitor configs
Expand Down
2 changes: 2 additions & 0 deletions libbeat/docs/shared-central-management.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ environment. The `development` tag might have:
another that reads metrics from Apache HTTP servers
* Two Filebeat module configuration blocks: one that reads Apache HTTP server
logs and another that reads system logs
* One heartbeat monitor configuration block: checks that a public facing website
is live.
* One Elasticsearch output configuration block that sends the output to your
{es} development cluster

Expand Down