Infrastructure 2023-12-27

Provisioning Contact Points and Policies in Grafana

Provision Grafana contact points and alerting policies via YAML configuration files for automated Slack notifications.

Read in: ja
Provisioning Contact Points and Policies in Grafana

Overview

It has become possible to provision Contact Points in Grafana, so I tried setting up provisioning.

Environment

Configuration Method

This is a rough note, so I will omit the explanation around building with Docker Compose. Refer to bmf-san/gobel-example.

Add contact-points.yml and policies.yml under provisioning/alerting. The file names can be arbitrary.

└── provisioning
    └──alerting
            ├── alert-rules.yml
            ├── contact-points.yml
            └── policies.yml

Contact Points

Below is an example configuration for notifying Slack via webhook.

apiVersion: 1

contactPoints:
  - orgId: 1
    name: Slack
    receivers:
      - uid: abc1234
        type: slack
        settings:
          recepient: alert-slack-channel-name
          url: [webhook url]
        disableResolveMessage: false

You can assign any uid when provisioning.

recepient is the Slack notification channel name.

url is set to the webhook url. It can also be configured to use a token.

cf. grafana.com - #provision-contact-points

Policies

Provisioning Policies is also necessary to reflect the settings of provisioned Contact Points and send Alert notifications, otherwise, the default ones will be used. (I didn't investigate if there are other ways.)

Below is an example configuration when creating a Contact Point named Slack.

apiVersion: 1

policies:
  - orgId: 1
    receiver: Slack

receiver specifies the Contact Points name.

The configuration is minimal.

cf. grafana.com - #provision-notification-policies

By provisioning in this way, you can configure alerts to be sent to any Contact Points.

Impressions

It has become easier since I used to configure it manually.

Tags: Grafana Docker
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles