Create Alerts, Notification Policies via REST-API

  • What Grafana version and what operating system are you using?
    Grafana 9.0.0, Kubernetes on Debian

  • What are you trying to achieve?
    I want to automate the creation of alerting rules, notification policies and contact points

  • How are you trying to achieve it?
    Using the documented ‘Alerting Provisioning API’

  • What happened?
    After I created the objects over the API, I can’t manually edit the created objects in the UI

  • What did you expect to happen?
    I want to create the objects via the API, but also want to use the UI to edit the created objects

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

Error-Message in the ui:
image

Python-Code to create the notification policy:

    obj = {
        "receiver": "test@test.de",
        "object_matchers": [],
        "repeat_interval": "8h",
        "routes": [
            {
                "receiver": fullSN,
                "object_matchers": [["sn", "=", sn]],
            }
        ],
    }

    resp = session.put(grafanaParsedURL + "/api/v1/provisioning/policies", json=obj)

I created a issue at github: Create Alerts, Notification Policies via REST-API · Issue #51455 · grafana/grafana (github.com)