-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move prospector log to its own package with log harvester
This is the last step in reorganising the packages related to prospector and harvester. Follow up PR's will mainly focusing on abstracting out common functionality, standardise naming and have proper interfaces. * Merge log harvester and log prospector config into one config * Rename Log to prospector as part of the new package structure * Move log harvester logic to log prospector package * Keep common harvester logic in its own package * stdin harvester still heavily depends on log harvester, needs to be split up and simplified at a later stage * Further cleanup of Prospector interface. `Wait()` only exists as a temporary solution.
- Loading branch information
Showing
18 changed files
with
268 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,19 @@ | ||
package prospector | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
cfg "github.com/elastic/beats/filebeat/config" | ||
"github.com/elastic/beats/libbeat/common/match" | ||
) | ||
|
||
var ( | ||
defaultConfig = prospectorConfig{ | ||
Enabled: true, | ||
IgnoreOlder: 0, | ||
ScanFrequency: 10 * time.Second, | ||
InputType: cfg.DefaultInputType, | ||
CleanInactive: 0, | ||
CleanRemoved: true, | ||
HarvesterLimit: 0, | ||
Symlinks: false, | ||
TailFiles: false, | ||
ScanFrequency: 10 * time.Second, | ||
InputType: cfg.DefaultInputType, | ||
} | ||
) | ||
|
||
type prospectorConfig struct { | ||
Enabled bool `config:"enabled"` | ||
ExcludeFiles []match.Matcher `config:"exclude_files"` | ||
IgnoreOlder time.Duration `config:"ignore_older"` | ||
Paths []string `config:"paths"` | ||
ScanFrequency time.Duration `config:"scan_frequency" validate:"min=0,nonzero"` | ||
InputType string `config:"input_type"` | ||
CleanInactive time.Duration `config:"clean_inactive" validate:"min=0"` | ||
CleanRemoved bool `config:"clean_removed"` | ||
HarvesterLimit uint64 `config:"harvester_limit" validate:"min=0"` | ||
Symlinks bool `config:"symlinks"` | ||
TailFiles bool `config:"tail_files"` | ||
recursiveGlob bool `config:"recursive_glob.enabled"` | ||
} | ||
|
||
func (config *prospectorConfig) Validate() error { | ||
|
||
if config.InputType == cfg.LogInputType && len(config.Paths) == 0 { | ||
return fmt.Errorf("No paths were defined for prospector") | ||
} | ||
|
||
if config.CleanInactive != 0 && config.IgnoreOlder == 0 { | ||
return fmt.Errorf("ignore_older must be enabled when clean_inactive is used") | ||
} | ||
|
||
if config.CleanInactive != 0 && config.CleanInactive <= config.IgnoreOlder+config.ScanFrequency { | ||
return fmt.Errorf("clean_inactive must be > ignore_older + scan_frequency to make sure only files which are not monitored anymore are removed") | ||
} | ||
|
||
return nil | ||
ScanFrequency time.Duration `config:"scan_frequency" validate:"min=0,nonzero"` | ||
InputType string `config:"input_type"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
filebeat/harvester/harvester_test.go → filebeat/prospector/log/harvester_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// +build !integration | ||
|
||
package harvester | ||
package log |
2 changes: 1 addition & 1 deletion
2
filebeat/harvester/json_test.go → filebeat/prospector/log/json_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package harvester | ||
package log | ||
|
||
import ( | ||
"testing" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.