CH-UICH-UI

Schedules

Cron-based scheduled query execution with auto-alerts

Schedules let you run saved queries on a cron schedule with timeout control, timezone support, run history, and automatic alerting on failures and slow executions.

Requires a Pro license.

Overview

Each schedule has:

  • A saved query (the SQL to execute)
  • A cron expression (5-field standard format)
  • A timezone (IANA, default UTC)
  • A timeout (milliseconds, default 60s)

Creating a Schedule

Navigate to Schedules in the sidebar and click New Schedule.

FieldDescriptionDefault
NameSchedule identifierRequired
Saved QuerySelect from existing saved queriesRequired
Cron5-field cron expressionRequired
TimezoneIANA timezone (e.g. America/New_York)UTC
Timeout (ms)Max execution time60000 (60s)
EnabledWhether the scheduler should trigger thistrue

Cron Syntax

Standard 5-field format:

FieldRangeSpecial
Minute0-59*, ,, -, /
Hour0-23*, ,, -, /
Day of month1-31*, ,, -, /
Month1-12*, ,, -, /
Day of week0-6 (Sun=0)*, ,, -, /

Examples:

0 9 * * *     # Daily at 9:00 AM
0 */6 * * *   # Every 6 hours
30 2 * * 0    # Sundays at 2:30 AM
0 0 1 * *     # First of month at midnight

next_run_at is computed automatically and always stored in UTC.

Execution Model

The schedule runner wakes every 30 seconds and checks for enabled schedules with next_run_at <= now.

Concurrency

Up to 3 schedules execute concurrently (system-wide semaphore). Additional due schedules wait for the next tick.

Credential Resolution

Scheduled runs need ClickHouse credentials. The runner:

  1. Checks for a connection-specific override on the schedule
  2. Falls back to the saved query's connection
  3. Searches active user sessions (tries up to 3 recent sessions)
  4. Decrypts the stored password using the app secret key

If no valid credentials are found, the run fails with an error.

Execution Flow

  1. Fetch the linked saved query
  2. Verify the tunnel is online for the target connection
  3. Resolve credentials (see above)
  4. Execute the query with the configured timeout (minimum enforced: 60s)
  5. Record the result (status, elapsed time, rows affected, error)
  6. Update last_run_at, last_status, last_error
  7. Recompute next_run_at if the schedule is still enabled
  8. Create audit log entry

Manual Execution

Trigger a schedule immediately without waiting for the cron:

POST /api/schedules/{id}/run

Returns synchronously with the run result including status, elapsed time, and any error.

Auto-Alerts

Schedules automatically create alert events for failures and slow executions. These integrate with the Governance alerts system.

Failure Alert

FieldValue
Event Typeschedule.failed
Severityerror
Fingerprintschedule:{id}:error

Created immediately when a scheduled run fails.

Slow Execution Alert

FieldValue
Event Typeschedule.slow
Severitywarn
Fingerprintschedule:{id}:slow
ThresholdElapsed time >= 80% of timeout (minimum 5 seconds)

Created when a run succeeds but takes too long relative to its timeout. Helps identify schedules that may need timeout increases or query optimization.

Both alert types use fingerprint-based deduplication to prevent duplicate alerts per schedule within the configured cooldown window.

Run History

View execution history for each schedule.

GET /api/schedules/{id}/runs?limit=50&offset=0

Default limit: 50, max: 500.

Run Fields

FieldDescription
idRun identifier
started_atWhen execution began
finished_atWhen execution completed
statusrunning, success, or error
rows_affectedNumber of rows affected
elapsed_msExecution time in milliseconds
errorError message (if status is error)

API Endpoints

MethodPathPurpose
GET/api/schedulesList all schedules
GET/api/schedules/{id}Get schedule details
POST/api/schedulesCreate schedule
PUT/api/schedules/{id}Update schedule
DELETE/api/schedules/{id}Delete schedule
POST/api/schedules/{id}/runManual execution
GET/api/schedules/{id}/runsRun history

On this page