To get SMS alerts from Prometheus Alertmanager or Grafana, point a webhook receiver at a small service that turns each firing alert into one short text and sends it through an SMS API. Both tools post JSON to any URL you give them, so the only code you write is the translation.
We make Ready, so the send uses the Ready REST API and only the request shape we document. This guide is for texting your own on-call staff, people who have agreed to receive alerts by text, not customers.
What Alertmanager sends
Alertmanager posts one JSON document per group of alerts. The fields you need are status (firing or resolved) and an alerts list, where each alert has labels (such as alertname and severity) and annotations (such as summary). Grafana's webhook contact point sends a similar alerts array. Check the shape in your own version before you depend on it.
receivers:
- name: sms-oncall
webhook_configs:
- url: https://alerts.internal.example/sms
send_resolved: false
route:
receiver: sms-oncall
routes:
- matchers: ['severity="critical"']
receiver: sms-oncall Only route critical to SMS. A text that wakes someone should mean something. Send warnings to chat or email.
The receiver
import os, uuid, requests
from flask import Flask, request
app = Flask(__name__)
ONCALL = os.environ["ONCALL_NUMBERS"].split(",") # E.164, staff who opted in
@app.post("/sms")
def sms():
data = request.get_json()
for alert in data.get("alerts", []):
if alert["status"] != "firing":
continue
name = alert["labels"].get("alertname", "alert")
summary = alert["annotations"].get("summary", "")[:100]
text = f"[{name}] {summary}"
for number in ONCALL:
key = str(uuid.uuid5(uuid.NAMESPACE_URL, f"{alert['fingerprint']}:{alert['startsAt']}:{number}"))
requests.post(
"https://api.tryready.com/v1/messages",
json={"to": number, "body": text, "consent_attested": True},
headers={"X-API-Key": os.environ["READY_API_KEY"], "Idempotency-Key": key},
timeout=10,
)
return "", 204 The idempotency key comes from the alert's fingerprint, its start time and the number. Alertmanager re-sends a notification when it re-notifies or retries, so the same alert reaching you twice is normal. A repeated key means the request isn't sent twice, so the on-call engineer isn't texted again for the same firing.
Keep the text short
One segment is 160 characters in plain GSM-7 text, and an emoji drops it to 70. An alert name, a short summary and nothing else fits in a segment. Put the runbook link in the chat message, not in the text. The segment counter post has the math.
Don't make SMS your only page
An SMS API refuses to send during quiet hours unless the recipient texted your number in the last 24 hours. A critical alert at 3 a.m. can come back as a 409 QUIET_HOURS_BLOCK or be held. For paging, keep a push or voice page as the primary and use SMS as a second signal. Our critical alert fallback ladder lays out the order. Also, an alert storm can send hundreds of texts, so group in Alertmanager (group_by, group_wait) and cap the receiver.
| Setting | Why |
|---|---|
group_by on alertname and cluster | One text per incident, not per instance |
send_resolved: false | Fewer texts at night |
| Severity routing | Only critical wakes people |
| Receiver cap per hour | Stops a flapping alert from texting for hours |
FAQ
Does Grafana alerting work the same way?
Yes. Add a webhook contact point that points at the same receiver URL, and read the alerts array. Check the field names in your Grafana version.
Can I text a whole team?
Yes, with a loop like the one above, or the bulk endpoint when the text is identical. Keep it to people who have agreed to alert texts.
How do I test without paging anyone?
Use a test key, which simulates every send with no card, number or charge, and post a sample payload to the receiver with curl.
The short version
Route critical alerts only, one idempotency key per firing and recipient, a text that fits a segment and a second channel for the middle of the night. The messages API docs cover the request.
Cost and registration
A segment on the Standard rate is $0.0075 plus a $0.0045 carrier fee, passed through at cost, excluding optional screening. An account can send up to 500 texts a month before it registers for 10DLC, and most approvals take 2 to 7 days. See pricing for the full list.