# Grafana alerting provisioning: a Webhook contact point for the Inbox of the portal.
# Put this file in /etc/grafana/provisioning/alerting/.
# Set INBOX_URL and INBOX_TOKEN in the environment of Grafana.
# Grafana expands $__env{...} in the provisioning files.
# INBOX_URL is the address of the portal (the same host and port as the pages).
# INBOX_TOKEN is an API key (api_...). Use the value of a block `api_key` of the file,
# or a key that an account made in the tab Access.
# The key and its owner need the permission alert.send on the group.
#
# Grafana builds its contact point types in, and a plugin cannot add one.
# So the Inbox accepts the Alertmanager payload of the Webhook contact point.
# The last path element is the group to alert. The token must be allowed to send to it.
apiVersion: 1
contactPoints:
  - orgId: 1
    name: inbox-oncall
    receivers:
      - uid: inbox-oncall
        type: webhook
        settings:
          url: $__env{INBOX_URL}/api/v1/webhooks/alertmanager/infra
          httpMethod: POST
          authorization_scheme: Bearer
          authorization_credentials: $__env{INBOX_TOKEN}
          maxAlerts: 50
        disableResolveMessage: true

policies:
  - orgId: 1
    receiver: inbox-oncall
    group_by: ["alertname"]
    group_wait: 10s
    group_interval: 1m
    repeat_interval: 4h
