log: add file rotation support based on size and time intervals#2293
Draft
Dominik-esb wants to merge 1 commit intoprometheus-community:masterfrom
Draft
log: add file rotation support based on size and time intervals#2293Dominik-esb wants to merge 1 commit intoprometheus-community:masterfrom
Dominik-esb wants to merge 1 commit intoprometheus-community:masterfrom
Conversation
Signed-off-by: EisenbergD <dominik.eisenberg@beiersdorf.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this PR does / why we need it
This PR adds log rotation functionality to the windows_exporter logger to prevent log files from growing indefinitely and consuming excessive disk space.
The implementation adds a new
rotatepackage that provides:The
FileWritertype implements theio.Writerinterface, making it a drop-in replacement for standard file writers. Rotated files are renamed with timestamps (e.g.,app-2026-01-08-1704672000.log) to ensure unique names and easy identification.Which issue this PR fixes
(optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close that issue when PR gets merged): fixes #Special notes for your reviewer
internal/log/rotate.go). Integration into the existing logger (internal/log/logger.go) will be needed.Particularly user-facing changes
Once integrated into the logger, users will be able to configure:
--log.rotation-interval: Time interval for log rotation (e.g.,24hfor daily rotation,0to disable)--log.rotation-max-size: Maximum log file size in bytes before rotation (e.g.,10485760for 10MB,0to disable)--log.rotation-max-archives: Number of archived log files to keep (-1to keep all)Example configuration:
Checklist
Complete these before marking the PR as
ready to review: