Skip to content

feat: export log retention metrics - #35

Merged
HaoZeke merged 1 commit into
mainfrom
feat/metrics
Nov 18, 2026
Merged

HaoZeke merged 1 commit into
mainfrom
feat/metrics

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

This adds opt-in Prometheus text exposition for log retention through --metrics-file PATH on failed and rotate. Without the flag, nothing changes and no metrics file is written.

The file carries three series. eb_keep_logs_logs_kept_total counts kept-log operations. eb_keep_logs_bytes_kept_total counts the bytes they wrote. eb_keep_logs_last_prune_timestamp_seconds records the Unix time when the last rotation finished.

Each writer takes a sidecar lock before it reads the old values. Under that lock it picks the completion time, so the timestamp never moves backwards when rotations finish out of order. The EB_KEEP_LOGS_NOW override affects run-age checks only, not this timestamp. Each command keeps the values the other command owns. The new content goes to a temporary file in the target directory, gets synced, and then replaces the target with an atomic rename.

New metrics files get mode 0644. A replaced file keeps its exact old mode, even under a strict umask. If restoring the mode fails, the command removes the temporary file and leaves the old exposition alone. Counters use the full unsigned 64-bit range. On overflow or a parse error the previous file stays as it was. The shell script and the Zig build behave the same way here.

Alongside the file handling, the docs gain a how-to for feeding the metrics file to the node_exporter textfile collector, plus updates to the CLI reference and the local-time explanation. CI and release workflows pin promtool 3.7.3, and the new integration and unit tests run promtool check metrics on the output.

@HaoZeke
HaoZeke merged commit 5b02b09 into main Nov 18, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant