Cherry-pick #17613 to 7.x: Do not rotate log files on startup when interval is configured and rotateonstartup is disabled #17644
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #17613 to 7.x branch. Original message:
What does this PR do?
This PR modifies the interval rotator which is responsible for rotating log files of Filebeat after the specified interval. From now on
rotateonstartup
option is taken into account when setting up this rotator. If the option is set tofalse
, Filebeat tries to set thelastRotate
time to the log file configured. If it cannot be found, Filebeat will not attempt to set the variable. But it is not a problem, as there is no file to rotate.If the user restarts filebeat right before it is able to rotate the first log file, it won't get rotated when Filebeat restarts. For example, the interval is set to 24h, and the user restarts Filebeat after 23 hours, the log file will not be rotated after one more hour. It will be rotated after the 24 hours of runtime has elapsed, as
lastRotate
is set the modification time of the file.Why is it important?
Previously, if both
logging.files.interval
was configured andlogging.files.rotateonstartup
was disabled, Filebeat rotated output log files regardless of therotateonstartup
options.Checklist
- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.