Skip to content

Commit

Permalink
Add enabled config for prospectors (elastic#3157)
Browse files Browse the repository at this point in the history
The enabled config allows easily to enable and disable a specific prospector. This is consistent with metricbeat where each modules has an enabled config. By default enabled is set to true.
  • Loading branch information
ruflin authored and suraj-soni committed Dec 15, 2016
1 parent ad5ed1e commit 3f61cd7
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ https://github.com/elastic/beats/compare/v5.0.1...master[Check the HEAD diff]
- Reset all states ttl on startup to make sure it is overwritten by new config {pull}2840[2840]
- Persist all states for files which fall under ignore_older to have consistent behaviour {pull}2859[2859]
- Improve shutdown behaviour with large number of files. {pull}3035[3035]
- Add enabled config option to prospectors.

*Winlogbeat*

Expand Down
3 changes: 3 additions & 0 deletions filebeat/_meta/beat.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ filebeat.prospectors:
# Note: Potential data loss. Make sure to read and understand the docs for this option.
#close_timeout: 0

# Defines if prospectors is enabled
#enabled: true

#----------------------------- Stdin prospector -------------------------------
# Configuration to use stdin input
#- input_type: stdin
Expand Down
4 changes: 3 additions & 1 deletion filebeat/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func (c *Crawler) Start(states file.States, once bool) error {
if err != nil {
return fmt.Errorf("Error in initing prospector: %s", err)
}
c.prospectors = append(c.prospectors, prospector)
if prospector.IsEnabled() {
c.prospectors = append(c.prospectors, prospector)
}
}

logp.Info("Loading Prospectors completed. Number of prospectors: %v", len(c.prospectors))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ Currently if a new harvester can be started again, the harvester is picked rando
This configuration option applies per prospector. You can use this option to indirectly set higher priorities on certain prospectors
by assigning a higher limit of harvesters.

===== enabled

The `enabled` option can be used with each prospector to define if a prospector is enabled or not. By default, enabled is set to true.

[[configuration-global-options]]
=== Filebeat Global Configuration

Expand Down
3 changes: 3 additions & 0 deletions filebeat/filebeat.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ filebeat.prospectors:
# Note: Potential data loss. Make sure to read and understand the docs for this option.
#close_timeout: 0

# Defines if prospectors is enabled
#enabled: true

#----------------------------- Stdin prospector -------------------------------
# Configuration to use stdin input
#- input_type: stdin
Expand Down
2 changes: 2 additions & 0 deletions filebeat/prospector/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

var (
defaultConfig = prospectorConfig{
Enabled: true,
IgnoreOlder: 0,
ScanFrequency: 10 * time.Second,
InputType: cfg.DefaultInputType,
Expand All @@ -22,6 +23,7 @@ var (
)

type prospectorConfig struct {
Enabled bool `config:"enabled"`
ExcludeFiles []*regexp.Regexp `config:"exclude_files"`
IgnoreOlder time.Duration `config:"ignore_older"`
Paths []string `config:"paths"`
Expand Down
5 changes: 5 additions & 0 deletions filebeat/prospector/prospector.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ func (p *Prospector) Run(once bool) {
}
}

// IsEnabled returns true if the prospector is eanbled
func (p *Prospector) IsEnabled() bool {
return p.config.Enabled
}

// updateState updates the prospector state and forwards the event to the spooler
// All state updates done by the prospector itself are synchronous to make sure not states are overwritten
func (p *Prospector) updateState(event *input.Event) error {
Expand Down

0 comments on commit 3f61cd7

Please sign in to comment.