Get a public URL for Grafana webhooks#
Grafana can't deliver to localhost. An OtterKit webhook endpoint gives you a public HTTPS URL that answers Grafana around the clock and keeps every request, so nothing is lost while your laptop is closed or your handler is half written:
npx otterkit login
npx otterkit webhook --daemon --subdomain grafana-dev
# https://grafana-dev.otterkit.appThe name is reserved to your account, so the URL stays the same every time you start it. An endpoint costs $0.01 per hour while it is live and never more than $3 in any 30 days, and new accounts get 10 free credits. To look at a payload before you sign up, the try page gives you a live URL in the browser with no account.
Register the URL in Grafana#
- In Grafana, open Alerting, then Contact points, and add a contact point.
- Choose the Webhook integration and paste the endpoint URL.
- Under the optional settings you can add HTTP Basic credentials or an
Authorizationheader. Save, then use the contact point in a notification policy or on an alert rule.
Use https://grafana-dev.otterkit.app as the URL. Add a path if your handler expects one, such as https://grafana-dev.otterkit.app/alerts: the endpoint accepts any path and records it.
Authenticate requests from Grafana#
By default a Grafana webhook is not signed. The usual protection is a secret in the Authorization header, set in the contact point's optional settings, which your receiver compares with the value it expects.
Recent Grafana versions can also sign the body with an HMAC. If your contact point has an HMAC signature section, set a secret there and note the header name it shows.
There is no Grafana preset. If you turned on Grafana's HMAC signature, open the endpoint in the console and use the generic HMAC mode with the header name and algorithm from the contact point. Otherwise, the captured request shows the Authorization header exactly as Grafana sent it.
Send a test event#
On the contact point, click Test and send the predefined alert. It arrives within a second or two, with the same shape as a real notification.
Then watch it land, or wait for it in a script:
# Follow requests as they arrive, with headers and bodies
npx otterkit inspect grafana-dev --follow
# Or block until the next POST, then print it as JSON
npx otterkit await grafana-dev --method POST --count 1 --timeout 120s --jsonReplay Grafana events into your local handler#
Once an event is captured you can send it to your handler as often as you like, with the original headers and body, without asking Grafana to fire it again:
# Send the latest captured event to a server on port 3000
npx otterkit replay grafana-dev --target 127.0.0.1:3000
# Or a specific one (1 is the oldest, -1 the latest)
npx otterkit replay grafana-dev --index 3 --target 127.0.0.1:3000Replays cost nothing and are added to the capture log with your handler's response next to them. If you would rather have events delivered live while you work, expose the handler with a tunnel instead and register the tunnel URL.
Retries, timeouts and duplicates#
- One notification can carry several alerts. The body has a top-level
statusoffiringorresolvedand analertsarray, each with its own status, labels, annotations and start time. Handle every item in the array. - Grafana sends again while an alert keeps firing, at the repeat interval of the notification policy, so a receiver should expect the same alert more than once.
To see how your code copes when a delivery fails, the HTTP status codes guide has URLs that return any status on demand.
Questions about Grafana webhooks#
Can I change the Grafana webhook payload?#
The title and message fields accept notification templates, and recent versions let you template the whole payload. Send a test after each change and read what arrives.
Does Grafana send a webhook when an alert resolves?#
Yes, unless you tick the option to disable resolved messages on the contact point. The alert's status is resolved.
Can Grafana Cloud reach a receiver on localhost?#
No. It needs a public URL. Capture the notification there and replay it locally.