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

Don't generate a config when disabling logs collection with hints #9305

Merged
merged 4 commits into from
Dec 3, 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
3 changes: 3 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha1...master[Check the HEAD d

*Filebeat*

- Don't generate incomplete configurations when logs collection is disabled by hints. {pull}9305[9305]
- Stop runners disabled by hints after previously being started. {pull}9305[9305]

*Heartbeat*

*Journalbeat*
Expand Down
5 changes: 3 additions & 2 deletions filebeat/autodiscover/builder/hints/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ func (l *logHints) CreateConfig(event bus.Event) []*common.Config {
hints, _ = hIface.(common.MapStr)
}

if builder.IsNoOp(hints, l.Key) == true {
return []*common.Config{config}
if builder.IsNoOp(hints, l.Key) {
logp.Debug("hints.builder", "disabled config in event: %+v", event)
return []*common.Config{}
}

inputConfig := l.getInputs(hints)
Expand Down
2 changes: 1 addition & 1 deletion libbeat/autodiscover/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (r *registry) BuildBuilder(c *common.Config) (Builder, error) {

// GetConfig creates configs for all builders initialized.
func (b Builders) GetConfig(event bus.Event) []*common.Config {
var configs []*common.Config
configs := []*common.Config{}

for _, builder := range b {
if config := builder.CreateConfig(event); config != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ func TestEmitEvent(t *testing.T) {
},
},
},
"config": []*common.Config{},
},
},
{
Expand Down Expand Up @@ -292,7 +293,7 @@ func TestEmitEvent(t *testing.T) {

select {
case event := <-listener.Events():
assert.Equal(t, test.Expected, event)
assert.Equal(t, test.Expected, event, test.Message)
case <-time.After(2 * time.Second):
if test.Expected != nil {
t.Fatal("Timeout while waiting for event")
Expand Down