Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495import { relations, sql } from "drizzle-orm";import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { monitorPeriodicity } from "../constants";import { monitorIncidentTable } from "../monitor_incidents/monitor_incident";import { monitorStatusTable } from "../monitor_status/monitor_status";import { monitorTagsToMonitors } from "../monitor_tags";import { notificationsToMonitors } from "../notifications";import { privateLocationToMonitors } from "../private_locations";import { workspace } from "../workspaces/workspace";import { grpcTlsModes, monitorJobTypes, monitorMethods, monitorStatus,} from "./constants";
export const monitor = sqliteTable( "monitor", { id: integer("id").primaryKey(), jobType: text("job_type", { enum: monitorJobTypes }) .default("http") .notNull(), periodicity: text("periodicity", { enum: monitorPeriodicity }) .default("other") .notNull(), status: text("status", { enum: monitorStatus }).default("active").notNull(), active: integer("active", { mode: "boolean" }).default(false),
regions: text("regions").default("").notNull(),
url: text("url", { length: 2048 }).notNull(), // URI
name: text("name", { length: 256 }).default("").notNull(), externalName: text("external_name"), description: text("description").default("").notNull(),
headers: text("headers").default(""), body: text("body").default(""), method: text("method", { enum: monitorMethods }).default("GET"), workspaceId: integer("workspace_id").references(() => workspace.id),
// Custom timeout for this monitor timeout: integer("timeout").notNull().default(45000), // in milliseconds
// Threshold for the monitor to be considered degraded degradedAfter: integer("degraded_after"), // in millisecond
assertions: text("assertions"),
otelEndpoint: text("otel_endpoint"),
otelHeaders: text("otel_headers"),
public: integer("public", { mode: "boolean" }).default(false),
retry: integer("retry").default(3),
followRedirects: integer("follow_redirects", { mode: "boolean" }).default( true, ),
grpcService: text("grpc_service"),
grpcTls: text("grpc_tls", { enum: grpcTlsModes }).default("tls"),
createdAt: integer("created_at", { mode: "timestamp" }).default( sql`(strftime('%s', 'now'))`, ), updatedAt: integer("updated_at", { mode: "timestamp" }).default( sql`(strftime('%s', 'now'))`, ),
deletedAt: integer("deleted_at", { mode: "timestamp" }), }, (t) => [ index("monitor_workspace_id_active_idx") .on(t.workspaceId) .where(sql`${t.deletedAt} IS NULL`), ],);
export const monitorRelation = relations(monitor, ({ one, many }) => ({ monitorTagsToMonitors: many(monitorTagsToMonitors), workspace: one(workspace, { fields: [monitor.workspaceId], references: [workspace.id], }), monitorsToNotifications: many(notificationsToMonitors), monitorIncidents: many(monitorIncidentTable), monitorStatus: many(monitorStatusTable), privateLocationToMonitors: many(privateLocationToMonitors),}));