-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set the fileProspector's ignoreInactiveSince value #34770
Conversation
…e_active config option
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
@Epakesko thanks for catching this and submitting the fix! Could you add at least a simple test that shows your fix works? It could be as simple as calling |
Hi belimawr Sure, I've added a new test file called prospector_creator_test.go which contains a test with 3 cases: checking if the option is not set, set to since_first_start, and set to since_last_start. If the fix is applied the test passes, if it's not, it fails as the value of ignoreInactiveSince on the fileProspector will always be 0. |
Set the fileProspector's ignoreInactiveSince value based on the ignore_active config option --------- Co-authored-by: Denis <[email protected]>
The filestream input's fileProspector does not take the configured ignore_inactive option into account. This option could be especially important if the registry is not persisted before Filebeat is restarted. In this case, setting ignore_inactive to since_last_start should cause Filebeat to only read the changes made since the restart and ignore old files, but since this value is not actually set in the fileProspector, every file will be fully read again.
What does this PR do?
Sets the ignoreInactiveSince option on the fileProspector, based on the ignore_inactive configuration option.
Why is it important?
Because the ignore_inactive option is currently ignored.
Checklist
[ ] I have commented my code, particularly in hard-to-understand areas[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added tests that prove my fix is effective or that my feature worksCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Start filebeat with the ignore_inactive option set to since_last_start. Example:
Add your log files. The contents of the log files are added to the output.
Stop filebeat, and remove the registry.
Start filebeat, and add new content to the log files.
Expected: Only the newly added content is added to the output.
Result without the fix: The full content of the log files was added to the output.
Result with the fix: Only the newly added content is added to the output.