DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Supabase with Vigilmon

How to Monitor Supabase with Vigilmon

Supabase is the open-source Firebase alternative used by thousands of developers. If your Supabase project goes down or becomes slow, your app breaks. Vigilmon gives you external uptime monitoring for Supabase-powered apps.

What to Monitor

For Supabase projects, monitor:

  1. Your app's public URL (frontend/API)
  2. A health check Edge Function
  3. (Optional) Supabase's own status

Create a Supabase Edge Function Health Check

Deploy a lightweight health check Edge Function:

// supabase/functions/health/index.ts
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2';

Deno.serve(async (_req) => {
  const supabase = createClient(
    Deno.env.get('SUPABASE_URL')!,
    Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!
  );

  const checks: Record<string, string> = {};

  // Database check
  try {
    const { error } = await supabase.from('_health_probe').select('id').limit(1);
    checks.database = error ? 'error' : 'ok';
  } catch {
    // Table may not exist — just test connectivity
    checks.database = 'ok';
  }

  const allOk = Object.values(checks).every(v => v === 'ok');

  return new Response(
    JSON.stringify({ status: allOk ? 'ok' : 'degraded', checks }),
    {
      status: allOk ? 200 : 503,
      headers: { 'Content-Type': 'application/json' },
    }
  );
});
Enter fullscreen mode Exit fullscreen mode

Deploy with:

supabase functions deploy health --no-verify-jwt
Enter fullscreen mode Exit fullscreen mode

Your health URL will be:
https://<project-ref>.supabase.co/functions/v1/health

Monitor Your App's API Layer

If you have a Next.js or Express API on top of Supabase, add a health route there:

// pages/api/health.ts (Next.js)
import { createClient } from '@supabase/supabase-js';
import { NextApiRequest, NextApiResponse } from 'next';

const supabase = createClient(
  process.env.NEXT_PUBLIC_SUPABASE_URL!,
  process.env.SUPABASE_SERVICE_ROLE_KEY!
);

export default async function handler(_req: NextApiRequest, res: NextApiResponse) {
  try {
    const { error } = await supabase.rpc('version');
    if (error) throw error;
    res.status(200).json({ status: 'ok', db: 'connected' });
  } catch (e) {
    res.status(503).json({ status: 'error' });
  }
}
Enter fullscreen mode Exit fullscreen mode

Add to Vigilmon

  1. Go to vigilmon.online
  2. Click Add Monitor
  3. Enter your health URL
  4. Set interval: 1 minute
  5. Add Slack or email alert

Supabase Monitoring Strategy

Monitor What it checks
App URL Is the frontend reachable?
Edge Function /health Is Supabase DB accessible?
Auth endpoint Can users log in?

Start free at vigilmon.online — no credit card required.

Top comments (0)