GitHub user dosubot[bot] added a comment to the discussion: Superset DB Log
Retention & Pruning Strategies
<!-- Answer -->
To automatically delete logs older than 1 year (365 days), add a prune_logs
task to your CeleryConfig beat_schedule with the retention period specified in
kwargs. The reports.prune_log task only prunes report schedule logs, not
general user activity logs. Here’s how you can update your configuration:
```python
beat_schedule = {
'reports.scheduler': {
'task': 'reports.scheduler',
'schedule': crontab(minute='*', hour='*'),
},
'reports.prune_log': {
'task': 'reports.prune_log',
'schedule': crontab(minute=0, hour=0),
},
'prune_logs': {
'task': 'prune_logs',
'schedule': crontab(minute=0, hour=1), # runs daily at 1am
'kwargs': {'retention_period_days': 365},
},
}
```
This will prune entries from the logs table older than 1 year, using Superset’s
LogPruneCommand via the prune_logs Celery task. Make sure to use kwargs (not
options) for retention_period_days, as passing via options is deprecated
[reference](https://github.com/apache/superset/blob/master/superset/config.py)
[reference](https://github.com/apache/superset/blob/master/superset/tasks/scheduler.py).
Before enabling, consider backing up your logs and documenting your retention
policy for audit/compliance needs.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
---
<sup>How did I do?
[Good](https://app.dosu.dev/response-feedback/1c8f5036-e548-426c-9a69-2ae1d7a4a7b7?feedback_type=great_response)
|
[Irrelevant](https://app.dosu.dev/response-feedback/1c8f5036-e548-426c-9a69-2ae1d7a4a7b7?feedback_type=irrelevant_answer)
|
[Incorrect](https://app.dosu.dev/response-feedback/1c8f5036-e548-426c-9a69-2ae1d7a4a7b7?feedback_type=incorrect_sources)
|
[Verbose](https://app.dosu.dev/response-feedback/1c8f5036-e548-426c-9a69-2ae1d7a4a7b7?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/1c8f5036-e548-426c-9a69-2ae1d7a4a7b7?feedback_type=hallucination)
| [Report
🐛](https://app.dosu.dev/response-feedback/1c8f5036-e548-426c-9a69-2ae1d7a4a7b7?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/1c8f5036-e548-426c-9a69-2ae1d7a4a7b7?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
nbsp;[](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/35811)
GitHub link:
https://github.com/apache/superset/discussions/35811#discussioncomment-14757812
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]