[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M796GDZYZ2B8VKZ6FRQQYQDC":3,"skill-same:01M796GDZYZ2B8VKZ6FRQQYQDC":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":37,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":40,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M796GDZYZ2B8VKZ6FRQQYQDC","supabase-observability",null,"Set up monitoring and observability for Supabase projects using Dashboard\nreports, CLI inspect commands, pg_stat_statements, log drains, and alerting.\nUse when implementing monitoring, diagnosing slow queries, forwarding logs,\nor configuring alerts for Supabase project health.\nTrigger with phrases like \"supabase monitoring\", \"supabase metrics\",\n\"supabase observability\", \"supabase logs\", \"supabase alerts\",\n\"supabase inspect\", \"supabase log drain\".","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--supabase-pack--supabase-observability\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: supabase-observability\ndescription: |\n  Set up monitoring and observability for Supabase projects using Dashboard\n  reports, CLI inspect commands, pg_stat_statements, log drains, and alerting.\n  Use when implementing monitoring, diagnosing slow queries, forwarding logs,\n  or configuring alerts for Supabase project health.\n  Trigger with phrases like \"supabase monitoring\", \"supabase metrics\",\n  \"supabase observability\", \"supabase logs\", \"supabase alerts\",\n  \"supabase inspect\", \"supabase log drain\".\nallowed-tools: Read, Write, Edit, Bash(npx supabase:*), Bash(supabase:*), Grep\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ncompatible-with: claude-code\ntags: [saas, supabase, monitoring, observability]\n---\n\n# Supabase Observability\n\n## Overview\nMonitor Supabase projects end-to-end: Dashboard reports for API\u002Fdatabase\u002Fauth metrics, `supabase inspect db` CLI for deep Postgres diagnostics, `pg_stat_statements` for query analytics, log drains for external aggregation, Edge Functions for custom metrics, and alerting on quota thresholds.\n\n## Prerequisites\n- Supabase CLI installed (`npx supabase --version`)\n- Supabase project linked (`supabase link --project-ref \u003Cref>`)\n- Pro plan or higher for log drain support and extended log retention\n- `@supabase\u002Fsupabase-js` v2+ installed for application-level monitoring\n\n## Instructions\n\n### Step 1: Dashboard Reports and CLI Inspect Commands\n\nSupabase Dashboard provides built-in reports under **Dashboard > Reports**:\n\n| Report | What It Shows |\n|--------|---------------|\n| API Requests | Total requests, response times, error rates by endpoint |\n| Database | Active connections, query counts, replication lag |\n| Auth Usage | Signups, logins, provider breakdown, failed attempts |\n| Storage | Bandwidth, object counts, bucket usage |\n| Realtime | Active connections, messages per second, channel counts |\n\nFor deeper Postgres diagnostics, use the CLI inspect commands:\n\n```bash\n# Table sizes — find the largest tables\nnpx supabase inspect db table-sizes --linked\n\n# Index usage — find unused indexes wasting space\nnpx supabase inspect db index-usage --linked\n\n# Cache hit ratio — should be > 99% (below 95% means upgrade compute)\nnpx supabase inspect db cache-hit --linked\n\n# Sequential scans — tables needing indexes\nnpx supabase inspect db seq-scans --linked\n\n# Long-running queries — find stuck queries\nnpx supabase inspect db long-running-queries --linked\n\n# Table index sizes — compare index vs table size\nnpx supabase inspect db table-index-sizes --linked\n\n# Bloat — estimate wasted space from dead tuples\nnpx supabase inspect db bloat --linked\n\n# Blocking queries — find lock contention\nnpx supabase inspect db blocking --linked\n\n# Replication slots — check replication health\nnpx supabase inspect db replication-slots --linked\n```\n\n### Step 2: Query Analytics with pg_stat_statements and Log Drains\n\nEnable `pg_stat_statements` for detailed query-level metrics:\n\n```sql\n-- Enable the extension (Dashboard > Database > Extensions, or SQL)\ncreate extension if not exists pg_stat_statements;\n\n-- Top 20 slowest queries by average execution time\nselect\n  substring(query, 1, 80) as query_preview,\n  calls,\n  round(mean_exec_time::numeric, 2) as avg_ms,\n  round(max_exec_time::numeric, 2) as max_ms,\n  round(total_exec_time::numeric, 2) as total_ms,\n  rows\nfrom pg_stat_statements\nwhere mean_exec_time > 50\norder by mean_exec_time desc\nlimit 20;\n\n-- Most-called queries (high call count may indicate N+1 problems)\nselect\n  substring(query, 1, 80) as query_preview,\n  calls,\n  round(mean_exec_time::numeric, 2) as avg_ms,\n  rows\nfrom pg_stat_statements\norder by calls desc\nlimit 20;\n\n-- Real-time connection monitoring\nselect\n  state,\n  count(*) as connections,\n  max(age(now(), state_change))::text as longest_duration\nfrom pg_stat_activity\nwhere datname = current_database()\ngroup by state\norder by connections desc;\n\n-- Reset stats after optimization (to measure improvement)\nselect pg_stat_statements_reset();\n```\n\n**Log drains** forward Supabase logs to external aggregation tools:\n\n```bash\n# Add a Datadog log drain\nnpx supabase log-drains add \\\n  --name datadog-drain \\\n  --type datadog \\\n  --datadog-api-key \"$DATADOG_API_KEY\" \\\n  --datadog-region us1 \\\n  --linked\n\n# Add a custom HTTP log drain (Logflare, Axiom, etc.)\nnpx supabase log-drains add \\\n  --name custom-drain \\\n  --type webhook \\\n  --url \"https:\u002F\u002Fapi.logflare.app\u002Flogs\u002Fsupabase\" \\\n  --linked\n\n# List active drains\nnpx supabase log-drains list --linked\n\n# Remove a drain\nnpx supabase log-drains remove \u003Cdrain-id> --linked\n```\n\nLog drain events include API requests, Auth events, Postgres logs, Storage operations, and Edge Function invocations.\n\n### Step 3: Custom Metrics, Alerting, and Health Checks\n\n**Custom metrics via Edge Functions** — emit structured events for business-level monitoring:\n\n```typescript\n\u002F\u002F supabase\u002Ffunctions\u002Fcollect-metrics\u002Findex.ts\nimport { createClient } from '@supabase\u002Fsupabase-js';\nimport { serve } from 'https:\u002F\u002Fdeno.land\u002Fstd@0.177.0\u002Fhttp\u002Fserver.ts';\n\nserve(async () => {\n  const supabase = createClient(\n    Deno.env.get('SUPABASE_URL')!,\n    Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!\n  );\n\n  \u002F\u002F Collect quota-relevant metrics\n  const { count: userCount } = await supabase\n    .from('profiles')\n    .select('*', { count: 'exact', head: true });\n\n  const { count: storageObjects } = await supabase\n    .storage.from('uploads')\n    .list('', { limit: 1, offset: 0 })\n    .then(({ data }) => ({ count: data?.length ?? 0 }));\n\n  const { data: dbSize } = await supabase\n    .rpc('get_database_size');\n\n  const metrics = {\n    timestamp: new Date().toISOString(),\n    user_count: userCount,\n    db_size_mb: dbSize,\n    storage_objects: storageObjects,\n  };\n\n  \u002F\u002F Store metrics for trend analysis\n  await supabase.from('app_metrics').insert(metrics);\n\n  \u002F\u002F Alert on quota thresholds\n  const DB_LIMIT_MB = 8000; \u002F\u002F 8GB Pro plan limit\n  if (dbSize > DB_LIMIT_MB * 0.85) {\n    console.warn(`[QUOTA_ALERT] Database at ${Math.round(dbSize \u002F DB_LIMIT_MB * 100)}% capacity`);\n    \u002F\u002F Send alert via webhook, email, or Slack\n  }\n\n  return new Response(JSON.stringify(metrics), {\n    headers: { 'Content-Type': 'application\u002Fjson' },\n  });\n});\n```\n\nSchedule it with a cron trigger in `supabase\u002Fconfig.toml`:\n\n```toml\n[functions.collect-metrics]\nschedule = \"*\u002F15 * * * *\"  # Every 15 minutes\n```\n\n**Health check endpoint** for uptime monitoring (Uptime Robot, Pingdom, etc.):\n\n```typescript\n\u002F\u002F supabase\u002Ffunctions\u002Fhealth\u002Findex.ts\nimport { createClient } from '@supabase\u002Fsupabase-js';\nimport { serve } from 'https:\u002F\u002Fdeno.land\u002Fstd@0.177.0\u002Fhttp\u002Fserver.ts';\n\nserve(async () => {\n  const supabase = createClient(\n    Deno.env.get('SUPABASE_URL')!,\n    Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!\n  );\n\n  const checks: Record\u003Cstring, { status: string; latency_ms: number; detail?: string }> = {};\n\n  \u002F\u002F Database check\n  const dbStart = Date.now();\n  const { error: dbErr } = await supabase.rpc('version');\n  checks.database = {\n    status: dbErr ? 'unhealthy' : 'healthy',\n    latency_ms: Date.now() - dbStart,\n    ...(dbErr && { detail: dbErr.message }),\n  };\n\n  \u002F\u002F Auth check\n  const authStart = Date.now();\n  const { error: authErr } = await supabase.auth.admin.listUsers({ perPage: 1 });\n  checks.auth = {\n    status: authErr ? 'unhealthy' : 'healthy',\n    latency_ms: Date.now() - authStart,\n  };\n\n  \u002F\u002F Storage check\n  const storageStart = Date.now();\n  const { error: storageErr } = await supabase.storage.listBuckets();\n  checks.storage = {\n    status: storageErr ? 'unhealthy' : 'healthy',\n    latency_ms: Date.now() - storageStart,\n  };\n\n  const overall = Object.values(checks).every(c => c.status === 'healthy');\n  const statusCode = overall ? 200 : 503;\n\n  return new Response(\n    JSON.stringify({ status: overall ? 'healthy' : 'degraded', checks, timestamp: new Date().toISOString() }),\n    { status: statusCode, headers: { 'Content-Type': 'application\u002Fjson' } }\n  );\n});\n```\n\n**Real-time connection monitoring** — track active Realtime connections:\n\n```typescript\nimport { createClient } from '@supabase\u002Fsupabase-js';\n\nconst supabase = createClient(\n  process.env.NEXT_PUBLIC_SUPABASE_URL!,\n  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!\n);\n\n\u002F\u002F Monitor channel state changes\nconst channel = supabase.channel('monitoring');\n\nchannel\n  .on('system', { event: '*' }, (payload) => {\n    console.log(`[REALTIME] System event:`, payload);\n  })\n  .subscribe((status) => {\n    console.log(`[REALTIME] Connection status: ${status}`);\n    if (status === 'CHANNEL_ERROR') {\n      console.error('[REALTIME] Connection lost — will auto-reconnect');\n    }\n  });\n```\n\n## Output\n- Dashboard reports configured for API, database, and auth monitoring\n- CLI inspect commands available for Postgres diagnostics (table sizes, index usage, cache hits, sequential scans, long-running queries)\n- `pg_stat_statements` enabled with slow-query and high-frequency-query views\n- Log drains forwarding to external tools (Datadog, Logflare, or webhook)\n- Custom metrics Edge Function collecting quota-relevant data on a schedule\n- Health check endpoint returning per-service status with latency\n- Alerting on quota thresholds (database size, user count)\n\n## Error Handling\n\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| `pg_stat_statements` returns no rows | Extension not enabled | Enable via Dashboard > Database > Extensions |\n| `supabase inspect db` fails | CLI not linked to project | Run `supabase link --project-ref \u003Cref>` |\n| Log drain not receiving events | API key invalid or region mismatch | Verify credentials; check `supabase log-drains list` |\n| Cache hit ratio below 95% | Working set exceeds RAM | Upgrade compute add-on or optimize queries |\n| Health check returns 503 | One or more services degraded | Check `detail` field in response; verify service role key |\n| Edge Function cron not firing | Missing `schedule` in config.toml | Add `[functions.\u003Cname>]` with `schedule` field and redeploy |\n| Long-running queries growing | Missing indexes or lock contention | Run `inspect db seq-scans` and `inspect db blocking` |\n\n## Examples\n\n### Quick Diagnostic Script\n```bash\n#!\u002Fbin\u002Fbash\n# supabase-health-check.sh — run all inspect commands at once\necho \"=== Table Sizes ===\"\nnpx supabase inspect db table-sizes --linked\necho \"\"\necho \"=== Cache Hit Ratio ===\"\nnpx supabase inspect db cache-hit --linked\necho \"\"\necho \"=== Sequential Scans ===\"\nnpx supabase inspect db seq-scans --linked\necho \"\"\necho \"=== Long Running Queries ===\"\nnpx supabase inspect db long-running-queries --linked\necho \"\"\necho \"=== Index Usage ===\"\nnpx supabase inspect db index-usage --linked\n```\n\n### Metrics Table Schema\n```sql\ncreate table if not exists app_metrics (\n  id bigint generated always as identity primary key,\n  timestamp timestamptz not null default now(),\n  user_count integer,\n  db_size_mb numeric,\n  storage_objects integer,\n  api_requests_24h integer,\n  avg_response_ms numeric\n);\n\n-- Index for time-series queries\ncreate index idx_app_metrics_timestamp on app_metrics (timestamp desc);\n\n-- Retention policy: keep 90 days\ncreate or replace function cleanup_old_metrics()\nreturns void as $$\n  delete from app_metrics where timestamp \u003C now() - interval '90 days';\n$$ language sql;\n```\n\n## Resources\n- [Supabase Logs & Analytics](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Fplatform\u002Flogs)\n- [Database Inspect Commands](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Fdatabase\u002Finspect)\n- [Log Drains](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Fplatform\u002Flog-drains)\n- [Edge Functions Scheduling](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Ffunctions\u002Fschedule-functions)\n- [pg_stat_statements](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Fdatabase\u002Fextensions\u002Fpg_stat_statements)\n- [Supabase JS Client](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Freference\u002Fjavascript\u002Fintroduction)\n\n## Next Steps\nFor incident response procedures, see `supabase-incident-runbook`.\nFor performance optimization, see `supabase-performance-tuning`.\n","# Supabase Observability\n\n## Overview\nMonitor Supabase projects end-to-end: Dashboard reports for API\u002Fdatabase\u002Fauth metrics, `supabase inspect db` CLI for deep Postgres diagnostics, `pg_stat_statements` for query analytics, log drains for external aggregation, Edge Functions for custom metrics, and alerting on quota thresholds.\n\n## Prerequisites\n- Supabase CLI installed (`npx supabase --version`)\n- Supabase project linked (`supabase link --project-ref \u003Cref>`)\n- Pro plan or higher for log drain support and extended log retention\n- `@supabase\u002Fsupabase-js` v2+ installed for application-level monitoring\n\n## Instructions\n\n### Step 1: Dashboard Reports and CLI Inspect Commands\n\nSupabase Dashboard provides built-in reports under **Dashboard > Reports**:\n\n| Report | What It Shows |\n|--------|---------------|\n| API Requests | Total requests, response times, error rates by endpoint |\n| Database | Active connections, query counts, replication lag |\n| Auth Usage | Signups, logins, provider breakdown, failed attempts |\n| Storage | Bandwidth, object counts, bucket usage |\n| Realtime | Active connections, messages per second, channel counts |\n\nFor deeper Postgres diagnostics, use the CLI inspect commands:\n\n```bash\n# Table sizes — find the largest tables\nnpx supabase inspect db table-sizes --linked\n\n# Index usage — find unused indexes wasting space\nnpx supabase inspect db index-usage --linked\n\n# Cache hit ratio — should be > 99% (below 95% means upgrade compute)\nnpx supabase inspect db cache-hit --linked\n\n# Sequential scans — tables needing indexes\nnpx supabase inspect db seq-scans --linked\n\n# Long-running queries — find stuck queries\nnpx supabase inspect db long-running-queries --linked\n\n# Table index sizes — compare index vs table size\nnpx supabase inspect db table-index-sizes --linked\n\n# Bloat — estimate wasted space from dead tuples\nnpx supabase inspect db bloat --linked\n\n# Blocking queries — find lock contention\nnpx supabase inspect db blocking --linked\n\n# Replication slots — check replication health\nnpx supabase inspect db replication-slots --linked\n```\n\n### Step 2: Query Analytics with pg_stat_statements and Log Drains\n\nEnable `pg_stat_statements` for detailed query-level metrics:\n\n```sql\n-- Enable the extension (Dashboard > Database > Extensions, or SQL)\ncreate extension if not exists pg_stat_statements;\n\n-- Top 20 slowest queries by average execution time\nselect\n  substring(query, 1, 80) as query_preview,\n  calls,\n  round(mean_exec_time::numeric, 2) as avg_ms,\n  round(max_exec_time::numeric, 2) as max_ms,\n  round(total_exec_time::numeric, 2) as total_ms,\n  rows\nfrom pg_stat_statements\nwhere mean_exec_time > 50\norder by mean_exec_time desc\nlimit 20;\n\n-- Most-called queries (high call count may indicate N+1 problems)\nselect\n  substring(query, 1, 80) as query_preview,\n  calls,\n  round(mean_exec_time::numeric, 2) as avg_ms,\n  rows\nfrom pg_stat_statements\norder by calls desc\nlimit 20;\n\n-- Real-time connection monitoring\nselect\n  state,\n  count(*) as connections,\n  max(age(now(), state_change))::text as longest_duration\nfrom pg_stat_activity\nwhere datname = current_database()\ngroup by state\norder by connections desc;\n\n-- Reset stats after optimization (to measure improvement)\nselect pg_stat_statements_reset();\n```\n\n**Log drains** forward Supabase logs to external aggregation tools:\n\n```bash\n# Add a Datadog log drain\nnpx supabase log-drains add \\\n  --name datadog-drain \\\n  --type datadog \\\n  --datadog-api-key \"$DATADOG_API_KEY\" \\\n  --datadog-region us1 \\\n  --linked\n\n# Add a custom HTTP log drain (Logflare, Axiom, etc.)\nnpx supabase log-drains add \\\n  --name custom-drain \\\n  --type webhook \\\n  --url \"https:\u002F\u002Fapi.logflare.app\u002Flogs\u002Fsupabase\" \\\n  --linked\n\n# List active drains\nnpx supabase log-drains list --linked\n\n# Remove a drain\nnpx supabase log-drains remove \u003Cdrain-id> --linked\n```\n\nLog drain events include API requests, Auth events, Postgres logs, Storage operations, and Edge Function invocations.\n\n### Step 3: Custom Metrics, Alerting, and Health Checks\n\n**Custom metrics via Edge Functions** — emit structured events for business-level monitoring:\n\n```typescript\n\u002F\u002F supabase\u002Ffunctions\u002Fcollect-metrics\u002Findex.ts\nimport { createClient } from '@supabase\u002Fsupabase-js';\nimport { serve } from 'https:\u002F\u002Fdeno.land\u002Fstd@0.177.0\u002Fhttp\u002Fserver.ts';\n\nserve(async () => {\n  const supabase = createClient(\n    Deno.env.get('SUPABASE_URL')!,\n    Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!\n  );\n\n  \u002F\u002F Collect quota-relevant metrics\n  const { count: userCount } = await supabase\n    .from('profiles')\n    .select('*', { count: 'exact', head: true });\n\n  const { count: storageObjects } = await supabase\n    .storage.from('uploads')\n    .list('', { limit: 1, offset: 0 })\n    .then(({ data }) => ({ count: data?.length ?? 0 }));\n\n  const { data: dbSize } = await supabase\n    .rpc('get_database_size');\n\n  const metrics = {\n    timestamp: new Date().toISOString(),\n    user_count: userCount,\n    db_size_mb: dbSize,\n    storage_objects: storageObjects,\n  };\n\n  \u002F\u002F Store metrics for trend analysis\n  await supabase.from('app_metrics').insert(metrics);\n\n  \u002F\u002F Alert on quota thresholds\n  const DB_LIMIT_MB = 8000; \u002F\u002F 8GB Pro plan limit\n  if (dbSize > DB_LIMIT_MB * 0.85) {\n    console.warn(`[QUOTA_ALERT] Database at ${Math.round(dbSize \u002F DB_LIMIT_MB * 100)}% capacity`);\n    \u002F\u002F Send alert via webhook, email, or Slack\n  }\n\n  return new Response(JSON.stringify(metrics), {\n    headers: { 'Content-Type': 'application\u002Fjson' },\n  });\n});\n```\n\nSchedule it with a cron trigger in `supabase\u002Fconfig.toml`:\n\n```toml\n[functions.collect-metrics]\nschedule = \"*\u002F15 * * * *\"  # Every 15 minutes\n```\n\n**Health check endpoint** for uptime monitoring (Uptime Robot, Pingdom, etc.):\n\n```typescript\n\u002F\u002F supabase\u002Ffunctions\u002Fhealth\u002Findex.ts\nimport { createClient } from '@supabase\u002Fsupabase-js';\nimport { serve } from 'https:\u002F\u002Fdeno.land\u002Fstd@0.177.0\u002Fhttp\u002Fserver.ts';\n\nserve(async () => {\n  const supabase = createClient(\n    Deno.env.get('SUPABASE_URL')!,\n    Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!\n  );\n\n  const checks: Record\u003Cstring, { status: string; latency_ms: number; detail?: string }> = {};\n\n  \u002F\u002F Database check\n  const dbStart = Date.now();\n  const { error: dbErr } = await supabase.rpc('version');\n  checks.database = {\n    status: dbErr ? 'unhealthy' : 'healthy',\n    latency_ms: Date.now() - dbStart,\n    ...(dbErr && { detail: dbErr.message }),\n  };\n\n  \u002F\u002F Auth check\n  const authStart = Date.now();\n  const { error: authErr } = await supabase.auth.admin.listUsers({ perPage: 1 });\n  checks.auth = {\n    status: authErr ? 'unhealthy' : 'healthy',\n    latency_ms: Date.now() - authStart,\n  };\n\n  \u002F\u002F Storage check\n  const storageStart = Date.now();\n  const { error: storageErr } = await supabase.storage.listBuckets();\n  checks.storage = {\n    status: storageErr ? 'unhealthy' : 'healthy',\n    latency_ms: Date.now() - storageStart,\n  };\n\n  const overall = Object.values(checks).every(c => c.status === 'healthy');\n  const statusCode = overall ? 200 : 503;\n\n  return new Response(\n    JSON.stringify({ status: overall ? 'healthy' : 'degraded', checks, timestamp: new Date().toISOString() }),\n    { status: statusCode, headers: { 'Content-Type': 'application\u002Fjson' } }\n  );\n});\n```\n\n**Real-time connection monitoring** — track active Realtime connections:\n\n```typescript\nimport { createClient } from '@supabase\u002Fsupabase-js';\n\nconst supabase = createClient(\n  process.env.NEXT_PUBLIC_SUPABASE_URL!,\n  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!\n);\n\n\u002F\u002F Monitor channel state changes\nconst channel = supabase.channel('monitoring');\n\nchannel\n  .on('system', { event: '*' }, (payload) => {\n    console.log(`[REALTIME] System event:`, payload);\n  })\n  .subscribe((status) => {\n    console.log(`[REALTIME] Connection status: ${status}`);\n    if (status === 'CHANNEL_ERROR') {\n      console.error('[REALTIME] Connection lost — will auto-reconnect');\n    }\n  });\n```\n\n## Output\n- Dashboard reports configured for API, database, and auth monitoring\n- CLI inspect commands available for Postgres diagnostics (table sizes, index usage, cache hits, sequential scans, long-running queries)\n- `pg_stat_statements` enabled with slow-query and high-frequency-query views\n- Log drains forwarding to external tools (Datadog, Logflare, or webhook)\n- Custom metrics Edge Function collecting quota-relevant data on a schedule\n- Health check endpoint returning per-service status with latency\n- Alerting on quota thresholds (database size, user count)\n\n## Error Handling\n\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| `pg_stat_statements` returns no rows | Extension not enabled | Enable via Dashboard > Database > Extensions |\n| `supabase inspect db` fails | CLI not linked to project | Run `supabase link --project-ref \u003Cref>` |\n| Log drain not receiving events | API key invalid or region mismatch | Verify credentials; check `supabase log-drains list` |\n| Cache hit ratio below 95% | Working set exceeds RAM | Upgrade compute add-on or optimize queries |\n| Health check returns 503 | One or more services degraded | Check `detail` field in response; verify service role key |\n| Edge Function cron not firing | Missing `schedule` in config.toml | Add `[functions.\u003Cname>]` with `schedule` field and redeploy |\n| Long-running queries growing | Missing indexes or lock contention | Run `inspect db seq-scans` and `inspect db blocking` |\n\n## Examples\n\n### Quick Diagnostic Script\n```bash\n#!\u002Fbin\u002Fbash\n# supabase-health-check.sh — run all inspect commands at once\necho \"=== Table Sizes ===\"\nnpx supabase inspect db table-sizes --linked\necho \"\"\necho \"=== Cache Hit Ratio ===\"\nnpx supabase inspect db cache-hit --linked\necho \"\"\necho \"=== Sequential Scans ===\"\nnpx supabase inspect db seq-scans --linked\necho \"\"\necho \"=== Long Running Queries ===\"\nnpx supabase inspect db long-running-queries --linked\necho \"\"\necho \"=== Index Usage ===\"\nnpx supabase inspect db index-usage --linked\n```\n\n### Metrics Table Schema\n```sql\ncreate table if not exists app_metrics (\n  id bigint generated always as identity primary key,\n  timestamp timestamptz not null default now(),\n  user_count integer,\n  db_size_mb numeric,\n  storage_objects integer,\n  api_requests_24h integer,\n  avg_response_ms numeric\n);\n\n-- Index for time-series queries\ncreate index idx_app_metrics_timestamp on app_metrics (timestamp desc);\n\n-- Retention policy: keep 90 days\ncreate or replace function cleanup_old_metrics()\nreturns void as $$\n  delete from app_metrics where timestamp \u003C now() - interval '90 days';\n$$ language sql;\n```\n\n## Resources\n- [Supabase Logs & Analytics](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Fplatform\u002Flogs)\n- [Database Inspect Commands](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Fdatabase\u002Finspect)\n- [Log Drains](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Fplatform\u002Flog-drains)\n- [Edge Functions Scheduling](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Ffunctions\u002Fschedule-functions)\n- [pg_stat_statements](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Fdatabase\u002Fextensions\u002Fpg_stat_statements)\n- [Supabase JS Client](https:\u002F\u002Fsupabase.com\u002Fdocs\u002Freference\u002Fjavascript\u002Fintroduction)\n\n## Next Steps\nFor incident response procedures, see `supabase-incident-runbook`.\nFor performance optimization, see `supabase-performance-tuning`.\n",{"name":5,"tags":24,"author":29,"license":15,"version":30,"description":31,"allowed-tools":32,"compatible-with":33},[25,26,27,28],"saas","supabase","monitoring","observability","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Set up monitoring and observability for Supabase projects using Dashboard\nreports, CLI inspect commands, pg_stat_statements, log drains, and alerting.\nUse when implementing monitoring, diagnosing slow queries, forwarding logs,\nor configuring alerts for Supabase project health.\nTrigger with phrases like \"supabase monitoring\", \"supabase metrics\",\n\"supabase observability\", \"supabase logs\", \"supabase alerts\",\n\"supabase inspect\", \"supabase log drain\".\n","Read, Write, Edit, Bash(npx supabase:*), Bash(supabase:*), Grep","claude-code","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--supabase-pack--supabase-observability",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill supabase-observability",{"tool":49,"command":50},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill supabase-observability",{"tool":52,"command":53},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill supabase-observability","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--supabase-pack--supabase-observability\u002FSKILL.md",true,[],[58,65,72,79,86,94],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":90,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]