Prompt
How do I set up API uptime checks with alerts?
Latest observation
Oct 20, 2026
OpenAI APIWeb search: off
Here’s a practical way to set up API uptime checks with alerts.
1) Decide what to monitor
For an API, don’t just check “is the host up?” Check an actual endpoint.
Good checks:
GET /healthGET /status- a lightweight authenticated endpoint if the API is private
- optionally, a deeper synthetic check like
GET /v1/versionor a simple read-only endpoint
What to validate:
- HTTP status code is
200 - response time is below a threshold
- expected JSON fields are present
- optional: auth works, DNS resolves, TLS is valid
2) Pick a monitoring method
You have a few common options:
A. External monitoring service
Examples:
- UptimeRobot
- Pingdom
- Better Stack
- StatusCake
- Datadog Synthetics
- New Relic Synthetics
- Grafana Cloud Synthetic Monitoring
Pros:
- easy setup
- built-in alerting
- checks from multiple regions
- dashboards and incident history
B. Cloud provider monitoring
Examples:
- AWS CloudWatch Synthetics
- Azure Monitor
- Google Cloud Monitoring uptime checks
Pros:
- good if your API is already in that cloud
- integrates with cloud alerts
C. DIY monitoring
Examples:
- cron job +
curl - Prometheus + Blackbox Exporter
- custom script with Slack/Email alerts
Pros:
- flexible
- cheap
- more control
3) Configure the check
Set:
- URL: e.g.
https://api.example.com/health - Method: usually
GET - Interval: every 1–5 minutes
- Timeout: 5–30 seconds
- Retry policy: 2–3 failures before alerting
- Regions: at least 2 if possible
- Expected response:
- status code
200 - maybe body contains
"ok": true
- status code
If you need auth:
- use an API key, bearer token, or basic auth in the monitor
- avoid using credentials with high privileges
- prefer a dedicated monitoring token
4) Set alerts
Common alert channels:
- Slack
- Microsoft Teams
- PagerDuty
- Opsgenie
- SMS
- Webhook to your incident system
Good alerting rules:
- alert after 2–3 consecutive failures
- alert on high latency, not only outages
- alert on certificate expiry, DNS failures, and 5xx spikes if supported
- route critical alerts to on-call; noncritical to email/Slack
5) Add checks for more than uptime
A service can be “up” but broken. Consider:
- response time > threshold
- increased 5xx errors
- failed auth
- wrong content in response
- dependency failures if your health endpoint reflects them
A common pattern:
- liveness check: “process is running”
- readiness/dependency check: “API can actually serve traffic”
6) Example: simple DIY uptime check with Slack alert
Here’s a basic Python example:
import requests
import os
from datetime import datetime
URL = "https://api.example.com/health"
SLACK_WEBHOOK = os.environ["SLACK_WEBHOOK"]
try:
r = requests.get(URL, timeout=10)
ok = r.status_code == 200 and r.json().get("ok") is True
except Exception as e:
ok = False
error = str(e)
if not ok:
payload = {
"text": f"API uptime check failed at {datetime.utcnow().isoformat()}Z for {URL}"
}
requests.post(SLACK_WEBHOOK, json=payload, timeout=10)
print("Alert sent")
else:
print("OK")
Run it every minute with cron:
* * * * * /usr/bin/python3 /path/check_api.py
7) Example: Prometheus Blackbox Exporter
If you already use Prometheus, Blackbox Exporter is a standard choice.
You configure Prometheus to probe your API endpoint and alert if it fails.
Typical alert rule:
- alert: ApiDown
expr: probe_success{job="blackbox-api"} == 0
for: 3m
labels:
severity: critical
annotations:
summary: "API is down"
description: "API uptime probe failed for 3 minutes."
8) Best practices
- Monitor from more than one region
- Use a dedicated
/healthendpoint that is fast and stable - Make alerts actionable and avoid alert fatigue
- Add maintenance windows
- Use escalation for repeated failures
- Track uptime history and error rates
- Test alerts regularly so you know they work
9) Recommended minimal setup
If you want something simple and reliable:
- Create a
/healthendpoint. - Use a managed monitoring service.
- Check every 1 minute from 2 regions.
- Alert after 2 failures.
- Send alerts to Slack + email, and PagerDuty for critical incidents.
If you want, I can also give you:
- a step-by-step setup for a specific tool (UptimeRobot, Datadog, CloudWatch, Grafana, etc.)
- a Docker/Kubernetes health check setup
- a Python or Node.js script for custom API uptime monitoring