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

libbeat/beat: introduce Beat.OutputConfigReloader #28048

Merged
merged 2 commits into from
Oct 4, 2021
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-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,4 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
- Add sorting to array fields for generated data files (*-generated.json) {pull}25320[25320]
- Update to go-concert 0.2.0 {pull}27162[27162]
- Update Go version to 1.16.5. {issue}26182[26182] {pull}26186[26186]
- Introduce `libbeat/beat.Beat.OutputConfigReloader` {pull}28048[28048]
7 changes: 7 additions & 0 deletions libbeat/beat/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package beat

import (
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/reload"
"github.com/elastic/beats/v7/libbeat/instrumentation"
"github.com/elastic/beats/v7/libbeat/keystore"
"github.com/elastic/beats/v7/libbeat/management"
Expand Down Expand Up @@ -63,6 +64,12 @@ type Beat struct {
// pipeline and ML jobs.
Config *BeatConfig // Common Beat configuration data.

// OutputConfigReloader may be set by a Creator to watch for output config changes.
//
// This reloader is called in addition to libbeat's internal output reloader, which
// is responsible for reconfiguring Publisher.
OutputConfigReloader reload.Reloadable

BeatConfig *common.Config // The beat's own configuration section

Fields []byte // Data from fields.yml
Expand Down
5 changes: 5 additions & 0 deletions libbeat/cmd/instance/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,11 @@ func (b *Beat) indexSetupCallback() elasticsearch.ConnectCallback {

func (b *Beat) makeOutputReloader(outReloader pipeline.OutputReloader) reload.Reloadable {
return reload.ReloadableFunc(func(config *reload.ConfigWithMeta) error {
if b.OutputConfigReloader != nil {
if err := b.OutputConfigReloader.Reload(config); err != nil {
return err
}
}
return outReloader.Reload(config, b.createOutput)
})
}
Expand Down