feat(coderd): add retention policy configuration (#21021)

Add `RetentionConfig` with server flags for configuring data retention:

- `--audit-logs-retention`: retention for audit log entries
- `--connection-logs-retention`: retention for connection logs
- `--api-keys-retention`: retention for expired API keys (default 7d)

Updates #20743
This commit is contained in:
Mathias Fredriksson
2025-12-02 16:04:06 +02:00
committed by GitHub
parent 74d0c39cb3
commit 56e7858570
11 changed files with 314 additions and 0 deletions
+33
View File
@@ -1770,3 +1770,36 @@ Whether to inject Coder's MCP tools into intercepted AI Bridge requests (require
| Default | <code>60d</code> |
Length of time to retain data such as interceptions and all related records (token, prompt, tool use).
### --audit-logs-retention
| | |
|-------------|------------------------------------------|
| Type | <code>duration</code> |
| Environment | <code>$CODER_AUDIT_LOGS_RETENTION</code> |
| YAML | <code>retention.audit_logs</code> |
| Default | <code>0</code> |
How long audit log entries are retained. Set to 0 to disable (keep indefinitely). We advise keeping audit logs for at least a year, and in accordance with your compliance requirements.
### --connection-logs-retention
| | |
|-------------|-----------------------------------------------|
| Type | <code>duration</code> |
| Environment | <code>$CODER_CONNECTION_LOGS_RETENTION</code> |
| YAML | <code>retention.connection_logs</code> |
| Default | <code>0</code> |
How long connection log entries are retained. Set to 0 to disable (keep indefinitely).
### --api-keys-retention
| | |
|-------------|----------------------------------------|
| Type | <code>duration</code> |
| Environment | <code>$CODER_API_KEYS_RETENTION</code> |
| YAML | <code>retention.api_keys</code> |
| Default | <code>7d</code> |
How long expired API keys are retained before being deleted. Keeping expired keys allows the backend to return a more helpful error when a user tries to use an expired key. Set to 0 to disable automatic deletion of expired keys.