Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt

Use this file to discover all available pages before exploring further.

The three PF-36 Phase 2 edge functions need to be scheduled via pg_cron + pg_net in Supabase.

Prerequisites

Enable extensions in the Supabase Dashboard → Extensions:
  • pg_cron
  • pg_net

Scheduling SQL

Run these in the Supabase SQL Editor (NOT as a migration — they contain project-specific URLs and keys):
-- 1. SLA Violation Detection — every 1 minute
SELECT cron.schedule(
  'pf-detect-sla-violations',
  '* * * * *',
  $$
  SELECT net.http_post(
    url := 'https://zkgxozahyczcnzpwhbbf.supabase.co/functions/v1/pf-detect-sla-violations',
    headers := '{"Content-Type": "application/json", "Authorization": "Bearer YOUR_SERVICE_ROLE_KEY"}'::jsonb,
    body := concat('{"time": "', now(), '"}')::jsonb
  ) AS request_id;
  $$
);

-- 2. Metric Collection — every 5 minutes
SELECT cron.schedule(
  'pf-collect-metrics',
  '*/5 * * * *',
  $$
  SELECT net.http_post(
    url := 'https://zkgxozahyczcnzpwhbbf.supabase.co/functions/v1/pf-collect-metrics',
    headers := '{"Content-Type": "application/json", "Authorization": "Bearer YOUR_SERVICE_ROLE_KEY"}'::jsonb,
    body := concat('{"time": "', now(), '"}')::jsonb
  ) AS request_id;
  $$
);

-- 3. Metric Value Purge — daily at 3:00 AM UTC
SELECT cron.schedule(
  'pf-purge-metric-values',
  '0 3 * * *',
  $$
  SELECT net.http_post(
    url := 'https://zkgxozahyczcnzpwhbbf.supabase.co/functions/v1/pf-purge-metric-values',
    headers := '{"Content-Type": "application/json", "Authorization": "Bearer YOUR_SERVICE_ROLE_KEY"}'::jsonb,
    body := concat('{"time": "', now(), '"}')::jsonb
  ) AS request_id;
  $$
);
Important: Replace YOUR_SERVICE_ROLE_KEY with the actual service role key from the Supabase dashboard (Settings → API → Service Role key). Never commit service role keys to code.

Managing Cron Jobs

-- List all scheduled jobs
SELECT * FROM cron.job;

-- Unschedule a job
SELECT cron.unschedule('pf-detect-sla-violations');

-- View job run history
SELECT * FROM cron.job_run_details ORDER BY start_time DESC LIMIT 20;