Grafana
Grafana Alerting can send each alert to Pocketbell through a Webhook contact point. There are two ways to set it up:
- Quick: a webhook Source. Pocketbell knows Grafana’s alerts: each arrives as “High CPU is firing” with the alert’s summary and a button to Grafana, Critical, and “High CPU resolved” stops it, with how long it was firing. Nothing to write, in Grafana or in the app.
- Full control: an API Source with a custom payload template, in Grafana versions that have it (not yet generally available in Grafana Cloud). Firing alerts are Critical, and the resolved notification replaces the alert.
Quick: a webhook Source
Section titled “Quick: a webhook Source”- In the Pocketbell app, create a Source named Grafana, choose Webhook, and copy its URL.
- In Grafana, open Alerting → Contact points → + Add contact point, name it Pocketbell, set Integration to Webhook, and paste the URL.
- Click Test. It arrives on your devices as a firing alert, so it’s Critical and repeats: acknowledge it. The Source’s setup shows the event and its Preview. There’s nothing to set.
- Save the contact point, and choose it in your notification policies or alert rules.
A firing alert repeats until you acknowledge it, for up to an hour, and the
resolved notification for the same alert group stops it, starting “Firing
for 12 min”; both stay in the inbox, in order. The title is
the alert’s name, the message its summary annotation (else its
description). Grafana’s own DatasourceNoData and DatasourceError alerts are
Important, not Critical. Leave the Source’s default priority on Normal for
this; any other default makes every event that priority. To change any of it, set your own title, message or priority in
the Source’s setup: what you set wins, part by part. For no Critical notifications,
set Priority by status with another priority for firing. More in Webhooks.
Full control: an API Source
Section titled “Full control: an API Source”-
In the Pocketbell app, create a Source named Grafana, choose API, and copy its key.
-
In Grafana, open **Alerting → Contact points → Notification Templates →
- Add notification template group**, name it
pocketbell, and paste:
{{ define "pocketbell.payload" -}}{{ coll.Dict"title" (tmpl.Exec "default.title" .)"message" (tmpl.Exec "default.message" .)"priority" (tmpl.Inline `{{ if eq .Status "firing" }}critical{{ else }}normal{{ end }}` .)"replace" (printf "grafana-%s" (.GroupLabels.alertname | reReplaceAll "[^A-Za-z0-9._:-]" "-") | reReplaceAll "^(.{64}).*$" "$1")"tags" (coll.Slice "grafana")| data.ToJSON }}{{- end }} - Add notification template group**, name it
-
Add a contact point named Pocketbell with Integration set to Webhook, and fill in:
- URL:
https://api.pocketbell.dev/v1/messages - Authentication Header Scheme:
Bearer - Authentication Header Credentials: your
pb_live_…key - Max Alerts: a small number, such as
5, so a large group’s message stays under Pocketbell’s 4,096 characters
- URL:
-
In the webhook’s optional settings, edit the Custom Payload template and choose
pocketbell.payload. -
Click Test, save, and choose the contact point in your notification policies.
How it behaves
Section titled “How it behaves”- Firing is Critical: it repeats every five minutes, for up to an hour, until you acknowledge it on any device.
- Resolved carries the same
replacekey,grafana-and the alert’s name, so it takes the alert’s place and the repeats stop. - The key is made from
alertname, so keepalertnamein the policy’s Group by, which Grafana does by default. Characters a key can’t hold become-, and it’s cut to 64. - The title and message are Grafana’s own. To change them, replace
tmpl.Exec "default.message" .with your own template’s name.
If a test doesn’t arrive
Section titled “If a test doesn’t arrive”- 401
invalid_api_key: the key is wrong, or the scheme isn’tBearer. - 400
invalid_request: a field is wrong, empty or too long, such as a message over 4,096 characters. Grafana shows Pocketbell’s answer when a test fails;detailsin it names the field.