How To Change Default Contact Point and Notification Policy Using File Provision?

Hi there!
I’m on Grafana 9 and I’d like to setup alerting file provisioning as follows:

  • Contact points: remove default email received, add my custom slack contact point
  • Notification policy: change root policy to use slack contact point

I have tried the following to delete the default contact point and add mine
/alerting/contact-points.yml

deleteContactPoints:
  - uid: "" #default contact point UID

contactPoints:
  - name: slack-default
    receivers:
    - uid: slack-contact-point
      type: slack
      settings: #more stuff

The result is an inconsistent configuration, as the root notification policy use the default email received contact point.
How can I change it in order to use my custom contact point?

1 Like

welcome to the :grafana: community @aaronullal

try adding orgID to the config file for deleting contact points and under contactPoints


# config file version
apiVersion: 1

# List of receivers that should be deleted
deleteContactPoints:
  # <int> organization ID, default = 1
  - orgId: 1
    # <string, required> unique identifier for the receiver
    uid: first_uid

Also are there any logs when you provision the file?

Hi @antonio !
Thank you for your quick response.

When I try to delete the default contact point this is the error I see in the logs:

grafana_1     | logger=provisioning.alerting t=2023-03-29T06:41:17.840738248Z level=info msg="starting to provision alerting"
grafana_1     | Error: ✗ contact points: change would result in an invalid configuration state: unexpected receiver (grafana-default-email) is undefined

Grafana is unable to start because I’m trying to delete a contact point that is being referenced by the root notification policy.
How would I change the policy to use another contact point via file provisioning?

PS: I have tried adding the orgId but the result is the same.

thanks for the reply @aaronullal

I have found a similar issue (a bug) related to being unable to update a notification policy via API provisioning

I’d suggest to add a comment in the issue in order to find out whether the bug is affecting you, and if there is any workaround to change the contact point

Seems like that issue is related to API provisioning.
I need to find a way to edit the root notification policy through file provisioning.

another recent api related issue that suggest there might be something going on (might be affecting file provisioning too)

Please open a new issue in our repo so the Alerting team can take a look . Reference this community post.

@antonio done :rocket:
Thank you for your help!

1 Like

Have you tried provisioning the notification policy to update the default contact point of the notification policy as shown here?

Here is an example of a configuration file for creating notification policiies.

# config file version
apiVersion: 1

# List of notification policies
policies:
  # <int> organization ID, default = 1
  - orgId: 1
    # <string> name of the contact point that should be used for this route
    receiver: grafana-default-email
.
.
.

Thank you @melori.arellano , that worked.
I didn’t try what you suggested before because the documentation you mentioned introduces the code snippet with this code:

Here is an example of a configuration file for creating notification policiies.

Here it talks about creating new ones, not modifying existing ones.
Anyways, thanks a lot for your help!!

1 Like