DEV Community

Vigilmon
Vigilmon

Posted on

Monitoring Neon Serverless Postgres with Vigilmon (Free External Health Checks)

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:

  1. Cold start latency: if your compute is idle, the first connection can take several seconds
  2. Connection pool exhaustion: serverless apps can hit Neon's connection limits under load
  3. 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 });
  }
});
Enter fullscreen mode Exit fullscreen mode

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 }
    );
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Set Up the Vigilmon Monitor

  1. Log into vigilmon.online
  2. Click New Monitor > HTTP/HTTPS
  3. Set URL to your health endpoint
  4. Set Check interval: 1 minute for production
  5. Set Regions: 2-3 for multi-region consensus
  6. Set Expected status: 200
  7. 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:

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

Start monitoring your Neon-backed app with Vigilmon - free

Top comments (0)