From 03348603bfc9621f6402d0ad073942ac0b47eaca Mon Sep 17 00:00:00 2001 From: Adrian Serrano Date: Thu, 4 Nov 2021 18:06:08 +0100 Subject: [PATCH] Filebeat: Error on startup for unconfigured module 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. --- filebeat/beater/filebeat.go | 16 ---------------- filebeat/fileset/modules.go | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/filebeat/beater/filebeat.go b/filebeat/beater/filebeat.go index 43edc32ff3f..c266faf10ae 100644 --- a/filebeat/beater/filebeat.go +++ b/filebeat/beater/filebeat.go @@ -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 { diff --git a/filebeat/fileset/modules.go b/filebeat/fileset/modules.go index 72c8d17cb25..b8c2c9e374a 100644 --- a/filebeat/fileset/modules.go +++ b/filebeat/fileset/modules.go @@ -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 ®, nil }