Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement prospector reloading (#3362)
This PR allows to dynamically reload prospectors. It works the same way as module reloading in metricbeat. **Refactoring** * LoadStates was separated from NewProspector. The reason is that after New only the ID is needed and setting up states requires more calculations. So this can be done in a second step when all the validations are done. * Only allow to start a prospector when all states are set to Finished. If not, LoadStates returns an error. This is to prevent a prospector starting before a harvester finished with a file. The prospector will be picked up again during the next reloading phase. * Extract ReloadConfig to libbeat **Limitations** This implementation currently has the some limitations. This are not new in filebeat but require more care as configurations change more often. * Two prospectors on one file: It is possible, that two prospectors pick up one file because they defined overlapping patterns. This can have the consequence that two harvesters on the same file are running which can lead to duplicates and unpredictable behaviour. The risk is minimized in that a prospector does not start as long as a state it takes care of is not finished. But it can still happen that a Finished state is picked up but it also managed by an other prospector. The user must ensure no prospector paths overlap. This problem can potentially be solved in the future with a global harvester registry. **Notes** * In a later PR, more refactoring and unification of the reloading should happen.
- Loading branch information
Showing
21 changed files
with
513 additions
and
83 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
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 was deleted.
Oops, something went wrong.
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
41 changes: 41 additions & 0 deletions
41
filebeat/docs/reference/configuration/reload-configuration.asciidoc
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[[filebeat-configuration-reloading]] | ||
=== Reload Configuration | ||
|
||
experimental[] | ||
|
||
Reload configuration allows to dynamically reload prospector configuration files. A glob can be defined which should be watched | ||
for prospector configuration changes. New prospectors will be started / stopped accordingly. This is especially useful in | ||
container environments where 1 container is used to tail logs from services in other containers on the same host. | ||
|
||
The configuration in the main filebeat.yml config file looks as following: | ||
|
||
[source,yaml] | ||
------------------------------------------------------------------------------ | ||
filebeat.reload.prospectors: | ||
enabled: true | ||
path: configs/*.yml | ||
period: 10s | ||
------------------------------------------------------------------------------ | ||
|
||
A path with a glob must be defined on which files should be checked for changes. A period is set on how often | ||
the files are checked for changes. Do not set period below 1s as the modification time of files is often stored in seconds. | ||
Setting it below 1s will cause an unnecessary overhead. | ||
|
||
The configuration inside the files which are found by the glob look as following: | ||
[source,yaml] | ||
------------------------------------------------------------------------------ | ||
- input_type: log | ||
paths: | ||
- /var/log/mysql.log | ||
scan_frequency: 10s | ||
- input_type: log | ||
paths: | ||
- /var/log/apache.log | ||
scan_frequency: 5s | ||
------------------------------------------------------------------------------ | ||
|
||
Each file directly contains a list of prospectors. Each file can contain one or multiple prospector definitions. | ||
|
||
WARNING: It is critical that two running prospectors DO NOT have overlapping file paths defined. If more then one prospector | ||
harvests the same file at the same time, it can lead to unexpected behaviour. |
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
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
Oops, something went wrong.