Skip to content

Commit 0334860

Browse files
committed
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.
1 parent 462f42f commit 0334860

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

filebeat/beater/filebeat.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,6 @@ func newBeater(b *beat.Beat, plugins PluginFactory, rawConfig *common.Config) (b
111111
if err != nil {
112112
return nil, err
113113
}
114-
if !moduleRegistry.Empty() {
115-
logp.Info("Enabled modules/filesets: %s", moduleRegistry.InfoString())
116-
for _, mod := range moduleRegistry.ModuleNames() {
117-
if mod == "" {
118-
continue
119-
}
120-
filesets, err := moduleRegistry.ModuleConfiguredFilesets(mod)
121-
if err != nil {
122-
logp.Err("Failed listing filesets for module %s", mod)
123-
continue
124-
}
125-
if len(filesets) == 0 {
126-
logp.Warn("Module %s is enabled but has no enabled filesets", mod)
127-
}
128-
}
129-
}
130114

131115
moduleInputs, err := moduleRegistry.GetInputConfigs()
132116
if err != nil {

filebeat/fileset/modules.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,20 @@ func newModuleRegistry(modulesPath string,
100100
}
101101
}
102102

103+
logp.Info("Enabled modules/filesets: %s", reg.InfoString())
104+
for _, mod := range reg.ModuleNames() {
105+
if mod == "" {
106+
continue
107+
}
108+
filesets, err := reg.ModuleConfiguredFilesets(mod)
109+
if err != nil {
110+
logp.Err("Failed listing filesets for module %s", mod)
111+
continue
112+
}
113+
if len(filesets) == 0 {
114+
return nil, errors.Errorf("module %s is configured but has no enabled filesets", mod)
115+
}
116+
}
103117
return &reg, nil
104118
}
105119

0 commit comments

Comments
 (0)