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

Disable add_kubernetes_metadata if no matchers found #13709

Merged
merged 2 commits into from
Sep 17, 2019
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.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Load DLLs only from Windows system directory. {pull}13234[13234] {pull}13384[13384]
- Fix mapping for kubernetes.labels and kubernetes.annotations in add_kubernetes_metadata. {issue}12638[12638] {pull}13226[13226]
- Fix case insensitive regular expressions not working correctly. {pull}13250[13250]
- Disable `add_kubernetes_metadata` if no matchers found. {pull}13709[13709]

*Auditbeat*

Expand Down
21 changes: 11 additions & 10 deletions libbeat/processors/add_kubernetes_metadata/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,7 @@ func New(cfg *common.Config) (processors.Processor, error) {
return nil, err
}

indexers := NewIndexers(config.Indexers, metaGen)

matchers := NewMatchers(config.Matchers)

if matchers.Empty() {
return nil, fmt.Errorf("Can not initialize kubernetes plugin with zero matcher plugins")
}

processor := &kubernetesAnnotator{
indexers: indexers,
matchers: matchers,
cache: newCache(config.CleanupTimeout),
kubernetesAvailable: false,
}
Expand All @@ -129,6 +119,17 @@ func New(cfg *common.Config) (processors.Processor, error) {
return processor, nil
}

processor.indexers = NewIndexers(config.Indexers, metaGen)

matchers := NewMatchers(config.Matchers)

if matchers.Empty() {
logp.Debug("kubernetes", "%v: could not initialize kubernetes plugin with zero matcher plugins", "add_kubernetes_metadata")
return processor, nil
}

processor.matchers = matchers

config.Host = kubernetes.DiscoverKubernetesNode(config.Host, kubernetes.IsInCluster(config.KubeConfig), client)

logp.Debug("kubernetes", "Using host: %s", config.Host)
Expand Down