-
Notifications
You must be signed in to change notification settings - Fork 436
Open
Labels
enhancementNew feature or requestNew feature or requestproposalA proposal for new functionality.A proposal for new functionality.
Description
Summary
Currently, the logging
block's write_to
parameter only supports Loki-based LogsReceiver components (like loki.write
, loki.relabel
, etc.). There's no built-in way to write Alloy's internal logs directly to files with log rotation and compression capabilities.
Problem
Users who want to:
- Write Alloy's internal logs to local files (not just stderr)
- Implement log rotation to manage disk usage
- Compress rotated logs to save space
- Avoid the complexity of setting up a full Loki instance just for internal logging
Currently have limited options and must rely on external tools or complex setups.
Proposed Solution
Add a new component (e.g., local.file_write
) that implements the LogsReceiver interface and provides:
- File-based log output with configurable path
- Built-in log rotation based on size, age, or both
- Compression of rotated files
- Configurable retention policies
This could leverage existing libraries like lumberjack which provides these features out of the box.
Example Usage
local.file_write "internal_logs" {
filename = "/var/log/alloy/alloy.log"
max_size = 100 // MB
max_backups = 3
max_age = 28 // days
compress = true
}
logging {
level = "info"
format = "json"
write_to = [local.file_write.internal_logs.receiver]
}
Benefits
- Simplified log management for users who prefer file-based logging
- Built-in rotation and compression without external dependencies
- Consistent with Alloy's component-based architecture
- Reduces operational complexity for users not using Loki
Alternative Workarounds
Currently, users must:
- Use system-level log rotation tools with stderr redirection
- Set up a local Loki instance just for internal logs
- Implement custom log forwarding solutions
A built-in file-based LogsReceiver would eliminate these complexities.
Nachtfalkeaw
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestproposalA proposal for new functionality.A proposal for new functionality.
Type
Projects
Status
Incoming