Your Flask API is running. Your health check passes locally. But at 3 AM, does it stay up in São Paulo? Tokyo? Frankfurt?
Single-probe monitoring tools will page you for blips that only one region sees. Multi-region monitoring eliminates those false alerts by requiring consensus across probes before triggering an alert. This tutorial shows you how to add production-grade uptime monitoring to a Python Flask app in under 10 minutes — for free.
What we're building
A Flask REST API with a /health endpoint, monitored by Vigilmon from multiple regions simultaneously.
Step 1: Add a health endpoint to your Flask app
A good health endpoint returns a machine-readable status and HTTP 200 when everything is fine:
from flask import Flask, jsonify
import time
app = Flask(__name__)
START_TIME = time.time()
@app.route('/health')
def health():
return jsonify({
"status": "ok",
"uptime_seconds": int(time.time() - START_TIME),
"service": "my-flask-api"
}), 200
@app.route('/api/items')
def items():
return jsonify({"items": ["a", "b", "c"]})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
Key details:
- Returns HTTP 200 when healthy — monitoring tools check status codes
- Keeps the response lightweight — no database queries in the health path
- Includes
uptime_secondsso you can see if the process silently restarted
For apps with a database dependency, add a quick ping:
@app.route('/health')
def health():
try:
db.session.execute(db.text('SELECT 1'))
db_status = "ok"
except Exception:
db_status = "error"
status = "ok" if db_status == "ok" else "degraded"
code = 200 if status == "ok" else 503
return jsonify({"status": status, "db": db_status}), code
Returning 503 on degraded state lets Vigilmon detect partial outages automatically.
Step 2: Deploy your Flask app
Your app needs a public URL for monitoring to work. Common options:
- Railway / Render / Fly.io — push to deploy, free tier available
- VPS with gunicorn + nginx
- Docker — containerize and deploy anywhere
Example Dockerfile:
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0:5000", "app:app"]
Once deployed, note your URL — e.g. https://my-flask-api.fly.dev.
Step 3: Set up Vigilmon monitoring
- Sign up free at vigilmon.online — no credit card required
- Click Add Monitor
- Set the URL to
https://your-app.example.com/health - Set check interval: 1 minute
- Set expected status code: 200
Vigilmon checks your endpoint from multiple regions. If only one probe fails (a transient network hiccup in one region), no alert fires. Only when multiple regions agree your app is down does an alert trigger — zero false positives.
Step 4: Add Slack alerts
- In Vigilmon, go to Notifications → Add Channel → Slack
- Paste your Slack webhook URL
- Choose which monitors to notify
Your team channel will receive:
🔴
my-flask-api.fly.dev/health— DOWN (2/3 regions)
And recovery notifications:
✅
my-flask-api.fly.dev/health— RECOVERED (response: 95ms)
Step 5: Test the full flow
Simulate a failure by returning 500 from your health endpoint temporarily, deploy it, wait ~2 minutes, and watch Vigilmon fire the alert. Then restore 200 and watch the recovery notification.
What you get on the free tier
- Unlimited monitors
- 1-minute check intervals
- Multi-region consensus checks
- Slack + email notifications
- 90-day uptime history
No credit card. No trial period. Sign up at vigilmon.online and add your Flask health endpoint today.
Wrapping up
Adding uptime monitoring to a Flask app takes ~10 minutes:
- Add a
/healthendpoint returning 200 when healthy - Deploy to a public URL
- Add it to Vigilmon — free, multi-region, no false alerts
Your on-call rotation will thank you.
Top comments (0)