feat(data-retention): add automated pruning for audit logs and analyt…#931
Open
Adeyemi-cmd wants to merge 1 commit into
Open
feat(data-retention): add automated pruning for audit logs and analyt…#931Adeyemi-cmd wants to merge 1 commit into
Adeyemi-cmd wants to merge 1 commit into
Conversation
|
@Adeyemi-cmd Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Great work on this PR |
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.
Close #848
PR Description
Summary
GDPR Article 5(1)(e) requires data to not be kept longer than necessary.
Audit logs and analytics events were accumulating indefinitely with no
automated pruning, degrading query performance and creating compliance risk.
Changes
Environment Variables
AUDIT_LOG_RETENTION_DAYS— audit log retention period (default730= 2 years)ANALYTICS_RETENTION_DAYS— analytics event retention period (default365= 1 year).env.example,env.validation.ts(Joi), andretention.config.tsAuditRetentionTask (
src/audit-log/tasks/audit-retention.task.ts)AUDIT_LOG_RETENTION_DAYSfrom configdo...whileloop with.limit())deleted_count{table="audit_logs"}Prometheus counter per runAnalyticsRetentionTask (
src/analytics/tasks/analytics-retention.task.ts) [NEW]ANALYTICS_RETENTION_DAYSfrom config (default 365)AnalyticsEventrows wheretimestamp < cutoffin batches of 1000deleted_count{table="analytics_events"}Prometheus counter