Monitoring Neon Serverless Postgres with Vigilmon (Free External Health Checks)
Neon is a serverless Postgres platform with autoscaling and branch-based databases. Because Neon scales to zero, your database can be in a cold state when your application first queries it — and if the cold start or connection fails, your users see errors.
This guide shows you how to monitor your Neon-backed application's database health with Vigilmon.
Why Monitor a Neon-Backed App
Neon serverless Postgres introduces specific failure modes:
- Cold start latency: if your compute is idle, the first connection can take several seconds
- Connection pool exhaustion: serverless apps can hit Neon's connection limits under load
- Branch database issues: if you use Neon branching, a branch may have issues your main does not
Step 1: Add a Health Endpoint That Checks Neon
Node.js with Neon serverless driver:
import { neon } from '@neondatabase/serverless';
const sql = neon(process.env.DATABASE_URL);
app.get('/health', async (req, res) => {
try {
await sql`SELECT 1`;
res.json({ status: 'ok', database: 'ok' });
} catch (error) {
res.status(503).json({ status: 'error', database: error.message });
}
});
Next.js API Route:
// app/api/health/route.js
import { neon } from '@neondatabase/serverless';
export async function GET() {
try {
const sql = neon(process.env.DATABASE_URL);
await sql`SELECT 1`;
return Response.json({ status: 'ok', database: 'ok' });
} catch (error) {
return Response.json(
{ status: 'error', database: 'unavailable' },
{ status: 503 }
);
}
}
Step 2: Set Up the Vigilmon Monitor
- Log into vigilmon.online
- Click New Monitor > HTTP/HTTPS
- Set URL to your health endpoint
- Set Check interval: 1 minute for production
- Set Regions: 2-3 for multi-region consensus
- Set Expected status: 200
- Set Response timeout: 30 seconds — critical for Neon cold starts
The 30-second timeout is essential. If Neon's compute is suspended and needs to wake up, the first query can take 5-15 seconds.
Step 3: Configure for Cold Starts
Alert after 2 consecutive failures rather than 1. A cold-start check taking 15 seconds but returning 200 is normal. Two consecutive 503 responses is a real problem.
Keep Neon Compute Warm
A side effect of 1-minute Vigilmon checks: your Neon compute stays warm because there is always a recent query, eliminating cold starts for your users entirely.
Monitoring Multiple Neon Branches
Each Neon branch has its own connection string. Monitor branch health with environment-specific health endpoints:
- https://preview.yourdomain.com/health (Neon preview branch)
- https://staging.yourdomain.com/health (Neon staging branch)
Summary
The key settings for Neon monitoring:
- Set response timeout to 30 seconds to accommodate cold starts
- Alert after 2 consecutive failures to avoid false positives
- Use your application's /health endpoint that queries Neon directly
Top comments (0)