-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(coderd/database/dbpurge): add retention for audit logs #21025
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
Merged
+296
−0
Conversation
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
This was referenced Dec 1, 2025
07ae594 to
9ca58c3
Compare
782f1f7 to
039afdb
Compare
9ca58c3 to
a21395a
Compare
dannykopping
approved these changes
Dec 2, 2025
Contributor
dannykopping
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except for batch size; I won't need to re-review.
a21395a to
82f1c2b
Compare
Emyrk
approved these changes
Dec 2, 2025
Member
Emyrk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Agree 1k is low
82f1c2b to
2ce8f62
Compare
Member
Author
|
@dannykopping @Emyrk I've bumped to 10k for both audit and connection logs 👍🏻 |
6433def to
d456497
Compare
2ce8f62 to
8cb020d
Compare
Base automatically changed from
mafredri/feat-coderd-db-retention-policy-2
to
main
December 2, 2025 14:17
Add configurable retention policy for audit logs. The DeleteOldAuditLogs query excludes deprecated connection events (connect, disconnect, open, close) which are handled separately by DeleteOldAuditLogConnectionEvents. Falls back to global retention if audit logs retention is unset. Disabled (0) by default. Depends on #21021 Updates #20743
Audit logs retention is now explicit - it's enabled when --audit-logs-retention is set to a non-zero duration, and disabled when set to 0. No fallback to global retention.
Use :execrows instead of :one to simplify the query by removing the extra CTE wrapper. This lets PostgreSQL return the row count directly via RowsAffected() instead of requiring an explicit COUNT(*) scan.
8cb020d to
2a45adb
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Add configurable retention policy for audit logs. The DeleteOldAuditLogs
query excludes deprecated connection events (connect, disconnect, open,
close) which are handled separately by DeleteOldAuditLogConnectionEvents.
Disabled (0) by default.
Depends on #21021
Updates #20743
PR Stack
workspace_agent_logs