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

[8.0](backport #28818) Filebeat: Error on startup for unconfigured module #28825

Merged
merged 1 commit into from
Nov 6, 2021
Merged
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
Filebeat: Error on startup for unconfigured module (#28818)
Since #27526 and #27762, Filebeat will have all filesets disabled by
default. To prevent user confusion, a warning message to alert the user
of a configured module without any enabled filesets was added. However,
due to Filebeat internals, this message will only appear for modules
configured from the command-line (--modules flag).

This updates the code to ensure it works also for modules configured via
modules.d directory and turns the warning into a hard-error that
prevents startup.

(cherry picked from commit 707ed1d)
adriansr authored and mergify-bot committed Nov 4, 2021
commit 871c80534f1d945bdd3e3ca80093934f6ab622e2
16 changes: 0 additions & 16 deletions filebeat/beater/filebeat.go
Original file line number Diff line number Diff line change
@@ -111,22 +111,6 @@ func newBeater(b *beat.Beat, plugins PluginFactory, rawConfig *common.Config) (b
if err != nil {
return nil, err
}
if !moduleRegistry.Empty() {
logp.Info("Enabled modules/filesets: %s", moduleRegistry.InfoString())
for _, mod := range moduleRegistry.ModuleNames() {
if mod == "" {
continue
}
filesets, err := moduleRegistry.ModuleConfiguredFilesets(mod)
if err != nil {
logp.Err("Failed listing filesets for module %s", mod)
continue
}
if len(filesets) == 0 {
logp.Warn("Module %s is enabled but has no enabled filesets", mod)
}
}
}

moduleInputs, err := moduleRegistry.GetInputConfigs()
if err != nil {
14 changes: 14 additions & 0 deletions filebeat/fileset/modules.go
Original file line number Diff line number Diff line change
@@ -100,6 +100,20 @@ func newModuleRegistry(modulesPath string,
}
}

logp.Info("Enabled modules/filesets: %s", reg.InfoString())
for _, mod := range reg.ModuleNames() {
if mod == "" {
continue
}
filesets, err := reg.ModuleConfiguredFilesets(mod)
if err != nil {
logp.Err("Failed listing filesets for module %s", mod)
continue
}
if len(filesets) == 0 {
return nil, errors.Errorf("module %s is configured but has no enabled filesets", mod)
}
}
return &reg, nil
}