How to Monitor PlanetScale Database Applications with Vigilmon
PlanetScale is a serverless MySQL database built on Vitess, loved for its branching model and zero-downtime schema migrations. But like any external service, PlanetScale can have outages - and your app needs to detect and report them.
This guide shows how to add PlanetScale health checks to your application and monitor them with Vigilmon.
What Can Go Wrong with PlanetScale
- PlanetScale regional outages
- Connection limits on free/hobby plans exceeded
- Query timeouts on complex joins (Vitess limitations)
- Branch promotion issues during deployments
- SSL handshake failures
Step 1: Node.js Health Check
const mysql = require('mysql2/promise');
const pool = mysql.createPool({
host: process.env.DATABASE_HOST,
user: process.env.DATABASE_USERNAME,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_NAME,
ssl: { rejectUnauthorized: true }, // PlanetScale requires SSL
});
app.get('/health', async (req, res) => {
try {
const [rows] = await pool.execute('SELECT 1 as ok');
res.json({ status: 'healthy', database: 'connected', provider: 'planetscale' });
} catch (err) {
res.status(503).json({ status: 'unhealthy', database: 'error', error: err.message });
}
});
Step 2: Next.js API Route
// pages/api/health.ts
export default async function handler(req, res) {
try {
await db.$queryRaw`SELECT 1`; // Prisma
res.status(200).json({ status: 'healthy', database: 'ok' });
} catch (error) {
res.status(503).json({ status: 'unhealthy', database: 'error' });
}
}
Step 3: Django
from django.http import JsonResponse
from django.db import connection
def health(request):
try:
with connection.cursor() as cursor:
cursor.execute('SELECT 1')
return JsonResponse({'status': 'healthy', 'database': 'ok'})
except Exception as e:
return JsonResponse({'status': 'unhealthy', 'database': str(e)}, status=503)
Step 4: Connect Vigilmon
- Sign up at vigilmon.online
- Add Monitor -> HTTP Monitor
- URL:
https://yourapp.com/health - Interval: 1 minute, Expected status: 200
- Configure email/Slack alerts
Add SSL Certificate Monitor for your domain too.
PlanetScale Branching
Monitor each branch environment independently:
- Production:
https://yourapp.com/health - Staging:
https://staging.yourapp.com/health
This catches schema promotion errors that break production.
Failure Coverage
| Failure | App Logs | Vigilmon |
|---|---|---|
| PlanetScale regional outage | DB errors | Yes - health 503 |
| Connection limit exceeded | Errors | Yes - health 503 |
| App process crash | Silent | Yes - HTTP monitor |
| SSL handshake failure | Errors | Yes - SSL monitor |
Free Tier
Vigilmon free tier: 5 monitors, 1-minute intervals, email alerts. No credit card required.
Start monitoring free at vigilmon.online
Top comments (0)