I am using django-sentry to track errors in a website. My problem is that the database has grown too big. The 'message' table and the 'groupedmessage' are related
Is there any way to clear older entries and specific messages or to add the sentry tables to the admin of django?
Use the cleanup command. Two parameters are available:
Use it as such (--config
now dropped):
# sentry --config=sentry.conf.py cleanup --days 360
sentry cleanup --days 360
OR with an optional project parameter, it must be an integer:
# sentry --config=sentry.conf.py cleanup --days 360 --project 1
sentry cleanup --days 360 --project 1
I also was able to use the django ORM to do this manually, before discovering the cleanup command:
#$source bin/activate
#$sentry --config=sentry.conf.py shell
from sentry.models import Event, Alert
Event.objects.all().count()
Alert.objects.all().count()
Check out the sentry models to query other objects. From here you can use the django ORM commands like .save(), .remove() etc.. on the objects. Check out the available sentry models here. This approach is a bit more flexible if you need the granularity, i.e. modifying objects. One thing that the cleanup command lacks is telling you how many objects it deleted, it dumps the deleted objects to the screen instead.
My cleanup script looks like this and I run it @monthly using cron:
#!/bin/bash
date
cd /var/web/sentry
source bin/activate
# exec sentry --config=sentry.conf.py cleanup --days 360 #--project 1
# UPDATE: You can now drop the --config param
exec sentry cleanup --days 360