Skip to content

Commit

Permalink
Make module directory optional (#3405)
Browse files Browse the repository at this point in the history
Before filebeat was stopping when module directory did not exist. Module directory should not be required.
  • Loading branch information
ruflin authored and tsg committed Jan 19, 2017
1 parent 0dbb695 commit 5878188
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions filebeat/beater/filebeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ func New(b *beat.Beat, rawConfig *common.Config) (beat.Beater, error) {
return nil, err
}

moduleProspectors, err := moduleRegistry.GetProspectorConfigs()
if err != nil {
return nil, err
var moduleProspectors []*common.Config
if moduleRegistry != nil {
var err error
moduleProspectors, err = moduleRegistry.GetProspectorConfigs()
if err != nil {
return nil, err
}
}

if err := config.FetchConfigs(); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions filebeat/fileset/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/paths"
)

Expand Down Expand Up @@ -82,6 +83,13 @@ func newModuleRegistry(modulesPath string,
// NewModuleRegistry reads and loads the configured module into the registry.
func NewModuleRegistry(moduleConfigs []*common.Config) (*ModuleRegistry, error) {
modulesPath := paths.Resolve(paths.Home, "module")

stat, err := os.Stat(modulesPath)
if err != nil || !stat.IsDir() {
logp.Info("Not loading modules. Module directory not found: %s")
return nil, nil
}

modulesCLIList, modulesOverrides, err := getModulesCLIConfig()
if err != nil {
return nil, err
Expand Down

0 comments on commit 5878188

Please sign in to comment.