DEV Community

Vigilmon
Vigilmon

Posted on

PostgreSQL Monitoring with Vigilmon: External Health Checks for Your Database

PostgreSQL Monitoring with Vigilmon: External Health Checks for Your Database

PostgreSQL does not expose an HTTP endpoint — so how do you monitor it with an external uptime tool? The answer is a health endpoint on your application layer that verifies database connectivity and surfaces it as an HTTP response Vigilmon can check.

Why You Need External DB Health Monitoring

Internal database metrics are important — but external monitoring answers a different question: can your application actually reach and query the database right now?

This catches: database crashes, authentication failures, connection pool exhaustion, network partitions, and bad migrations.

Building a Database Health Endpoint

Node.js + pg

const { Pool } = require('pg');
const pool = new Pool({ connectionString: process.env.DATABASE_URL });

app.get('/health', async (req, res) => {
  try {
    await pool.query('SELECT 1');
    res.json({ status: 'ok', database: 'connected' });
  } catch (error) {
    res.status(503).json({ status: 'error', database: 'disconnected', error: error.message });
  }
});
Enter fullscreen mode Exit fullscreen mode

Python + SQLAlchemy

from sqlalchemy import text
from sqlalchemy.exc import OperationalError

@app.get("/health")
async def health(db: Session = Depends(get_db)):
    try:
        db.execute(text("SELECT 1"))
        return {"status": "ok", "database": "connected"}
    except OperationalError:
        raise HTTPException(status_code=503, detail="Database unavailable")
Enter fullscreen mode Exit fullscreen mode

Laravel (PHP)

Route::get('/health', function () {
    try {
        DB::select('SELECT 1');
        return response()->json(['status' => 'ok', 'database' => 'connected']);
    } catch (Exception $e) {
        return response()->json(['status' => 'error'], 503);
    }
});
Enter fullscreen mode Exit fullscreen mode

Rails (Ruby)

get '/health', to: proc {
  begin
    ActiveRecord::Base.connection.execute('SELECT 1')
    [200, {'Content-Type' => 'application/json'}, [{ status: 'ok' }.to_json]]
  rescue => e
    [503, {'Content-Type' => 'application/json'}, [{ status: 'error' }.to_json]]
  end
}
Enter fullscreen mode Exit fullscreen mode

Configuring Vigilmon

  1. Log in to vigilmon.online
  2. Click Add Monitor
  3. Enter your health endpoint URL: https://yourapp.com/health
  4. Enable keyword assertion: ok
  5. Set response time threshold: 2000ms
  6. Choose alert channels

Common PostgreSQL Failures Vigilmon Detects

Failure How Vigilmon Catches It
Server crash Health endpoint returns 503
Connection pool exhausted Response spikes, then 503
Wrong password after rotation Health endpoint returns 503
Network partition Health endpoint times out

Multi-Region Coverage

Vigilmon checks from multiple geographic regions. An alert fires only when a majority agree the endpoint is failing — preventing false positives from transient network issues.

Free Tier

5 monitors, 5-minute intervals, email alerts, no credit card required.

Start monitoring your PostgreSQL-backed app at vigilmon.online.

Top comments (0)