Skip to content

Commit

Permalink
Filebeat: Error on startup for unconfigured module
Browse files Browse the repository at this point in the history
Since elastic#27526 and elastic#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.
  • Loading branch information
adriansr committed Nov 4, 2021
1 parent 462f42f commit 0334860
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
16 changes: 0 additions & 16 deletions filebeat/beater/filebeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions filebeat/fileset/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 0334860

Please sign in to comment.