Alert rule version table in database too large

Hello,

Our alert_rule_version table in Grafana database (we’re using MySQL) is already about 10GB large. When we update Grafana’s version, the migration takes around 15-20 minutes and then throws an error (rn the error might have been of a different origin, but the time of the migration isn’t something we’d like to continue as well).

My question is: Is there a way to clean up the table a bit and is it safe? It would be best if there was a setting in Grafana ini like the one for annotations. If there’s nothing like that, could we do that by hand? If not, is there any way to do something about the time of migrations?

Thanks in advance.

We’ve managed to find rule_version_record_limit field. Setting it will set the number of versions to the limit but only when new version is applied. One of our alerts has now 98k versions in the table, so we’d like to clear the data a bit. Is it safe to just truncate the table? We did it on dev and nothing seems broken, but maybe someone has already done that?

Update: we did truncate the table and for now nobody cried about it, so it might have been the way to go :smile:

1 Like