grafana_api_sdk icon indicating copy to clipboard operation
grafana_api_sdk copied to clipboard

New notification policy?

Open Saurus119 opened this issue 3 months ago • 0 comments
trafficstars

Hello, I am tryin to use this sdk for creating alerts (managing) + set up policies for the alerts.

It is not possible to add new notification policy with AlertingProvisioning(<api>).add_notification_policies(<route>)

I am able to create a policy but when I add "routes" for the policy it fails on "Bad request", no detail at all. For example this is what I send. As lib requires parameters as group_by I pass them. But UI when I add notifications can miss this information and they only need "receiver" and that is how you point to the "default policy".

{
   "continue":false,
   "group_by":[
      "action_email_notification"
   ],
   "group_interval":"None",
   "group_wait":"None",
   "mute_time_intervals":"None",
   "object_matchers":"None",
   "provenance":"api",
   "receiver":"",
   "repeat_interval":"None",
   "routes":[
      {
         "continue":false,
         "group_by":[
            "action_email_notification"
         ],
         "group_interval":"None",
         "group_wait":"None",
         "mute_time_intervals":"None",
         "object_matchers":[
            {
               "name":"action_email_notification",
               "type":0,
               "value":"test_value"
            }
         ],
         "provenance":"api",
         "receiver":"grafana-default-email",
         "repeat_interval":"None",
         "routes":"None"
      }
   ]
}

When I am creating policies manually and try to export:

{
    "apiVersion": 1,
    "policies": [
        {
            "orgId": 1,
            "receiver": "grafana-default-email",
            "group_by": [
                "action_email_notification"
            ],
            "routes": [
                {
                    "object_matchers": [
                        [
                            "x",
                            "=",
                            "x"
                        ]
                    ]
                },
                {
                    "object_matchers": [
                        [
                            "xdd",
                            "=",
                            "dd"
                        ]
                    ]
                }
            ]
        }
    ]
}

So I am not able to match syntax with grafana API sdk? Were you able to add notification policies under default with reference to any contact point and the Matcher as you use? I checked the the grafana official HTTP documentation and they don´t have the same "required" fields as is in the SDK.

Saurus119 avatar Jul 30 '25 10:07 Saurus119