Error "Failed to save rule: (...) UNIQUE constraint failed" when saving alert rule

Dear all,

I unexpectedly started to observe error when saving alert rule. Please help to resolve.

  • What Grafana version and what operating system are you using?

    • 11.2.9
  • What are you trying to achieve?

    • Save existing Alert rule after modifications
  • How are you trying to achieve it?

    • Click Save rule
  • What happened?

    • Change of configuraiton is not saved and error popup appears “Failed to save rule: failed to update rule group: failed to update rules: failed to create new rule versions: UNIQUE constraint failed: alert_rule_version.rule_guid, alert_rule_version.version”
  • What did you expect to happen?

    • Successfull save after modifications
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

    • Popup message as above and error in the log
    • logger=context userId=1 orgId=1 uname=admin t=2025-10-28T09:32:22.346657565Z level=error msg="failed to update rule group: failed to update rules: failed to create new rule versions: UNIQUE constraint failed: alert_rule_version.rule_guid, alert_rule_version.version"error=“failed to update rule group: failed to update rules: failed to create new rule versions: UNIQUE constraint failed: alert_rule_version.rule_guid, alert_rule_version.version” remote_addr=2001:808:0:1000:5534:7188:e4aa:9174 traceID=

This error started without any specific changes in the system. It’s not after upgarde or downgrade. Saving alert rules was working properly all the time.

Any help appreciated.

Regards,

Szymon

Hi @szymont ! Sorry you encountered this problem. Here you can find instructions for how to fix the problem.