Skip to content

Commit

Permalink
Register filebeat inputs & modules for central management (elastic#8560
Browse files Browse the repository at this point in the history
…) (elastic#8583)

This change registers `filebeat.inputs` and `filebeat.modules`
reloadables, exposing them to be handled by central management.

(cherry picked from commit 41f5680)
  • Loading branch information
exekias authored Oct 18, 2018
1 parent 1a52259 commit 8bc6101
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion filebeat/beater/filebeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"fmt"
"strings"

"github.com/elastic/beats/libbeat/common/reload"

"github.com/joeshaw/multierror"
"github.com/pkg/errors"

Expand All @@ -32,6 +34,7 @@ import (
"github.com/elastic/beats/libbeat/common/cfgwarn"
"github.com/elastic/beats/libbeat/kibana"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/management"
"github.com/elastic/beats/libbeat/monitoring"
"github.com/elastic/beats/libbeat/outputs/elasticsearch"

Expand Down Expand Up @@ -391,6 +394,13 @@ func (fb *Filebeat) Run(b *beat.Beat) error {
waitFinished.Add(runOnce)
}

// Register reloadable list of inputs and modules
inputs := cfgfile.NewRunnerList(management.DebugK, crawler.InputsFactory, b.Publisher)
reload.Register.MustRegisterList("filebeat.inputs", inputs)

modules := cfgfile.NewRunnerList(management.DebugK, crawler.ModulesFactory, b.Publisher)
reload.Register.MustRegisterList("filebeat.modules", modules)

var adiscover *autodiscover.Autodiscover
if fb.config.Autodiscover != nil {
adapter := fbautodiscover.NewAutodiscoverAdapter(crawler.InputsFactory, crawler.ModulesFactory)
Expand All @@ -405,10 +415,12 @@ func (fb *Filebeat) Run(b *beat.Beat) error {
waitFinished.AddChan(fb.done)
waitFinished.Wait()

// Stop autodiscover -> Stop crawler -> stop inputs -> stop harvesters
// Stop reloadable lists, autodiscover -> Stop crawler -> stop inputs -> stop harvesters
// Note: waiting for crawlers to stop here in order to install wgEvents.Wait
// after all events have been enqueued for publishing. Otherwise wgEvents.Wait
// or publisher might panic due to concurrent updates.
inputs.Stop()
modules.Stop()
adiscover.Stop()
crawler.Stop()

Expand Down

0 comments on commit 8bc6101

Please sign in to comment.