Grafana 8.0.0 - Alerting migration issue

Hi
I’ve activated ngalert

[feature_toggles]
      enable = ngalert

and when bouncing Grafana it doesn’t come up with the error message in log:

t=2021-06-16T17:42:25+0100 lvl=info msg="Executing migration" logger=migrator id="move dashboard alerts to unified alerting"
t=2021-06-16T17:42:25+0100 lvl=eror msg="Executing migration failed" logger=migrator id="move dashboard alerts to unified alerting" error="failed to migrate alert 14: dashboard with UID  under organisation 27 not found: %!w(<nil>)"
t=2021-06-16T17:42:25+0100 lvl=eror msg="Exec failed" logger=migrator error="failed to migrate alert 14: dashboard with UID  under organisation 27 not found: %!w(<nil>)" sql="code migration"

So it complaints about OrgID 27 and alert 14.
Both items do not exist and were removed from Grafana some time before I tried to switch to ngalert

> curl -X GET https://admin:***@grafana:8086/api/orgs/27
{"message":"Organization not found"}

and

> curl -X DELETE https://admin:***@grafana:8086/api/alert-notifications/14
{"message":"alert notification not found"}
> curl -X GET https://admin:***@grafana:8086/api/alerts/14
{"message":"You are not allowed to edit/view alert"}

My understanding that there are some traces left from deleted organizations and alerts and migration process fails
Any suggestions how to fix it?
Thanks

ok, I have to manually remove this rule from grafana.db

delete from alert where id=14

as this rule was still present in config DB
and it reolved the issue

though I think that migration should go smoother

1 Like

I had this same issue with v8.0.2 as well. could see the old alert info in the JSON view of the dashboard even though the alert rule was deleted.

Observed same issue of migration failure to unified alerting caused by non-existent orgs/alerts while attempting to migrate using v8.3.3.

Migration issue resolved in v8.5.4. However, if running an earlier Grafana version, automation can also be used with mysql to list organizations, locate alerts tied to orgs not in that list, and remove those alerts from DB, prior to migrating to new alert system.