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 — PostgreSQL, Auth, Storage, Edge Functions, and Realtime in one platform. When your app depends on Supabase, monitoring its availability and your application's health is critical. This guide covers how to monitor Supabase-backed applications with Vigilmon.

What to Monitor for Supabase Apps

  1. Your application's API endpoints — the user-facing layer
  2. Supabase's official status — platform-level outages
  3. Your Supabase Edge Functions — if you use them for backend logic
  4. SSL certificates — for custom domains

Step 1: Monitor Your Application Layer

Your app that uses Supabase should have a health endpoint that verifies Supabase connectivity:

Next.js API Route

// app/api/health/route.ts
import { createClient } from '@supabase/supabase-js'
import { NextResponse } from 'next/server'

export async function GET() {
  const supabase = createClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.SUPABASE_SERVICE_ROLE_KEY!
  )

  const checks: Record<string, string> = {}
  let status = 'ok'

  // Check Supabase database connectivity
  try {
    const { data, error } = await supabase
      .from('_health_check')
      .select('1')
      .limit(1)

    if (error && error.code !== 'PGRST116') { // PGRST116 = table not found (ok)
      throw error
    }
    checks.database = 'ok'
  } catch (err) {
    checks.database = 'error'
    status = 'degraded'
  }

  // Check Supabase Auth
  try {
    const { data: { users }, error } = await supabase.auth.admin.listUsers({ page: 1, perPage: 1 })
    if (error) throw error
    checks.auth = 'ok'
  } catch (err) {
    checks.auth = 'error'
    // Auth being down is degraded, not critical
  }

  return NextResponse.json(
    { status, checks, timestamp: new Date().toISOString() },
    { status: status === 'ok' ? 200 : 503 }
  )
}
Enter fullscreen mode Exit fullscreen mode

SvelteKit

// src/routes/api/health/+server.ts
import { createClient } from '@supabase/supabase-js'
import { json } from '@sveltejs/kit'
import { SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY } from '$env/static/private'

export async function GET() {
  const supabase = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY)

  try {
    // Simple connectivity check
    const { error } = await supabase.from('profiles').select('id').limit(1)
    if (error) throw error

    return json({ status: 'ok', supabase: 'connected' })
  } catch (err) {
    return json({ status: 'degraded', supabase: 'error' }, { status: 503 })
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Monitor Supabase Edge Functions

If you use Supabase Edge Functions, add a dedicated health function:

// supabase/functions/health/index.ts
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts'

serve(async (req) => {
  return new Response(
    JSON.stringify({
      status: 'ok',
      function: 'health',
      timestamp: new Date().toISOString()
    }),
    {
      headers: { 'Content-Type': 'application/json' },
      status: 200
    }
  )
})
Enter fullscreen mode Exit fullscreen mode

Deploy:

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

Then monitor: https://your-project.supabase.co/functions/v1/health

Step 3: Set Up Vigilmon Monitors

Monitor 1: Your Application

  1. Sign up at vigilmon.online
  2. New Monitor → HTTP(S)
  3. URL: https://yourapp.com/api/health
  4. Interval: 1 minute | Timeout: 10 seconds

Monitor 2: Supabase Edge Functions

  1. New Monitor → HTTP(S)
  2. URL: https://your-project.supabase.co/functions/v1/health
  3. Headers: Authorization: Bearer your-anon-key
  4. Interval: 5 minutes

Monitor 3: Supabase REST API

Check that your Supabase project's REST API is responding:

  1. New Monitor → HTTP(S)
  2. URL: https://your-project.supabase.co/rest/v1/
  3. Headers:
    • apikey: your-anon-key
    • Authorization: Bearer your-anon-key
  4. Expected status: 200

Step 4: Configure Status Pages

Vigilmon's status pages let you communicate Supabase outages to your users:

https://status.yourapp.com
Enter fullscreen mode Exit fullscreen mode

Create a status page showing:

  • Application API — your main service
  • Database — Supabase PostgreSQL
  • Authentication — Supabase Auth
  • Edge Functions — if applicable

Step 5: Handle Supabase-Specific Failures

Common Supabase failures and how Vigilmon catches them:

Failure Vigilmon Detection
Supabase platform outage App health check returns 503
Row Level Security misconfiguration API returns 403 instead of 200
Edge function cold start timeout Response time > threshold
Auth service degraded Auth check in health endpoint fails
Database connection pool exhausted Slow response / 503

Step 6: Set Up Alerts

For Supabase apps, configure Vigilmon alerts:

  • Slack: Alert your dev channel within 1 minute of downtime
  • Email: Send to your on-call team
  • Webhook: Trigger PagerDuty for critical production issues

Set confirmation threshold to 2 failures to avoid false positives from Supabase's brief maintenance windows.

Summary

Supabase is reliable, but platform-level outages happen (check their status page). Vigilmon gives you independent monitoring that alerts your team before users start complaining.

Start monitoring your Supabase app for free →


Related: How to Monitor PostgreSQL with Vigilmon | How to Monitor Your Next.js Application with Vigilmon

Top comments (0)