Management Commands
monitor_status
Check whether django_monitor is active and connected to D1:
python manage.py monitor_statusOutputs:
- Whether
django_cfis configured andis_ready() - Whether the
server_eventsandfrontend_eventstables exist in D1 - Count of open (unresolved) server events
- Count of frontend events in the last 24 hours
monitor_cleanup
Deletes old events from D1 to manage storage:
# Delete resolved server events and all frontend events older than 90 days (default)
python manage.py monitor_cleanup
# Custom retention
python manage.py monitor_cleanup --days 30
# Preview without deleting
python manage.py monitor_cleanup --dry-run
# Verbose output with cutoff timestamps
python manage.py monitor_cleanup --dry-run --verboseWhat gets deleted
| Table | Condition |
|---|---|
server_events | is_resolved=1 AND last_seen < cutoff |
frontend_events | created_at < cutoff |
Open (unresolved) server events are never deleted, regardless of --days or age.
Scheduling
Run daily via cron or a Django-RQ scheduled task:
# djangoconfig.py — in RQScheduleConfig
RQScheduleConfig(
func="django.core.management.call_command",
args=["monitor_cleanup"],
cron="0 3 * * *", # 03:00 UTC every day
description="Prune old monitor events",
)See Also
- Configuration — Retention defaults
- Overview — Architecture
TAGS: django_monitor, management-commands, monitor_cleanup, monitor_status DEPENDS_ON: [django-monitor/overview]
Last updated on