Skip to content

Alerting

cronbase sends notifications when jobs complete — via webhooks (Slack, Discord, any URL) or email (built-in SMTP client). Alerts are configured per-job and fire on success, failure, or timeout events.

Quick setup

The simplest way to add alerting is in your config file:

yaml
jobs:
  - name: backup-db
    schedule: "0 2 * * *"
    command: pg_dump mydb > /backups/db.sql
    on_failure: https://hooks.slack.com/services/T.../B.../xxx
    on_failure_email: ops@example.com

Config file shortcuts

Webhook shortcuts

PropertyEvents triggered
on_failurefailed, timeout
on_successsuccess
on_completesuccess, failed, timeout

Email shortcuts

PropertyEvents triggered
on_failure_emailfailed, timeout
on_success_emailsuccess
on_complete_emailsuccess, failed, timeout

Email fields accept a single address or a comma-separated list (e.g. ops@example.com, oncall@example.com).

You can combine webhook and email shortcuts on the same job — both fire independently.

Platform support

cronbase auto-detects the webhook platform from the URL and sends appropriately formatted messages.

Slack

URLs containing hooks.slack.com or slack.com/api receive Block Kit formatted messages with:

  • Color-coded attachments (green for success, red for failure)
  • Structured fields: schedule, duration, exit code, attempt number
  • stderr output block on failure

Discord

URLs containing discord.com/api/webhooks receive embed formatted messages with:

  • Color-coded embeds
  • Inline fields: schedule, duration, exit code
  • stderr output on failure

Generic webhook

All other URLs receive the raw JSON payload:

json
{
  "event": "failed",
  "job": {
    "id": 1,
    "name": "backup-db",
    "schedule": "0 2 * * *",
    "command": "pg_dump mydb > /backups/db.sql"
  },
  "execution": {
    "id": 42,
    "status": "failed",
    "exitCode": 1,
    "durationMs": 5230,
    "startedAt": "2025-01-15T02:00:00.000Z",
    "finishedAt": "2025-01-15T02:00:05.230Z",
    "stdoutTail": "...",
    "stderrTail": "pg_dump: error: connection refused",
    "attempt": 2
  },
  "timestamp": "2025-01-15T02:00:05.235Z"
}

Email (SMTP)

cronbase includes a built-in SMTP client for email alerts — no external mail libraries or services required.

Setup

Set the SMTP environment variables before starting cronbase:

bash
export CRONBASE_SMTP_HOST="smtp.gmail.com"
export CRONBASE_SMTP_PORT=465
export CRONBASE_SMTP_SECURE=true
export CRONBASE_SMTP_FROM="alerts@example.com"
export CRONBASE_SMTP_USERNAME="alerts@example.com"
export CRONBASE_SMTP_PASSWORD="app-password-here"

cronbase start

With Docker:

bash
docker run -d --name cronbase \
  -p 7433:7433 \
  -e CRONBASE_SMTP_HOST="smtp.gmail.com" \
  -e CRONBASE_SMTP_PORT=465 \
  -e CRONBASE_SMTP_SECURE=true \
  -e CRONBASE_SMTP_FROM="alerts@example.com" \
  -e CRONBASE_SMTP_USERNAME="alerts@example.com" \
  -e CRONBASE_SMTP_PASSWORD="app-password-here" \
  -v cronbase-data:/data \
  ghcr.io/paperkite-hq/cronbase

Environment variables

VariableDefaultDescription
CRONBASE_SMTP_HOST(none)SMTP server hostname (required to enable email alerts)
CRONBASE_SMTP_PORT587SMTP server port
CRONBASE_SMTP_SECUREfalseSet to true for TLS/SMTPS on connect (typically port 465)
CRONBASE_SMTP_FROMcronbase@localhostSender address
CRONBASE_SMTP_USERNAME(none)SMTP AUTH username
CRONBASE_SMTP_PASSWORD(none)SMTP AUTH password

Email content

Alert emails include:

  • Subject line with status icon: [cronbase] ✓ backup-db succeeded or [cronbase] ✗ backup-db failed
  • Job name, schedule, start time, duration, exit code, and attempt number
  • Last 500 characters of stderr (on failure) or stdout (on success)

Common SMTP providers

ProviderHostPortSecureNotes
Gmailsmtp.gmail.com465trueUse App Passwords
Outlook/Office 365smtp.office365.com587falseStandard auth or OAuth
Amazon SESemail-smtp.us-east-1.amazonaws.com465trueSMTP credentials from SES console
Postmarksmtp.postmarkapp.com587falseServer API token as password
Local relaylocalhost25falseNo auth needed for local relay

REST API configuration

You can also configure alerts via the REST API:

bash
# Set webhook + email alerts for job ID 1
curl -X PUT http://localhost:7433/api/jobs/1/alerts \
  -H "Content-Type: application/json" \
  -d '{
    "webhooks": [
      {
        "url": "https://hooks.slack.com/services/T.../B.../xxx",
        "events": ["failed", "timeout"]
      }
    ],
    "emails": [
      {
        "to": ["ops@example.com", "oncall@example.com"],
        "events": ["failed", "timeout"]
      }
    ]
  }'

# View current alert config
curl http://localhost:7433/api/jobs/1/alerts

# Remove alerts
curl -X DELETE http://localhost:7433/api/jobs/1/alerts

Email alerts require SMTP environment variables to be set (see Email setup above). If CRONBASE_SMTP_HOST is not set, email alerts are silently skipped with a warning in the logs.

Behavior

  • Alerts are sent asynchronously after job completion — they don't block the scheduler
  • Each webhook has a 10-second timeout to prevent hanging
  • Failed webhook deliveries are logged but don't affect job status
  • The stdoutTail and stderrTail fields contain the last 500 characters of output

Released under the AGPL-3.0 License.