See llms.txt for all machine-readable content.

Back to Templates

Monitor cron jobs and triage failures with GPT-5, PagerDuty and Slack

Quick overview

This workflow monitors scheduled jobs via heartbeat webhooks, stores job state and check-in history in n8n Data Tables, uses OpenAI and GitHub to triage failures, and notifies via Slack, PagerDuty Events API, and Gmail, plus a weekly Slack/email reliability report.

How it works

  1. Receives a POST heartbeat webhook from a job run (job name, status/exit code, duration, host, and log tail).
  2. Normalizes the payload, looks up the job in an n8n Data Table, calculates state changes (new, failed, recovered, or no change), and upserts the current job state while logging the check-in to a history table.
  3. When a job transitions to failing, OpenAI triages the failure using recent check-in history from the Data Table and (when configured) recent commits fetched from the GitHub API, producing a structured cause, evidence, first steps, and severity.
  4. For failures, posts the triage to a Slack channel, optionally triggers a PagerDuty incident via the Events API, and emails the job owner via Gmail.
  5. When a job recovers, optionally resolves the PagerDuty incident and posts a recovery message to Slack, and when a job checks in for the first time it announces the new job in Slack.
  6. Every 5 minutes, scans the job table for overdue check-ins, marks silent jobs as late, posts a Slack alert, and optionally pages via PagerDuty.
  7. Every Monday at 9 AM, summarizes the last 7 days of check-ins per job and uses OpenAI to write a short reliability note that is posted to Slack and emailed.
  8. If the monitoring workflow itself errors, posts an alert to Slack with the failing node and execution link.

Setup

  1. Create two n8n Data Tables named (or mapped to) cron_jobs and cron_checkins with the columns used by the workflow (job state fields in cron_jobs, and job/status/host/logTail/receivedAt/durationSec/exitCode in cron_checkins).
  2. Configure the heartbeat webhook with Header Auth and update your jobs to POST to the webhook URL with the required header key/value and JSON body (at minimum a job name, plus exitCode/status and optional log/duration/host).
  3. Add credentials for OpenAI (Chat model), GitHub API (to read commits), Slack (to post to your target channel), and Gmail (to email owners and send the weekly report).
  4. Create or select the Slack channel (for example #job-alerts) and update the channel setting in the Slack nodes if you use a different channel.
  5. Populate the cron_jobs table with per-job settings such as owner email, repo (org/name), optional pagerDutyKey, and expected interval/grace minutes, and set a PagerDuty routing key for any job that should page on failures or silence.