Skip to main content

MonitorResult

Result returned by a monitor handler function.
status
MonitorStatus
required
The status of the monitor check
responseTime
number
required
Response time in milliseconds
message
string
Optional message describing the check result
statusCode
number
HTTP status code if applicable
export interface MonitorResult {
  status: MonitorStatus;
  responseTime: number; // milliseconds
  message?: string;
  statusCode?: number;
}

MonitorStatus

The status of a monitor check.
export type MonitorStatus = "up" | "down" | "degraded" | "pending";
up
literal
Monitor is functioning normally
down
literal
Monitor has failed or is unreachable
degraded
literal
Monitor is responding but with degraded performance
pending
literal
Monitor check is pending or has not yet run

MonitorConfig

Monitor configuration file schema. The filename becomes the monitor ID.
name
string
required
Display name for the monitor
interval
string
Human-readable interval: ”30s”, “5m”, “1h”. Optional if cron is set.
cron
string
Cron expression: ”*/5 * * * *”. Optional if interval is set.
timeout
string
Human-readable timeout duration. Defaults to ”30s”.
active
boolean
Whether the monitor is active. Defaults to true.
alerts
AlertConfig[]
Array of alert configurations for this monitor
handler
() => Promise<MonitorResult>
required
Handler function that runs the monitor check. Returns status, response time, and optional message.
export interface MonitorConfig {
  name: string;
  interval?: string; // human-readable: "30s", "5m", "1h" - optional if cron is set
  cron?: string; // cron expression: "*/5 * * * *" - optional if interval is set
  timeout?: string; // human-readable, defaults to "30s"
  active?: boolean; // defaults to true
  alerts?: AlertConfig[];

  /**
   * Handler function that runs the monitor check
   * Returns status, response time, and optional message
   */
  handler: () => Promise<MonitorResult>;
}

Example

import { monitor } from "pongo";

export default monitor({
  name: "API Health",
  interval: "1m",
  async handler() {
    const start = Date.now();
    const res = await fetch("https://api.example.com/health");
    return {
      status: res.ok ? "up" : "down",
      responseTime: Date.now() - start,
      statusCode: res.status,
    };
  },
});

Build docs developers (and LLMs) love