Skip to main content

AlertConfig

Alert definition within a monitor configuration.
id
string
required
Unique identifier for the alert
name
string
required
Display name for the alert
condition
AlertCondition
required
Declarative condition or callback function that determines when to fire
channels
string[]
required
Array of channel IDs to notify when the alert fires
severity
AlertSeverity
Severity level of the alert. Defaults to “warning”.
regionThreshold
RegionThreshold
Multi-region threshold for firing. Defaults to “any”.
escalateAfterMs
number
Re-notify if alert stays firing for this many milliseconds
export interface AlertConfig {
  id: string;
  name: string;
  condition: AlertCondition;
  channels: string[];
  severity?: AlertSeverity;
  regionThreshold?: RegionThreshold;
  /** Re-notify if alert stays firing for this many ms */
  escalateAfterMs?: number;
}

DeclarativeCondition

Declarative alert conditions that can be configured without writing code.
export type DeclarativeCondition =
  | { consecutiveFailures: number }
  | { consecutiveSuccesses: number }
  | { latencyAboveMs: number; forChecks?: number }
  | { status: "down" | "degraded"; forChecks?: number }
  | { downForMs: number }
  | { upForMs: number };
consecutiveFailures
number
Fire when N consecutive check failures occur
consecutiveSuccesses
number
Fire when N consecutive check successes occur (used for recovery alerts)
latencyAboveMs
number
Fire when latency exceeds this threshold in milliseconds
forChecks
number
Optional: number of checks the condition must be true for (used with latencyAboveMs and status)
status
'down' | 'degraded'
Fire when monitor reaches this status
downForMs
number
Fire when monitor has been down for this duration in milliseconds
upForMs
number
Fire when monitor has been up for this duration in milliseconds

ConditionCallback

Callback-based condition function for advanced custom logic.
export type ConditionCallback = (
  result: CheckResultWithId,
  history: CheckResultWithId[],
) => boolean;
result
CheckResultWithId
The current check result with ID
history
CheckResultWithId[]
Array of recent check results for historical analysis
returns
boolean
Return true to fire the alert, false otherwise

AlertSeverity

Alert severity levels.
export type AlertSeverity = "critical" | "warning" | "info";
critical
literal
Critical severity - requires immediate attention
warning
literal
Warning severity - should be investigated
info
literal
Informational severity - for awareness only

AlertStatus

Alert state in memory and database.
export type AlertStatus = "ok" | "firing";
ok
literal
Alert condition is not met
firing
literal
Alert condition is met and alert is firing

AlertEventType

Alert event types for webhook notifications.
export type AlertEventType = "fired" | "resolved";
fired
literal
Alert has started firing
resolved
literal
Alert has been resolved and is no longer firing

RegionThreshold

Region threshold for multi-region alerting.
export type RegionThreshold = "any" | "majority" | "all" | number;
any
literal
Fire if any region triggers (default)
majority
literal
Fire if more than 50% of regions trigger
all
literal
Fire only if all regions trigger
number
number
Fire if N or more regions trigger

CheckResultWithId

Check result with ID for database references and alert evaluation.
id
string
required
Unique identifier for the check result
monitorId
string
required
ID of the monitor that performed the check
status
'up' | 'down' | 'degraded' | 'pending'
required
Status of the check
responseTimeMs
number
required
Response time in milliseconds
statusCode
number | null
required
HTTP status code if applicable, null otherwise
message
string | null
required
Optional message describing the check result
checkedAt
Date
required
Timestamp when the check was performed
export interface CheckResultWithId {
  id: string;
  monitorId: string;
  status: "up" | "down" | "degraded" | "pending";
  responseTimeMs: number;
  statusCode: number | null;
  message: string | null;
  checkedAt: Date;
}

AlertSnapshot

Snapshot of monitor state when an alert fires.
consecutiveFailures
number
required
Number of consecutive failures at the time of firing
consecutiveSuccesses
number
required
Number of consecutive successes at the time of firing
lastStatus
string
required
Last status of the monitor
lastResponseTimeMs
number | null
required
Last response time in milliseconds, or null if not available
lastMessage
string | null
required
Last message from the monitor check, or null if not available
export interface AlertSnapshot {
  consecutiveFailures: number;
  consecutiveSuccesses: number;
  lastStatus: string;
  lastResponseTimeMs: number | null;
  lastMessage: string | null;
}

Build docs developers (and LLMs) love