Skip to content

Open-source status page, incident response and uptime monitoring

πŸš€ Threshold monitor (#778)

Thibault Le Ouaydb163f6e5f49
diff --git a/apps/checker/cmd/main.go b/apps/checker/cmd/main.go
index bfe3c86bb..a5750deb1 100644
--- a/apps/checker/cmd/main.go
+++ b/apps/checker/cmd/main.go
@@ -95,7 +95,7 @@ func main() {
}
// We need a new client for each request to avoid connection reuse.
requestClient := &http.Client{
- Timeout: 45 * time.Second,
+ Timeout: time.Duration(req.Timeout) * time.Millisecond,
}
defer requestClient.CloseIdleConnections()
@@ -171,6 +171,7 @@ func main() {
}
res.Assertions = assertionAsString
+ // That part could be refactored
if !isSuccessfull && req.Status == "active" {
// Q: Why here we do not check if the status was previously active?
checker.UpdateStatus(ctx, checker.UpdateData{
@@ -182,8 +183,20 @@ func main() {
CronTimestamp: req.CronTimestamp,
})
}
-
- if req.Status == "error" && isSuccessfull {
+ // Check if the status is degraded
+ if isSuccessfull && req.Status == "active" {
+ if req.DegradedAfter > 0 && res.Latency > req.DegradedAfter {
+ checker.UpdateStatus(ctx, checker.UpdateData{
+ MonitorId: req.MonitorID,
+ Status: "degraded",
+ Region: flyRegion,
+ StatusCode: res.StatusCode,
+ CronTimestamp: req.CronTimestamp,
+ })
+ }
+ }
+ // We were in error and now we are successful don't check for degraded
+ if isSuccessfull && req.Status == "error" {
// Q: Why here we check the data before updating the status in this scenario?
checker.UpdateStatus(ctx, checker.UpdateData{
MonitorId: req.MonitorID,
@@ -193,6 +206,18 @@ func main() {
CronTimestamp: req.CronTimestamp,
})
}
+ // if we were in degraded and now we are successful, we should update the status to active
+ if isSuccessfull && req.Status == "degraded" {
+ if req.DegradedAfter > 0 && res.Latency <= req.DegradedAfter {
+ checker.UpdateStatus(ctx, checker.UpdateData{
+ MonitorId: req.MonitorID,
+ Status: "active",
+ Region: flyRegion,
+ StatusCode: res.StatusCode,
+ CronTimestamp: req.CronTimestamp,
+ })
+ }
+ }
if err := tinybirdClient.SendEvent(ctx, res, dataSourceName); err != nil {
log.Ctx(ctx).Error().Err(err).Msg("failed to send event to tinybird")
diff --git a/apps/checker/request/request.go b/apps/checker/request/request.go
index 6235227bf..5629a08f1 100644
--- a/apps/checker/request/request.go
+++ b/apps/checker/request/request.go
@@ -52,6 +52,8 @@ type CheckerRequest struct {
Method string `json:"method"`
CronTimestamp int64 `json:"cronTimestamp"`
Body string `json:"body"`
+ Timeout int64 `json:"timeout"`
+ DegradedAfter int64 `json:"degradedAfter,omitempty"`
Headers []struct {
Key string `json:"key"`
Value string `json:"value"`
diff --git a/apps/server/src/checker/alerting.ts b/apps/server/src/checker/alerting.ts
index a67fc172a..d0840604e 100644
--- a/apps/server/src/checker/alerting.ts
+++ b/apps/server/src/checker/alerting.ts
@@ -21,7 +21,7 @@ export const triggerNotifications = async ({
monitorId: string;
statusCode?: number;
message?: string;
- notifType: "alert" | "recovery";
+ notifType: "alert" | "recovery" | "degraded";
incidentId?: string;
}) => {
console.log(`πŸ’Œ triggerAlerting for ${monitorId}`);
@@ -62,6 +62,14 @@ export const triggerNotifications = async ({
incidentId,
});
break;
+ case "degraded":
+ await providerToFunction[notif.notification.provider].sendDegraded({
+ monitor,
+ notification: selectNotificationSchema.parse(notif.notification),
+ statusCode,
+ message,
+ });
+ break;
}
// ALPHA
await checkerAudit.publishAuditLog({
diff --git a/apps/server/src/checker/index.ts b/apps/server/src/checker/index.ts
index 8ccda2f6a..01b36ff4b 100644
--- a/apps/server/src/checker/index.ts
+++ b/apps/server/src/checker/index.ts
@@ -59,11 +59,52 @@ checkerRoute.post("/updateStatus", async (c) => {
and(
eq(incidentTable.monitorId, Number(monitorId)),
isNull(incidentTable.resolvedAt),
- isNull(incidentTable.acknowledgedAt),
- ),
+ isNull(incidentTable.acknowledgedAt)
+ )
)
.get();
+ if (status === "degraded") {
+ // We upsert the status of the monitor
+ await upsertMonitorStatus({
+ monitorId: monitorId,
+ status: "degraded",
+ region: region,
+ });
+ await checkerAudit.publishAuditLog({
+ id: `monitor:${monitorId}`,
+ action: "monitor.degraded",
+ targets: [{ id: monitorId, type: "monitor" }],
+ metadata: { region, statusCode: Number(statusCode) },
+ });
+ const currentMonitor = await db
+ .select()
+ .from(schema.monitor)
+ .where(eq(schema.monitor.id, Number(monitorId)))
+ .get();
+ if (currentMonitor?.status === "active") {
+ const redisKey = `${monitorId}-${cronTimestamp}-degraded`;
+ // We add the new region to the set
+ await redis.sadd(redisKey, region);
+ // let's add an expire to the set
+ await redis.expire(redisKey, 60 * 60 * 24);
+ // We get the number of regions affected
+ const nbAffectedRegion = await redis.scard(redisKey);
+
+ const monitor = selectMonitorSchema.parse(currentMonitor);
+
+ const numberOfRegions = monitor.regions.length;
+
+ if (nbAffectedRegion > numberOfRegions / 2) {
+ await triggerNotifications({
+ monitorId,
+ statusCode,
+ message,
+ notifType: "degraded",
+ });
+ }
+ }
+ }
// if we are in error
if (status === "error") {
// trigger alerting
@@ -100,7 +141,7 @@ checkerRoute.post("/updateStatus", async (c) => {
const numberOfRegions = monitor.regions.length;
console.log(
- `πŸ€“ MonitorID ${monitorId} incident current affected ${nbAffectedRegion} total region ${numberOfRegions}`,
+ `πŸ€“ MonitorID ${monitorId} incident current affected ${nbAffectedRegion} total region ${numberOfRegions}`
);
// If the number of affected regions is greater than half of the total region, we trigger the alerting
// 4 of 6 monitor need to fail to trigger an alerting
@@ -114,8 +155,8 @@ checkerRoute.post("/updateStatus", async (c) => {
eq(incidentTable.monitorId, Number(monitorId)),
isNull(incidentTable.resolvedAt),
isNull(incidentTable.acknowledgedAt),
- eq(incidentTable.startedAt, new Date(cronTimestamp)),
- ),
+ eq(incidentTable.startedAt, new Date(cronTimestamp))
+ )
)
.get();
@@ -192,7 +233,7 @@ checkerRoute.post("/updateStatus", async (c) => {
const numberOfRegions = monitor.regions.length;
console.log(
- `πŸ€“ MonitorId ${monitorId} recovering incident current ${nbAffectedRegion} total region ${numberOfRegions}`,
+ `πŸ€“ MonitorId ${monitorId} recovering incident current ${nbAffectedRegion} total region ${numberOfRegions}`
);
// // If the number of affected regions is greater than half of the total region, we trigger the alerting
// // 4 of 6 monitor need to fail to trigger an alerting
@@ -204,8 +245,8 @@ checkerRoute.post("/updateStatus", async (c) => {
and(
eq(incidentTable.monitorId, Number(monitorId)),
isNull(incidentTable.resolvedAt),
- isNull(incidentTable.acknowledgedAt),
- ),
+ isNull(incidentTable.acknowledgedAt)
+ )
)
.get();
if (incident) {
diff --git a/apps/server/src/checker/utils.ts b/apps/server/src/checker/utils.ts
index b9d3de05d..5e52b503a 100644
--- a/apps/server/src/checker/utils.ts
+++ b/apps/server/src/checker/utils.ts
@@ -6,23 +6,28 @@ import type {
import {
sendAlert as sendDiscordAlert,
sendRecovery as sendDiscordRecovery,
+ sendDegraded as sendDiscordDegraded,
} from "@openstatus/notification-discord";
import {
sendAlert as sendEmailAlert,
sendRecovery as sendEmailRecovery,
+ sendDegraded as sendEmailDegraded,
} from "@openstatus/notification-emails";
import {
sendAlert as sendSlackAlert,
sendRecovery as sendSlackRecovery,
+ sendDegraded as sendSlackDegraded,
} from "@openstatus/notification-slack";
import {
sendAlert as sendSmsAlert,
sendRecovery as sendSmsRecovery,
+ sendDegraded as sendSmsDegraded,
} from "@openstatus/notification-twillio-sms";
import {
sendAlert as sendPagerdutyAlert,
sendRecovery as sendPagerDutyRecovery,
+ sendDegraded as sendPagerDutyDegraded,
} from "@openstatus/notification-pagerduty";
type SendNotification = ({
@@ -42,20 +47,33 @@ type SendNotification = ({
type Notif = {
sendAlert: SendNotification;
sendRecovery: SendNotification;
+ sendDegraded: SendNotification;
};
export const providerToFunction = {
email: {
sendAlert: sendEmailAlert,
sendRecovery: sendEmailRecovery,
+ sendDegraded: sendEmailDegraded,
},
slack: {
sendAlert: sendSlackAlert,
sendRecovery: sendSlackRecovery,
+ sendDegraded: sendSlackDegraded,
},
- discord: { sendAlert: sendDiscordAlert, sendRecovery: sendDiscordRecovery },
- sms: { sendAlert: sendSmsAlert, sendRecovery: sendSmsRecovery },
+ discord: {
+ sendAlert: sendDiscordAlert,
+ sendRecovery: sendDiscordRecovery,
+ sendDegraded: sendDiscordDegraded,
+ },
+ sms: {
+ sendAlert: sendSmsAlert,
+ sendRecovery: sendSmsRecovery,
+ sendDegraded: sendSmsDegraded,
+ },
+
pagerduty: {
sendAlert: sendPagerdutyAlert,
sendRecovery: sendPagerDutyRecovery,
+ sendDegraded: sendPagerDutyDegraded,
},
} satisfies Record<NotificationProvider, Notif>;
diff --git a/apps/web/public/assets/changelog/monitor-threshold.png b/apps/web/public/assets/changelog/monitor-threshold.png
new file mode 100644
index 000000000..f118808ca
Binary files /dev/null and b/apps/web/public/assets/changelog/monitor-threshold.png differ
diff --git a/apps/web/src/app/api/checker/cron/_cron.ts b/apps/web/src/app/api/checker/cron/_cron.ts
index 7e75e9762..427342731 100644
--- a/apps/web/src/app/api/checker/cron/_cron.ts
+++ b/apps/web/src/app/api/checker/cron/_cron.ts
@@ -156,6 +156,8 @@ const createCronTask = async ({
headers: row.headers,
status: status,
assertions: row.assertions ? JSON.parse(row.assertions) : null,
+ degradedAfter: row.degradedAfter,
+ timeout: row.timeout,
};
const newTask: google.cloud.tasks.v2beta3.ITask = {
diff --git a/apps/web/src/app/api/checker/schema.ts b/apps/web/src/app/api/checker/schema.ts
index a6b05fe48..606075367 100644
--- a/apps/web/src/app/api/checker/schema.ts
+++ b/apps/web/src/app/api/checker/schema.ts
@@ -13,6 +13,8 @@ export const payloadSchema = z.object({
cronTimestamp: z.number(),
status: z.enum(monitorStatus),
assertions: z.array(base).nullable(),
+ timeout: z.number().default(45000),
+ degradedAfter: z.number().nullable(),
});
export type Payload = z.infer<typeof payloadSchema>;
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/edit/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/edit/page.tsx
index e468aadd0..e840616c3 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/edit/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/edit/page.tsx
@@ -36,15 +36,17 @@ export default async function EditPage({
defaultSection={search.success ? search.data.section : undefined}
defaultValues={{
...monitor,
+ // FIXME - Why is this not working?
+ degradedAfter: monitor.degradedAfter ?? undefined,
pages: pages
.filter((page) =>
- page.monitorsToPages.map(({ monitorId }) => monitorId).includes(id),
+ page.monitorsToPages.map(({ monitorId }) => monitorId).includes(id)
)
.map(({ id }) => id),
notifications: monitorNotifications?.map(({ id }) => id),
tags: tags
.filter((tag) =>
- tag.monitor.map(({ monitorId }) => monitorId).includes(id),
+ tag.monitor.map(({ monitorId }) => monitorId).includes(id)
)
.map(({ id }) => id),
}}
diff --git a/apps/web/src/components/content/changelog.tsx b/apps/web/src/components/content/changelog.tsx
index 55d643ca3..a4bf44cc5 100644
--- a/apps/web/src/components/content/changelog.tsx
+++ b/apps/web/src/components/content/changelog.tsx
@@ -12,12 +12,12 @@ export function ChangelogCard({ post }: { post: Changelog }) {
{formatDate(new Date(post.publishedAt))}
</p>
<h1 className="mb-5 font-cal text-3xl">{post.title}</h1>
- <div className="relative h-64 w-full overflow-hidden rounded-lg border border-border">
+ <div className="relative aspect-video w-full overflow-hidden rounded-lg border border-border">
<Image
src={post.image}
fill={true}
alt={post.title}
- className="object-cover"
+ className="object-contain"
/>
</div>
</div>
diff --git a/apps/web/src/components/forms/monitor/form.tsx b/apps/web/src/components/forms/monitor/form.tsx
index 246e979b6..1f5545b2a 100644
--- a/apps/web/src/components/forms/monitor/form.tsx
+++ b/apps/web/src/components/forms/monitor/form.tsx
@@ -29,7 +29,6 @@ import type { RegionChecker } from "@/components/ping-response-analysis/utils";
import { toast, toastAction } from "@/lib/toast";
import { formatDuration } from "@/lib/utils";
import { api } from "@/trpc/client";
-import type { Writeable } from "@/types/utils";
import { SaveButton } from "../shared/save-button";
import { General } from "./general";
import { RequestTestButton } from "./request-test-button";
@@ -87,6 +86,9 @@ export function MonitorForm({
statusAssertions: _assertions.filter((a) => a.type === "status") as any, // TS considers a.type === "header"
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
headerAssertions: _assertions.filter((a) => a.type === "header") as any, // TS considers a.type === "status"
+
+ degradedAfter: defaultValues?.degradedAfter,
+ timeout: defaultValues?.timeout || 45000,
},
});
const router = useRouter();
@@ -257,9 +259,9 @@ export function MonitorForm({
>
<TabsList>
<TabsTrigger value="request">Request</TabsTrigger>
- <TabsTrigger value="scheduling">Scheduling</TabsTrigger>
+ <TabsTrigger value="scheduling">Scheduling & Regions</TabsTrigger>
<TabsTrigger value="assertions">
- Assertions{" "}
+ Timing & Assertions{" "}
{_assertions.length ? (
<Badge variant="secondary" className="ml-1">
{_assertions.length}
diff --git a/apps/web/src/components/forms/monitor/section-assertions.tsx b/apps/web/src/components/forms/monitor/section-assertions.tsx
index 27fc12499..4795d65a1 100644
--- a/apps/web/src/components/forms/monitor/section-assertions.tsx
+++ b/apps/web/src/components/forms/monitor/section-assertions.tsx
@@ -13,8 +13,10 @@ import type { InsertMonitor } from "@openstatus/db/src/schema";
import {
Button,
FormControl,
+ FormDescription,
FormField,
FormItem,
+ FormLabel,
Input,
Select,
SelectContent,
@@ -53,6 +55,67 @@ export function SectionAssertions({ form }: Props) {
return (
<div className="grid w-full gap-4">
+ <SectionHeader
+ title="Timing Setting"
+ description={
+ <>
+ Add specific time limits to your requests to receive notifications
+ if an endpoint takes longer than expected.
+ </>
+ }
+ />
+ <div className="grid w-full gap-4 sm:grid-cols-6">
+ <FormField
+ control={form.control}
+ name="degradedAfter"
+ render={({ field }) => (
+ <FormItem className="col-span-6 sm:col-span-3">
+ <FormLabel>Degraded</FormLabel>
+ <FormControl>
+ <Input
+ className="bg-muted"
+ type="number"
+ min={0}
+ max={60000}
+ placeholder="30000"
+ {...form.register(field.name, {
+ setValueAs: (v) => (v === "" ? null : v),
+ })}
+ />
+ </FormControl>
+ <FormDescription>
+ In milliseconds, the time after which the endpoint is considered
+ degraded.
+ </FormDescription>
+ </FormItem>
+ )}
+ />
+ <FormField
+ control={form.control}
+ name="timeout"
+ render={({ field }) => (
+ <FormItem className="col-span-6 sm:col-span-3">
+ <FormLabel>Timeout</FormLabel>
+ <FormControl>
+ <Input
+ className="bg-muted"
+ type="number"
+ placeholder="45000"
+ min={0}
+ max={60000}
+ {...field}
+ />
+ </FormControl>
+ <FormDescription>
+ In milliseconds, the maximum time allowed for the request to
+ complete.
+ </FormDescription>
+
+ {/* <FormMessage /> */}
+ </FormItem>
+ )}
+ />
+ </div>
<SectionHeader
title="Assertions"
description={
diff --git a/apps/web/src/components/forms/monitor/section-requests.tsx b/apps/web/src/components/forms/monitor/section-requests.tsx
index e2f9e09d2..92c5099e1 100644
--- a/apps/web/src/components/forms/monitor/section-requests.tsx
+++ b/apps/web/src/components/forms/monitor/section-requests.tsx
@@ -111,7 +111,7 @@ export function SectionRequests({ form }: Props) {
control={form.control}
name="url"
render={({ field }) => (
- <FormItem className="sm:col-span-5">
+ <FormItem className="sm:col-span-6">
<FormLabel>URL</FormLabel>
<FormControl>
{/* <InputWithAddons
diff --git a/apps/web/src/components/monitor/status-dot-with-tooltip.tsx b/apps/web/src/components/monitor/status-dot-with-tooltip.tsx
index 7fcdc40ef..96fe414d9 100644
--- a/apps/web/src/components/monitor/status-dot-with-tooltip.tsx
+++ b/apps/web/src/components/monitor/status-dot-with-tooltip.tsx
@@ -23,6 +23,7 @@ export function StatusDotWithTooltip(props: StatusDotWithTooltipProps) {
if (!active) return "Monitor is inactive";
if (maintenance) return "Monitor in maintenance";
if (status === "error") return "Monitor has failed";
+ if (status === "degraded") return "Monitor is degraded";
return "Monitor is active";
})()}
</TooltipContent>
diff --git a/apps/web/src/components/monitor/status-dot.tsx b/apps/web/src/components/monitor/status-dot.tsx
index d77fe633c..f8ffc4ce4 100644
--- a/apps/web/src/components/monitor/status-dot.tsx
+++ b/apps/web/src/components/monitor/status-dot.tsx
@@ -30,6 +30,14 @@ export function StatusDot({ active, status, maintenance }: StatusDotProps) {
</span>
);
}
+ if (status === "degraded") {
+ return (
+ <span className="relative flex h-2 w-2">
+ <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-yellow-500/80 opacity-75 duration-[2000ms]" />
+ <span className="relative inline-flex h-2 w-2 rounded-full bg-yellow-500" />
+ </span>
+ );
+ }
return (
<span className="relative flex h-2 w-2">
diff --git a/apps/web/src/content/changelog/monitor-threshold.mdx b/apps/web/src/content/changelog/monitor-threshold.mdx
new file mode 100644
index 000000000..58e08a1b1
--- /dev/null
+++ b/apps/web/src/content/changelog/monitor-threshold.mdx
@@ -0,0 +1,12 @@
+---
+title: Monitor Threshold
+description: Set custom request timeouts and degradation timing.
+image: /assets/changelog/monitor-threshold.png
+publishedAt: 2024-07-01
+---
+Sometimes you need to get notified if your monitor is taking too long to respond or if it's degrading.
+
+You can set custom request timeouts and degradation timing for your monitors.
+
+We have added this feature to the monitor settings.
+
diff --git a/packages/db/drizzle/0033_solid_colossus.sql b/packages/db/drizzle/0033_solid_colossus.sql
new file mode 100644
index 000000000..697eca74a
--- /dev/null
+++ b/packages/db/drizzle/0033_solid_colossus.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `monitor` ADD `timeout` integer DEFAULT 45000 NOT NULL;--> statement-breakpoint
+ALTER TABLE `monitor` ADD `degraded_after` integer;
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0025_snapshot.json b/packages/db/drizzle/meta/0025_snapshot.json
index bc91be730..867541384 100644
--- a/packages/db/drizzle/meta/0025_snapshot.json
+++ b/packages/db/drizzle/meta/0025_snapshot.json
@@ -33,36 +33,25 @@
"status_report_to_monitors_monitor_id_monitor_id_fk": {
"name": "status_report_to_monitors_monitor_id_monitor_id_fk",
"tableFrom": "status_report_to_monitors",
- "columnsFrom": [
- "monitor_id"
- ],
+ "columnsFrom": ["monitor_id"],
"tableTo": "monitor",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
},
"status_report_to_monitors_status_report_id_status_report_id_fk": {
"name": "status_report_to_monitors_status_report_id_status_report_id_fk",
"tableFrom": "status_report_to_monitors",
- "columnsFrom": [
- "status_report_id"
- ],
+ "columnsFrom": ["status_report_id"],
"tableTo": "status_report",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
}
},
"compositePrimaryKeys": {
"status_report_to_monitors_monitor_id_status_report_id_pk": {
- "columns": [
- "monitor_id",
- "status_report_id"
- ],
+ "columns": ["monitor_id", "status_report_id"],
"name": "status_report_to_monitors_monitor_id_status_report_id_pk"
}
},
@@ -99,36 +88,25 @@
"status_reports_to_pages_page_id_page_id_fk": {
"name": "status_reports_to_pages_page_id_page_id_fk",
"tableFrom": "status_reports_to_pages",
- "columnsFrom": [
- "page_id"
- ],
+ "columnsFrom": ["page_id"],
"tableTo": "page",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
},
"status_reports_to_pages_status_report_id_status_report_id_fk": {
"name": "status_reports_to_pages_status_report_id_status_report_id_fk",
"tableFrom": "status_reports_to_pages",
- "columnsFrom": [
- "status_report_id"
- ],
+ "columnsFrom": ["status_report_id"],
"tableTo": "status_report",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
}
},
"compositePrimaryKeys": {
"status_reports_to_pages_page_id_status_report_id_pk": {
- "columns": [
- "page_id",
- "status_report_id"
- ],
+ "columns": ["page_id", "status_report_id"],
"name": "status_reports_to_pages_page_id_status_report_id_pk"
}
},
@@ -187,13 +165,9 @@
"status_report_workspace_id_workspace_id_fk": {
"name": "status_report_workspace_id_workspace_id_fk",
"tableFrom": "status_report",
- "columnsFrom": [
- "workspace_id"
- ],
+ "columnsFrom": ["workspace_id"],
"tableTo": "workspace",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "no action"
}
@@ -261,13 +235,9 @@
"status_report_update_status_report_id_status_report_id_fk": {
"name": "status_report_update_status_report_id_status_report_id_fk",
"tableFrom": "status_report_update",
- "columnsFrom": [
- "status_report_id"
- ],
+ "columnsFrom": ["status_report_id"],
"tableTo": "status_report",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
}
@@ -342,13 +312,9 @@
"integration_workspace_id_workspace_id_fk": {
"name": "integration_workspace_id_workspace_id_fk",
"tableFrom": "integration",
- "columnsFrom": [
- "workspace_id"
- ],
+ "columnsFrom": ["workspace_id"],
"tableTo": "workspace",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "no action"
}
@@ -437,9 +403,7 @@
"indexes": {
"page_slug_unique": {
"name": "page_slug_unique",
- "columns": [
- "slug"
- ],
+ "columns": ["slug"],
"isUnique": true
}
},
@@ -447,13 +411,9 @@
"page_workspace_id_workspace_id_fk": {
"name": "page_workspace_id_workspace_id_fk",
"tableFrom": "page",
- "columnsFrom": [
- "workspace_id"
- ],
+ "columnsFrom": ["workspace_id"],
"tableTo": "workspace",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
}
@@ -609,13 +569,9 @@
"monitor_workspace_id_workspace_id_fk": {
"name": "monitor_workspace_id_workspace_id_fk",
"tableFrom": "monitor",
- "columnsFrom": [
- "workspace_id"
- ],
+ "columnsFrom": ["workspace_id"],
"tableTo": "workspace",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "no action"
}
@@ -654,36 +610,25 @@
"monitors_to_pages_monitor_id_monitor_id_fk": {
"name": "monitors_to_pages_monitor_id_monitor_id_fk",
"tableFrom": "monitors_to_pages",
- "columnsFrom": [
- "monitor_id"
- ],
+ "columnsFrom": ["monitor_id"],
"tableTo": "monitor",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
},
"monitors_to_pages_page_id_page_id_fk": {
"name": "monitors_to_pages_page_id_page_id_fk",
"tableFrom": "monitors_to_pages",
- "columnsFrom": [
- "page_id"
- ],
+ "columnsFrom": ["page_id"],
"tableTo": "page",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
}
},
"compositePrimaryKeys": {
"monitors_to_pages_monitor_id_page_id_pk": {
- "columns": [
- "monitor_id",
- "page_id"
- ],
+ "columns": ["monitor_id", "page_id"],
"name": "monitors_to_pages_monitor_id_page_id_pk"
}
},
@@ -758,9 +703,7 @@
"indexes": {
"user_tenant_id_unique": {
"name": "user_tenant_id_unique",
- "columns": [
- "tenant_id"
- ],
+ "columns": ["tenant_id"],
"isUnique": true
}
},
@@ -807,36 +750,25 @@
"users_to_workspaces_user_id_user_id_fk": {
"name": "users_to_workspaces_user_id_user_id_fk",
"tableFrom": "users_to_workspaces",
- "columnsFrom": [
- "user_id"
- ],
+ "columnsFrom": ["user_id"],
"tableTo": "user",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "no action"
},
"users_to_workspaces_workspace_id_workspace_id_fk": {
"name": "users_to_workspaces_workspace_id_workspace_id_fk",
"tableFrom": "users_to_workspaces",
- "columnsFrom": [
- "workspace_id"
- ],
+ "columnsFrom": ["workspace_id"],
"tableTo": "workspace",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "no action"
}
},
"compositePrimaryKeys": {
"users_to_workspaces_user_id_workspace_id_pk": {
- "columns": [
- "user_id",
- "workspace_id"
- ],
+ "columns": ["user_id", "workspace_id"],
"name": "users_to_workspaces_user_id_workspace_id_pk"
}
},
@@ -909,13 +841,9 @@
"page_subscriber_page_id_page_id_fk": {
"name": "page_subscriber_page_id_page_id_fk",
"tableFrom": "page_subscriber",
- "columnsFrom": [
- "page_id"
- ],
+ "columnsFrom": ["page_id"],
"tableTo": "page",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "no action"
}
@@ -1002,16 +930,12 @@
"indexes": {
"workspace_slug_unique": {
"name": "workspace_slug_unique",
- "columns": [
- "slug"
- ],
+ "columns": ["slug"],
"isUnique": true
},
"workspace_stripe_id_unique": {
"name": "workspace_stripe_id_unique",
- "columns": [
- "stripe_id"
- ],
+ "columns": ["stripe_id"],
"isUnique": true
}
},
@@ -1080,13 +1004,9 @@
"notification_workspace_id_workspace_id_fk": {
"name": "notification_workspace_id_workspace_id_fk",
"tableFrom": "notification",
- "columnsFrom": [
- "workspace_id"
- ],
+ "columnsFrom": ["workspace_id"],
"tableTo": "workspace",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "no action"
}
@@ -1125,36 +1045,25 @@
"notifications_to_monitors_monitor_id_monitor_id_fk": {
"name": "notifications_to_monitors_monitor_id_monitor_id_fk",
"tableFrom": "notifications_to_monitors",
- "columnsFrom": [
- "monitor_id"
- ],
+ "columnsFrom": ["monitor_id"],
"tableTo": "monitor",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
},
"notifications_to_monitors_notification_id_notification_id_fk": {
"name": "notifications_to_monitors_notification_id_notification_id_fk",
"tableFrom": "notifications_to_monitors",
- "columnsFrom": [
- "notification_id"
- ],
+ "columnsFrom": ["notification_id"],
"tableTo": "notification",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
}
},
"compositePrimaryKeys": {
"notifications_to_monitors_monitor_id_notification_id_pk": {
- "columns": [
- "monitor_id",
- "notification_id"
- ],
+ "columns": ["monitor_id", "notification_id"],
"name": "notifications_to_monitors_monitor_id_notification_id_pk"
}
},
@@ -1206,10 +1115,7 @@
"indexes": {
"monitor_status_idx": {
"name": "monitor_status_idx",
- "columns": [
- "monitor_id",
- "region"
- ],
+ "columns": ["monitor_id", "region"],
"isUnique": false
}
},
@@ -1217,23 +1123,16 @@
"monitor_status_monitor_id_monitor_id_fk": {
"name": "monitor_status_monitor_id_monitor_id_fk",
"tableFrom": "monitor_status",
- "columnsFrom": [
- "monitor_id"
- ],
+ "columnsFrom": ["monitor_id"],
"tableTo": "monitor",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
}
},
"compositePrimaryKeys": {
"monitor_status_monitor_id_region_pk": {
- "columns": [
- "monitor_id",
- "region"
- ],
+ "columns": ["monitor_id", "region"],
"name": "monitor_status_monitor_id_region_pk"
}
},
@@ -1432,10 +1331,7 @@
"indexes": {
"incident_monitor_id_started_at_unique": {
"name": "incident_monitor_id_started_at_unique",
- "columns": [
- "monitor_id",
- "started_at"
- ],
+ "columns": ["monitor_id", "started_at"],
"isUnique": true
}
},
@@ -1443,52 +1339,36 @@
"incident_monitor_id_monitor_id_fk": {
"name": "incident_monitor_id_monitor_id_fk",
"tableFrom": "incident",
- "columnsFrom": [
- "monitor_id"
- ],
+ "columnsFrom": ["monitor_id"],
"tableTo": "monitor",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "set default"
},
"incident_workspace_id_workspace_id_fk": {
"name": "incident_workspace_id_workspace_id_fk",
"tableFrom": "incident",
- "columnsFrom": [
- "workspace_id"
- ],
+ "columnsFrom": ["workspace_id"],
"tableTo": "workspace",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "no action"
},
"incident_acknowledged_by_user_id_fk": {
"name": "incident_acknowledged_by_user_id_fk",
"tableFrom": "incident",
- "columnsFrom": [
- "acknowledged_by"
- ],
+ "columnsFrom": ["acknowledged_by"],
"tableTo": "user",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "no action"
},
"incident_resolved_by_user_id_fk": {
"name": "incident_resolved_by_user_id_fk",
"tableFrom": "incident",
- "columnsFrom": [
- "resolved_by"
- ],
+ "columnsFrom": ["resolved_by"],
"tableTo": "user",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "no action"
}
@@ -1549,13 +1429,9 @@
"monitor_tag_workspace_id_workspace_id_fk": {
"name": "monitor_tag_workspace_id_workspace_id_fk",
"tableFrom": "monitor_tag",
- "columnsFrom": [
- "workspace_id"
- ],
+ "columnsFrom": ["workspace_id"],
"tableTo": "workspace",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
}
@@ -1594,36 +1470,25 @@
"monitor_tag_to_monitor_monitor_id_monitor_id_fk": {
"name": "monitor_tag_to_monitor_monitor_id_monitor_id_fk",
"tableFrom": "monitor_tag_to_monitor",
- "columnsFrom": [
- "monitor_id"
- ],
+ "columnsFrom": ["monitor_id"],
"tableTo": "monitor",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
},
"monitor_tag_to_monitor_monitor_tag_id_monitor_tag_id_fk": {
"name": "monitor_tag_to_monitor_monitor_tag_id_monitor_tag_id_fk",
"tableFrom": "monitor_tag_to_monitor",
- "columnsFrom": [
- "monitor_tag_id"
- ],
+ "columnsFrom": ["monitor_tag_id"],
"tableTo": "monitor_tag",
- "columnsTo": [
- "id"
- ],
+ "columnsTo": ["id"],
"onUpdate": "no action",
"onDelete": "cascade"
}
},
"compositePrimaryKeys": {
"monitor_tag_to_monitor_monitor_id_monitor_tag_id_pk": {
- "columns": [
- "monitor_id",
- "monitor_tag_id"
- ],
+ "columns": ["monitor_id", "monitor_tag_id"],
"name": "monitor_tag_to_monitor_monitor_id_monitor_tag_id_pk"
}
},
@@ -1637,4 +1502,4 @@
},
"id": "40ddc769-9652-470e-87af-71f269131bc3",
"prevId": "96f82403-94f3-49fd-871b-946bc0a687f2"
-}
\ No newline at end of file
+}
diff --git a/packages/db/drizzle/meta/0033_snapshot.json b/packages/db/drizzle/meta/0033_snapshot.json
new file mode 100644
index 000000000..435a846ab
--- /dev/null
+++ b/packages/db/drizzle/meta/0033_snapshot.json
@@ -0,0 +1,2051 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "447f81c0-1837-4e85-bb0e-9ecce75e95d9",
+ "prevId": "de3d58e5-d801-4b9e-a35a-39cfc09b7807",
+ "tables": {
+ "status_report_to_monitors": {
+ "name": "status_report_to_monitors",
+ "columns": {
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status_report_id": {
+ "name": "status_report_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "status_report_to_monitors_monitor_id_monitor_id_fk": {
+ "name": "status_report_to_monitors_monitor_id_monitor_id_fk",
+ "tableFrom": "status_report_to_monitors",
+ "tableTo": "monitor",
+ "columnsFrom": ["monitor_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "status_report_to_monitors_status_report_id_status_report_id_fk": {
+ "name": "status_report_to_monitors_status_report_id_status_report_id_fk",
+ "tableFrom": "status_report_to_monitors",
+ "tableTo": "status_report",
+ "columnsFrom": ["status_report_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "status_report_to_monitors_monitor_id_status_report_id_pk": {
+ "columns": ["monitor_id", "status_report_id"],
+ "name": "status_report_to_monitors_monitor_id_status_report_id_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "status_reports_to_pages": {
+ "name": "status_reports_to_pages",
+ "columns": {
+ "page_id": {
+ "name": "page_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status_report_id": {
+ "name": "status_report_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "status_reports_to_pages_page_id_page_id_fk": {
+ "name": "status_reports_to_pages_page_id_page_id_fk",
+ "tableFrom": "status_reports_to_pages",
+ "tableTo": "page",
+ "columnsFrom": ["page_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "status_reports_to_pages_status_report_id_status_report_id_fk": {
+ "name": "status_reports_to_pages_status_report_id_status_report_id_fk",
+ "tableFrom": "status_reports_to_pages",
+ "tableTo": "status_report",
+ "columnsFrom": ["status_report_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "status_reports_to_pages_page_id_status_report_id_pk": {
+ "columns": ["page_id", "status_report_id"],
+ "name": "status_reports_to_pages_page_id_status_report_id_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "status_report": {
+ "name": "status_report",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "status_report_workspace_id_workspace_id_fk": {
+ "name": "status_report_workspace_id_workspace_id_fk",
+ "tableFrom": "status_report",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "status_report_update": {
+ "name": "status_report_update",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text(4)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "date": {
+ "name": "date",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status_report_id": {
+ "name": "status_report_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "status_report_update_status_report_id_status_report_id_fk": {
+ "name": "status_report_update_status_report_id_status_report_id_fk",
+ "tableFrom": "status_report_update",
+ "tableTo": "status_report",
+ "columnsFrom": ["status_report_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "integration": {
+ "name": "integration",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "credential": {
+ "name": "credential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "data": {
+ "name": "data",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "integration_workspace_id_workspace_id_fk": {
+ "name": "integration_workspace_id_workspace_id_fk",
+ "tableFrom": "integration",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "page": {
+ "name": "page",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "custom_domain": {
+ "name": "custom_domain",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "published": {
+ "name": "published",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "password_protected": {
+ "name": "password_protected",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "page_slug_unique": {
+ "name": "page_slug_unique",
+ "columns": ["slug"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "page_workspace_id_workspace_id_fk": {
+ "name": "page_workspace_id_workspace_id_fk",
+ "tableFrom": "page",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "monitor": {
+ "name": "monitor",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "job_type": {
+ "name": "job_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'other'"
+ },
+ "periodicity": {
+ "name": "periodicity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'other'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'active'"
+ },
+ "active": {
+ "name": "active",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "regions": {
+ "name": "regions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "url": {
+ "name": "url",
+ "type": "text(2048)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "headers": {
+ "name": "headers",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "method": {
+ "name": "method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'GET'"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "timeout": {
+ "name": "timeout",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 45000
+ },
+ "degraded_after": {
+ "name": "degraded_after",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "assertions": {
+ "name": "assertions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "public": {
+ "name": "public",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "monitor_workspace_id_workspace_id_fk": {
+ "name": "monitor_workspace_id_workspace_id_fk",
+ "tableFrom": "monitor",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "monitors_to_pages": {
+ "name": "monitors_to_pages",
+ "columns": {
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "order": {
+ "name": "order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "monitors_to_pages_monitor_id_monitor_id_fk": {
+ "name": "monitors_to_pages_monitor_id_monitor_id_fk",
+ "tableFrom": "monitors_to_pages",
+ "tableTo": "monitor",
+ "columnsFrom": ["monitor_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "monitors_to_pages_page_id_page_id_fk": {
+ "name": "monitors_to_pages_page_id_page_id_fk",
+ "tableFrom": "monitors_to_pages",
+ "tableTo": "page",
+ "columnsFrom": ["page_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "monitors_to_pages_monitor_id_page_id_pk": {
+ "columns": ["monitor_id", "page_id"],
+ "name": "monitors_to_pages_monitor_id_page_id_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "account": {
+ "name": "account",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider_account_id": {
+ "name": "provider_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_provider_account_id_pk": {
+ "columns": ["provider", "provider_account_id"],
+ "name": "account_provider_provider_account_id_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "session": {
+ "name": "session",
+ "columns": {
+ "session_token": {
+ "name": "session_token",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "user": {
+ "name": "user",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tenant_id": {
+ "name": "tenant_id",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "photo_url": {
+ "name": "photo_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "user_tenant_id_unique": {
+ "name": "user_tenant_id_unique",
+ "columns": ["tenant_id"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "users_to_workspaces": {
+ "name": "users_to_workspaces",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'member'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "users_to_workspaces_user_id_user_id_fk": {
+ "name": "users_to_workspaces_user_id_user_id_fk",
+ "tableFrom": "users_to_workspaces",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "users_to_workspaces_workspace_id_workspace_id_fk": {
+ "name": "users_to_workspaces_workspace_id_workspace_id_fk",
+ "tableFrom": "users_to_workspaces",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "users_to_workspaces_user_id_workspace_id_pk": {
+ "columns": ["user_id", "workspace_id"],
+ "name": "users_to_workspaces_user_id_workspace_id_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "verification_token": {
+ "name": "verification_token",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verification_token_identifier_token_pk": {
+ "columns": ["identifier", "token"],
+ "name": "verification_token_identifier_token_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "page_subscriber": {
+ "name": "page_subscriber",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "page_subscriber_page_id_page_id_fk": {
+ "name": "page_subscriber_page_id_page_id_fk",
+ "tableFrom": "page_subscriber",
+ "tableTo": "page",
+ "columnsFrom": ["page_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "workspace": {
+ "name": "workspace",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stripe_id": {
+ "name": "stripe_id",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "plan": {
+ "name": "plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ends_at": {
+ "name": "ends_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "paid_until": {
+ "name": "paid_until",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "dsn": {
+ "name": "dsn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "workspace_slug_unique": {
+ "name": "workspace_slug_unique",
+ "columns": ["slug"],
+ "isUnique": true
+ },
+ "workspace_stripe_id_unique": {
+ "name": "workspace_stripe_id_unique",
+ "columns": ["stripe_id"],
+ "isUnique": true
+ },
+ "workspace_id_dsn_unique": {
+ "name": "workspace_id_dsn_unique",
+ "columns": ["id", "dsn"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "notification": {
+ "name": "notification",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "data": {
+ "name": "data",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'{}'"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "notification_workspace_id_workspace_id_fk": {
+ "name": "notification_workspace_id_workspace_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "notifications_to_monitors": {
+ "name": "notifications_to_monitors",
+ "columns": {
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "notification_id": {
+ "name": "notification_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "notifications_to_monitors_monitor_id_monitor_id_fk": {
+ "name": "notifications_to_monitors_monitor_id_monitor_id_fk",
+ "tableFrom": "notifications_to_monitors",
+ "tableTo": "monitor",
+ "columnsFrom": ["monitor_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notifications_to_monitors_notification_id_notification_id_fk": {
+ "name": "notifications_to_monitors_notification_id_notification_id_fk",
+ "tableFrom": "notifications_to_monitors",
+ "tableTo": "notification",
+ "columnsFrom": ["notification_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "notifications_to_monitors_monitor_id_notification_id_pk": {
+ "columns": ["monitor_id", "notification_id"],
+ "name": "notifications_to_monitors_monitor_id_notification_id_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "monitor_status": {
+ "name": "monitor_status",
+ "columns": {
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "region": {
+ "name": "region",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'active'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "monitor_status_idx": {
+ "name": "monitor_status_idx",
+ "columns": ["monitor_id", "region"],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "monitor_status_monitor_id_monitor_id_fk": {
+ "name": "monitor_status_monitor_id_monitor_id_fk",
+ "tableFrom": "monitor_status",
+ "tableTo": "monitor",
+ "columnsFrom": ["monitor_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "monitor_status_monitor_id_region_pk": {
+ "columns": ["monitor_id", "region"],
+ "name": "monitor_status_monitor_id_region_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "invitation": {
+ "name": "invitation",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'member'"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "incident": {
+ "name": "incident",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'triage'"
+ },
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "acknowledged_at": {
+ "name": "acknowledged_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "acknowledged_by": {
+ "name": "acknowledged_by",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "resolved_by": {
+ "name": "resolved_by",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "incident_screenshot_url": {
+ "name": "incident_screenshot_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "recovery_screenshot_url": {
+ "name": "recovery_screenshot_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "auto_resolved": {
+ "name": "auto_resolved",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "incident_monitor_id_started_at_unique": {
+ "name": "incident_monitor_id_started_at_unique",
+ "columns": ["monitor_id", "started_at"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "incident_monitor_id_monitor_id_fk": {
+ "name": "incident_monitor_id_monitor_id_fk",
+ "tableFrom": "incident",
+ "tableTo": "monitor",
+ "columnsFrom": ["monitor_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set default",
+ "onUpdate": "no action"
+ },
+ "incident_workspace_id_workspace_id_fk": {
+ "name": "incident_workspace_id_workspace_id_fk",
+ "tableFrom": "incident",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "incident_acknowledged_by_user_id_fk": {
+ "name": "incident_acknowledged_by_user_id_fk",
+ "tableFrom": "incident",
+ "tableTo": "user",
+ "columnsFrom": ["acknowledged_by"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "incident_resolved_by_user_id_fk": {
+ "name": "incident_resolved_by_user_id_fk",
+ "tableFrom": "incident",
+ "tableTo": "user",
+ "columnsFrom": ["resolved_by"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "monitor_tag": {
+ "name": "monitor_tag",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "monitor_tag_workspace_id_workspace_id_fk": {
+ "name": "monitor_tag_workspace_id_workspace_id_fk",
+ "tableFrom": "monitor_tag",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "monitor_tag_to_monitor": {
+ "name": "monitor_tag_to_monitor",
+ "columns": {
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "monitor_tag_id": {
+ "name": "monitor_tag_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "monitor_tag_to_monitor_monitor_id_monitor_id_fk": {
+ "name": "monitor_tag_to_monitor_monitor_id_monitor_id_fk",
+ "tableFrom": "monitor_tag_to_monitor",
+ "tableTo": "monitor",
+ "columnsFrom": ["monitor_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "monitor_tag_to_monitor_monitor_tag_id_monitor_tag_id_fk": {
+ "name": "monitor_tag_to_monitor_monitor_tag_id_monitor_tag_id_fk",
+ "tableFrom": "monitor_tag_to_monitor",
+ "tableTo": "monitor_tag",
+ "columnsFrom": ["monitor_tag_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "monitor_tag_to_monitor_monitor_id_monitor_tag_id_pk": {
+ "columns": ["monitor_id", "monitor_tag_id"],
+ "name": "monitor_tag_to_monitor_monitor_id_monitor_tag_id_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "application": {
+ "name": "application",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "dsn": {
+ "name": "dsn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "application_dsn_unique": {
+ "name": "application_dsn_unique",
+ "columns": ["dsn"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "application_workspace_id_workspace_id_fk": {
+ "name": "application_workspace_id_workspace_id_fk",
+ "tableFrom": "application",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "maintenance": {
+ "name": "maintenance",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "from": {
+ "name": "from",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "to": {
+ "name": "to",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "maintenance_workspace_id_workspace_id_fk": {
+ "name": "maintenance_workspace_id_workspace_id_fk",
+ "tableFrom": "maintenance",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "maintenance_page_id_page_id_fk": {
+ "name": "maintenance_page_id_page_id_fk",
+ "tableFrom": "maintenance",
+ "tableTo": "page",
+ "columnsFrom": ["page_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "maintenance_to_monitor": {
+ "name": "maintenance_to_monitor",
+ "columns": {
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "maintenance_id": {
+ "name": "maintenance_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "maintenance_to_monitor_monitor_id_monitor_id_fk": {
+ "name": "maintenance_to_monitor_monitor_id_monitor_id_fk",
+ "tableFrom": "maintenance_to_monitor",
+ "tableTo": "monitor",
+ "columnsFrom": ["monitor_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "maintenance_to_monitor_maintenance_id_maintenance_id_fk": {
+ "name": "maintenance_to_monitor_maintenance_id_maintenance_id_fk",
+ "tableFrom": "maintenance_to_monitor",
+ "tableTo": "maintenance",
+ "columnsFrom": ["maintenance_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "maintenance_to_monitor_monitor_id_maintenance_id_pk": {
+ "columns": ["maintenance_id", "monitor_id"],
+ "name": "maintenance_to_monitor_monitor_id_maintenance_id_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "check": {
+ "name": "check",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "regions": {
+ "name": "regions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "url": {
+ "name": "url",
+ "type": "text(4096)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "headers": {
+ "name": "headers",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "method": {
+ "name": "method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'GET'"
+ },
+ "count_requests": {
+ "name": "count_requests",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 1
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "check_workspace_id_workspace_id_fk": {
+ "name": "check_workspace_id_workspace_id_fk",
+ "tableFrom": "check",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ }
+ },
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ }
+}
diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json
index 38c93e0d7..a4ccd2c34 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -232,6 +232,13 @@
"when": 1718027484219,
"tag": "0032_hot_swordsman",
"breakpoints": true
+ },
+ {
+ "idx": 33,
+ "version": "6",
+ "when": 1719740057514,
+ "tag": "0033_solid_colossus",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/src/schema/monitors/constants.ts b/packages/db/src/schema/monitors/constants.ts
index 3e98e3490..2b06c9b9f 100644
--- a/packages/db/src/schema/monitors/constants.ts
+++ b/packages/db/src/schema/monitors/constants.ts
@@ -46,7 +46,7 @@ export const monitorPeriodicity = [
"other",
] as const;
export const monitorMethods = ["GET", "POST", "HEAD"] as const;
-export const monitorStatus = ["active", "error"] as const;
+export const monitorStatus = ["active", "error", "degraded"] as const;
export const monitorRegions = [...flyRegions] as const;
export const monitorJobTypes = ["website", "cron", "other"] as const;
diff --git a/packages/db/src/schema/monitors/monitor.ts b/packages/db/src/schema/monitors/monitor.ts
index 7ced1b6cc..047b18652 100644
--- a/packages/db/src/schema/monitors/monitor.ts
+++ b/packages/db/src/schema/monitors/monitor.ts
@@ -42,15 +42,21 @@ export const monitor = sqliteTable("monitor", {
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"),
public: integer("public", { mode: "boolean" }).default(false),
createdAt: integer("created_at", { mode: "timestamp" }).default(
- sql`(strftime('%s', 'now'))`,
+ sql`(strftime('%s', 'now'))`
),
updatedAt: integer("updated_at", { mode: "timestamp" }).default(
- sql`(strftime('%s', 'now'))`,
+ sql`(strftime('%s', 'now'))`
),
deletedAt: integer("deleted_at", { mode: "timestamp" }),
@@ -78,13 +84,13 @@ export const monitorsToPages = sqliteTable(
.notNull()
.references(() => page.id, { onDelete: "cascade" }),
createdAt: integer("created_at", { mode: "timestamp" }).default(
- sql`(strftime('%s', 'now'))`,
+ sql`(strftime('%s', 'now'))`
),
order: integer("order").default(0),
},
(t) => ({
pk: primaryKey(t.monitorId, t.pageId),
- }),
+ })
);
export const monitorsToPagesRelation = relations(
@@ -98,5 +104,5 @@ export const monitorsToPagesRelation = relations(
fields: [monitorsToPages.pageId],
references: [page.id],
}),
- }),
+ })
);
diff --git a/packages/db/src/schema/monitors/validation.ts b/packages/db/src/schema/monitors/validation.ts
index a03a166d9..035841a24 100644
--- a/packages/db/src/schema/monitors/validation.ts
+++ b/packages/db/src/schema/monitors/validation.ts
@@ -50,6 +50,7 @@ export const selectMonitorSchema = createSelectSchema(monitor, {
periodicity: monitorPeriodicitySchema.default("10m"),
status: monitorStatusSchema.default("active"),
jobType: monitorJobTypesSchema.default("other"),
+ timeout: z.number().default(45),
regions: regionsToArraySchema.default([]),
}).extend({
headers: headersToArraySchema.default([]),
@@ -76,6 +77,8 @@ export const insertMonitorSchema = createInsertSchema(monitor, {
statusAssertions: z.array(assertions.statusAssertion).optional(),
headerAssertions: z.array(assertions.headerAssertion).optional(),
textBodyAssertions: z.array(assertions.textBodyAssertion).optional(),
+ timeout: z.coerce.number().gte(0).lte(60000).default(45000),
+ degradedAfter: z.coerce.number().gte(0).lte(60000).nullish(),
});
export const selectMonitorToPageSchema = createSelectSchema(monitorsToPages);
diff --git a/packages/notifications/discord/src/index.ts b/packages/notifications/discord/src/index.ts
index b4184ce63..d8209c470 100644
--- a/packages/notifications/discord/src/index.ts
+++ b/packages/notifications/discord/src/index.ts
@@ -78,6 +78,37 @@ export const sendRecovery = async ({
}
};
+export const sendDegraded = async ({
+ monitor,
+ notification,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ statusCode,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ message,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ incidentId,
+}: {
+ monitor: Monitor;
+ notification: Notification;
+ statusCode?: number;
+ message?: string;
+ incidentId?: string;
+}) => {
+ const notificationData = JSON.parse(notification.data);
+ const { discord: webhookUrl } = notificationData; // webhook url
+ const { name } = monitor;
+
+ try {
+ await postToWebhook(
+ `Your monitor ${name}|${monitor.url} is degraded ⚠️`,
+ webhookUrl
+ );
+ } catch (err) {
+ console.error(err);
+ // Do something
+ }
+};
+
export const sendTestDiscordMessage = async (webhookUrl: string) => {
if (!webhookUrl) {
return false;
diff --git a/packages/notifications/email/src/index.ts b/packages/notifications/email/src/index.ts
index 82f9b98eb..14a65e560 100644
--- a/packages/notifications/email/src/index.ts
+++ b/packages/notifications/email/src/index.ts
@@ -96,3 +96,45 @@ export const sendRecovery = async ({
console.log(`Error sending recovery email ${monitor.id}`);
}
};
+
+export const sendDegraded = async ({
+ monitor,
+ notification,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ statusCode,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ message,
+}: {
+ monitor: Monitor;
+ notification: Notification;
+ statusCode?: number;
+ message?: string;
+}) => {
+ // FIXME:
+ const config = EmailConfigurationSchema.parse(JSON.parse(notification.data));
+ const { email } = config;
+
+ const res = await fetch("https://api.resend.com/emails", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${env.RESEND_API_KEY}`,
+ },
+ body: JSON.stringify({
+ to: email,
+ from: "Notifications <[email protected]>",
+
+ subject: `Your monitor ${monitor.name} is degraded ⚠️`,
+ html: `<p>Hi,<br><br>Your monitor ${monitor.name} is taking longer than expected to respond</p><p>URL : ${monitor.url}</p> <p>OpenStatus πŸ“ </p>`,
+ }),
+ });
+
+ if (res.ok) {
+ const data = await res.json();
+ console.log(data);
+ // return NextResponse.json(data);
+ }
+ if (!res.ok) {
+ console.log(`Error sending recovery email ${monitor.id}`);
+ }
+};
diff --git a/packages/notifications/pagerduty/src/index.ts b/packages/notifications/pagerduty/src/index.ts
index f47c6bd18..33ceb8dc7 100644
--- a/packages/notifications/pagerduty/src/index.ts
+++ b/packages/notifications/pagerduty/src/index.ts
@@ -54,6 +54,54 @@ export const sendAlert = async ({
}
};
+export const sendDegraded = async ({
+ monitor,
+ notification,
+ statusCode,
+ message,
+ incidentId,
+}: {
+ monitor: Monitor;
+ notification: Notification;
+ statusCode?: number;
+ message?: string;
+ incidentId?: string;
+}) => {
+ const notificationData = PagerDutySchema.parse(JSON.parse(notification.data));
+ const { name } = monitor;
+
+ const event = triggerEventPayloadSchema.parse({
+ rounting_key: notificationData.integration_keys[0].integration_key,
+ dedup_key: `${monitor.id}}`,
+ event_action: "trigger",
+ payload: {
+ summary: `${name} is degraded`,
+ source: "Open Status",
+ severity: "warning",
+ timestamp: new Date().toISOString(),
+ custom_details: {
+ statusCode,
+ message,
+ },
+ },
+ });
+
+ try {
+ for await (const integrationKey of notificationData.integration_keys) {
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ const { integration_key, type } = integrationKey;
+
+ await fetch("https://events.pagerduty.com/v2/enqueue", {
+ method: "POST",
+ body: JSON.stringify(event),
+ });
+ }
+ } catch (err) {
+ console.log(err);
+ // Do something
+ }
+};
+
export const sendRecovery = async ({
monitor,
notification,
diff --git a/packages/notifications/slack/src/index.ts b/packages/notifications/slack/src/index.ts
index bd2781a4a..5745ebb2b 100644
--- a/packages/notifications/slack/src/index.ts
+++ b/packages/notifications/slack/src/index.ts
@@ -118,6 +118,55 @@ export const sendRecovery = async ({
}
};
+export const sendDegraded = async ({
+ monitor,
+ notification,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ statusCode,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ message,
+}: {
+ monitor: Monitor;
+ notification: Notification;
+ statusCode?: number;
+ message?: string;
+}) => {
+ const notificationData = JSON.parse(notification.data);
+ const { slack: webhookUrl } = notificationData; // webhook url
+ const { name } = monitor;
+
+ try {
+ await postToWebhook(
+ {
+ blocks: [
+ {
+ type: "section",
+ text: {
+ type: "mrkdwn",
+ text: `Your monitor <${monitor.url}/|${name}> is degraded
+ ⚠️ \n\n Powered by <https://www.openstatus.dev/|OpenStatus>.`,
+ },
+ accessory: {
+ type: "button",
+ text: {
+ type: "plain_text",
+ text: "Open Monitor",
+ emoji: true,
+ },
+ value: `monitor_url_${monitor.url}`,
+ url: monitor.url,
+ },
+ },
+ ],
+ },
+ webhookUrl
+ );
+ } catch (err) {
+ console.log(err);
+ // Do something
+ }
+};
+
export const sendTestSlackMessage = async (webhookUrl: string) => {
try {
await postToWebhook(
diff --git a/packages/notifications/twillio-sms/src/index.ts b/packages/notifications/twillio-sms/src/index.ts
index a9cb22aad..6417e3a71 100644
--- a/packages/notifications/twillio-sms/src/index.ts
+++ b/packages/notifications/twillio-sms/src/index.ts
@@ -95,3 +95,47 @@ export const sendRecovery = async ({
// Do something
}
};
+
+export const sendDegraded = async ({
+ monitor,
+ notification,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ statusCode,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ message,
+ incidentId,
+}: {
+ monitor: Monitor;
+ notification: Notification;
+ statusCode?: number;
+ message?: string;
+ incidentId?: string;
+}) => {
+ const notificationData = SmsConfigurationSchema.parse(
+ JSON.parse(notification.data)
+ );
+ const { name } = monitor;
+
+ const body = new FormData();
+ body.set("To", notificationData.sms);
+ body.set("From", "+14807252613");
+ body.set("Body", `Your monitor ${name} / ${monitor.url} is degraded `);
+
+ try {
+ fetch(
+ `https://api.twilio.com/2010-04-01/Accounts/${env.TWILLIO_ACCOUNT_ID}/Messages.json`,
+ {
+ method: "post",
+ body,
+ headers: {
+ Authorization: `Basic ${btoa(
+ `${env.TWILLIO_ACCOUNT_ID}:${env.TWILLIO_AUTH_TOKEN}`
+ )}`,
+ },
+ }
+ );
+ } catch (err) {
+ console.log(err);
+ // Do something
+ }
+};
diff --git a/packages/tinybird/src/audit-log/action-schema.ts b/packages/tinybird/src/audit-log/action-schema.ts
index 6d710f358..510e80912 100644
--- a/packages/tinybird/src/audit-log/action-schema.ts
+++ b/packages/tinybird/src/audit-log/action-schema.ts
@@ -13,6 +13,19 @@ export const monitorRecoveredSchema = z.object({
}),
});
+/**
+ * The schema for the monitor.recovered action.
+ * It represents the event when a monitor has recovered from a failure.
+ */
+export const monitorDegradedSchema = z.object({
+ action: z.literal("monitor.degraded"),
+ metadata: z.object({
+ region: z.string(),
+ statusCode: z.number(),
+ cronTimestamp: z.number().optional(),
+ }),
+});
+
/**
* The schema for the monitor.failed action.
* It represents the event when a monitor has failed.
diff --git a/packages/tinybird/src/audit-log/action-validation.ts b/packages/tinybird/src/audit-log/action-validation.ts
index e478cbee9..03125aefe 100644
--- a/packages/tinybird/src/audit-log/action-validation.ts
+++ b/packages/tinybird/src/audit-log/action-validation.ts
@@ -1,6 +1,7 @@
import { z } from "zod";
import {
+ monitorDegradedSchema,
monitorFailedSchema,
monitorRecoveredSchema,
notificationSentSchema,
@@ -21,6 +22,7 @@ export const ingestActionEventSchema = z
// and made available to devs as library
z.discriminatedUnion("action", [
monitorRecoveredSchema,
+ monitorDegradedSchema,
monitorFailedSchema,
notificationSentSchema,
]),