Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
import { base } from "@openstatus/assertions";
import { z } from "zod";
import { MONITOR_METHODS, MONITOR_STATUSES } from "./constants";
export const httpPayloadSchema = z.object({
workspaceId: z.string(),
monitorId: z.string(),
method: z.enum(MONITOR_METHODS),
body: z.string().optional(),
headers: z.array(z.object({ key: z.string(), value: z.string() })).optional(),
url: z.string(),
cronTimestamp: z.number(),
status: z.enum(MONITOR_STATUSES),
assertions: z.array(base).nullable(),
timeout: z.number().prefault(45000),
degradedAfter: z.number().nullable(),
trigger: z.enum(["cron", "api"]).nullable().prefault("cron"),
otelConfig: z
.object({
endpoint: z.string(),
headers: z.record(z.string(), z.string()),
})
.optional(),
retry: z.number().prefault(3),
followRedirects: z.boolean().prefault(true),
});
export type HttpPayload = z.infer<typeof httpPayloadSchema>;
export const tpcPayloadSchema = z.object({
status: z.enum(MONITOR_STATUSES),
workspaceId: z.string(),
uri: z.string(),
monitorId: z.string(),
assertions: z.array(base).nullable(),
cronTimestamp: z.number(),
timeout: z.number().prefault(45000),
degradedAfter: z.number().nullable(),
trigger: z.enum(["cron", "api"]).nullable().prefault("cron"),
otelConfig: z
.object({
endpoint: z.string(),
headers: z.record(z.string(), z.string()),
})
.optional(),
retry: z.number().prefault(3),
});
export type TcpPayload = z.infer<typeof tpcPayloadSchema>;
export const DNSPayloadSchema = z.object({
status: z.enum(MONITOR_STATUSES),
workspaceId: z.string(),
uri: z.string(),
monitorId: z.string(),
assertions: z.array(base).nullable(),
cronTimestamp: z.number(),
timeout: z.number().prefault(45000),
degradedAfter: z.number().nullable(),
trigger: z.enum(["cron", "api"]).nullable().prefault("cron"),
otelConfig: z
.object({
endpoint: z.string(),
headers: z.record(z.string(), z.string()),
})
.optional(),
retry: z.number().prefault(3),
});
export type DNSPayload = z.infer<typeof DNSPayloadSchema>;
export const icmpPayloadSchema = z.object({
status: z.enum(MONITOR_STATUSES),
workspaceId: z.string(),
uri: z.string(),
monitorId: z.string(),
cronTimestamp: z.number(),
timeout: z.number().prefault(45000),
degradedAfter: z.number().nullable(),
trigger: z.enum(["cron", "api"]).nullable().prefault("cron"),
otelConfig: z
.object({
endpoint: z.string(),
headers: z.record(z.string(), z.string()),
})
.optional(),
retry: z.number().prefault(3),
});
export type IcmpPayload = z.infer<typeof icmpPayloadSchema>;
export const GRPC_TLS_MODES = ["plaintext", "tls", "tls_insecure"] as const;
export const grpcPayloadSchema = z.object({
status: z.enum(MONITOR_STATUSES),
workspaceId: z.string(),
uri: z.string(),
monitorId: z.string(),
service: z.string().optional(),
tls: z.enum(GRPC_TLS_MODES).prefault("tls"),
headers: z.record(z.string(), z.string()).optional(),
cronTimestamp: z.number(),
timeout: z.number().prefault(45000),
degradedAfter: z.number().nullable(),
trigger: z.enum(["cron", "api"]).nullable().prefault("cron"),
otelConfig: z
.object({
endpoint: z.string(),
headers: z.record(z.string(), z.string()),
})
.optional(),
retry: z.number().prefault(3),
});
export type GrpcPayload = z.infer<typeof grpcPayloadSchema>;