Skip to content

Grafana Alerting

Grafana Alerting’s webhook contact point supports a fully customizable payload using Grafana’s Go-template notification engine.

See API Overview for authentication and finding your Account ID/Team ID.

  1. In Grafana, go to Alerting → Contact points → + Add contact point.
  2. Choose integration type Webhook.
  3. Set the URL to https://api.opsfusion.cloud/v1/account/YOUR_ACCOUNT_ID/push/alert.
  4. Add an HTTP header: Authorization: YOUR_API_KEY.
  5. Enable Custom Payload and enter the template below (this replaces the default Title/Message fields entirely).
{{ $severityMap := coll.Dict "critical" 1 "warning" 2 "info" 3 }}
{{ $sev := .CommonLabels.severity }}
{
"teamId": YOUR_TEAM_ID,
"title": "{{ .CommonLabels.alertname }}",
"description": "{{ .CommonAnnotations.summary }}",
"severity": {{ if $sev }}{{ index $severityMap $sev }}{{ else }}3{{ end }},
"status": {{ if eq .Status "firing" }}1{{ else }}3{{ end }},
"labels": {{ data.ToJSON .CommonLabels }}
}

Unlike most of the other tools in this section, Grafana’s templating language has real conditional logic and a coll.Dict/index lookup pattern, so both status and severity can be computed inline from the alert’s own data rather than hardcoded or needing separate contact points per state. status comes from .Status (firing/resolved) directly; severity looks up a severity label (set on your alert rule, e.g. severity: critical) against the map, falling back to 3 if the label isn’t set.

OpsFusion fieldGrafana source
teamIdHardcoded per contact point
title.CommonLabels.alertname
description.CommonAnnotations.summary (or .CommonAnnotations.description)
severity.CommonLabels.severity, looked up against $severityMap (falls back to 3 if unset)
status.Status (firing1, resolved3), computed inline with {{ if }}
labelsdata.ToJSON .CommonLabels
  • Template fails to save or compile: Grafana’s Custom Payload templating has had rough edges in some versions — simplify the template to isolate which function/expression is failing, and check your Grafana version’s release notes for known templating issues.
  • labels isn’t valid JSON: data.ToJSON should handle escaping automatically — if you’re building the labels object by hand instead, make sure any string values are wrapped in {{ ... | printf "%q" }} style escaping.
  • Custom Payload option missing: confirm you’re on self-managed or Enterprise Grafana; it’s not yet available on Grafana Cloud.

For integration support: