Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
feat: add Grafana OnCall integration (#1813)
Thibault Le Ouaydb9e2d4b276d
diff --git a/apps/dashboard/package.json b/apps/dashboard/package.jsonindex e8405adb4..dfea9295b 100644--- a/apps/dashboard/package.json+++ b/apps/dashboard/package.json@@ -33,6 +33,7 @@"@openstatus/notification-discord": "workspace:*","@openstatus/notification-emails": "workspace:*","@openstatus/notification-google-chat": "workspace:*",+ "@openstatus/notification-grafana-oncall": "workspace:*","@openstatus/notification-ntfy": "workspace:*","@openstatus/notification-opsgenie": "workspace:*","@openstatus/notification-pagerduty": "workspace:*",diff --git a/apps/dashboard/src/components/forms/notifications/form-grafana-oncall.tsx b/apps/dashboard/src/components/forms/notifications/form-grafana-oncall.tsxnew file mode 100644index 000000000..fd31c569f--- /dev/null+++ b/apps/dashboard/src/components/forms/notifications/form-grafana-oncall.tsx@@ -0,0 +1,238 @@+"use client";++import { Checkbox } from "@/components/ui/checkbox";+import {+ FormControl,+ FormDescription,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+} from "@/components/ui/form";++import {+ FormCardContent,+ FormCardSeparator,+} from "@/components/forms/form-card";+import { Button } from "@/components/ui/button";+import { Form } from "@/components/ui/form";+import { Input } from "@/components/ui/input";+import { Label } from "@/components/ui/label";+import { useTRPC } from "@/lib/trpc/client";+import { cn } from "@/lib/utils";+import { zodResolver } from "@hookform/resolvers/zod";+import { useMutation } from "@tanstack/react-query";+import { isTRPCClientError } from "@trpc/client";+import { useTransition } from "react";+import React from "react";+import { useForm } from "react-hook-form";+import { toast } from "sonner";+import { z } from "zod";+import { useFormSheetDirty } from "../form-sheet";++const schema = z.object({+ name: z.string(),+ provider: z.literal("grafana-oncall"),+ data: z.record(z.string(), z.string()),+ monitors: z.array(z.number()),+});++type FormValues = z.infer<typeof schema>;++export function FormGrafanaOncall({+ defaultValues,+ onSubmit,+ className,+ monitors,+ ...props+}: Omit<React.ComponentProps<"form">, "onSubmit"> & {+ defaultValues?: FormValues;+ onSubmit: (values: FormValues) => Promise<void>;+ monitors: { id: number; name: string }[];+}) {+ const form = useForm<FormValues>({+ resolver: zodResolver(schema),+ defaultValues: defaultValues ?? {+ name: "",+ provider: "grafana-oncall",+ data: {+ webhookUrl: "",+ },+ monitors: [],+ },+ });+ const [isPending, startTransition] = useTransition();+ const { setIsDirty } = useFormSheetDirty();++ const trpc = useTRPC();++ const sendTestMutation = useMutation(+ trpc.notification.sendTest.mutationOptions(),+ );++ const formIsDirty = form.formState.isDirty;+ React.useEffect(() => {+ setIsDirty(formIsDirty);+ }, [formIsDirty, setIsDirty]);++ function submitAction(values: FormValues) {+ if (isPending) return;++ startTransition(async () => {+ try {+ const promise = onSubmit(values);+ toast.promise(promise, {+ loading: "Saving...",+ success: "Saved",+ error: (error) => {+ if (isTRPCClientError(error)) {+ return error.message;+ }+ return "Failed to save";+ },+ });+ await promise;+ } catch (error) {+ console.error(error);+ }+ });+ }++ function testAction() {+ if (isPending) return;++ startTransition(async () => {+ try {+ const provider = form.getValues("provider");+ const data = form.getValues("data");+ const promise = sendTestMutation.mutateAsync({+ provider,+ data: {+ "grafana-oncall": data,+ },+ });+ toast.promise(promise, {+ loading: "Sending test...",+ success: "Test sent",+ error: (error) => {+ if (error instanceof Error) {+ return error.message;+ }+ return "Failed to send test";+ },+ });+ await promise;+ } catch (error) {+ console.error(error);+ }+ });+ }++ return (+ <Form {...form}>+ <form+ className={cn("grid gap-4", className)}+ onSubmit={form.handleSubmit(submitAction)}+ {...props}+ >+ <FormCardContent className="grid gap-4">+ <FormField+ control={form.control}+ name="name"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Name</FormLabel>+ <FormControl>+ <Input placeholder="My Notifier" {...field} />+ </FormControl>+ <FormMessage />+ <FormDescription>+ Enter a descriptive name for your notifier.+ </FormDescription>+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="data.webhookUrl"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Webhook URL</FormLabel>+ <FormControl>+ <Input+ placeholder="https://oncall-prod-us-central-0.grafana.net/oncall/integrations/v1/webhook/..."+ {...field}+ />+ </FormControl>+ <FormMessage />+ <FormDescription>+ Enter your Grafana OnCall incoming webhook URL. You can find+ this in your Grafana OnCall integration settings.+ </FormDescription>+ </FormItem>+ )}+ />+ <div>+ <Button+ variant="outline"+ size="sm"+ type="button"+ onClick={testAction}+ >+ Send Test+ </Button>+ </div>+ </FormCardContent>+ <FormCardSeparator />+ <FormCardContent>+ <FormField+ control={form.control}+ name="monitors"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Monitors</FormLabel>+ <FormDescription>+ Select the monitors you want to notify.+ </FormDescription>+ <div className="grid gap-3">+ <div className="flex items-center gap-2">+ <FormControl>+ <Checkbox+ id="all"+ checked={field.value?.length === monitors.length}+ onCheckedChange={(checked) => {+ field.onChange(+ checked ? monitors.map((m) => m.id) : [],+ );+ }}+ />+ </FormControl>+ <Label htmlFor="all">Select all</Label>+ </div>+ {monitors.map((item) => (+ <div key={item.id} className="flex items-center gap-2">+ <FormControl>+ <Checkbox+ id={String(item.id)}+ checked={field.value?.includes(item.id)}+ onCheckedChange={(checked) => {+ const newValue = checked+ ? [...(field.value || []), item.id]+ : field.value?.filter((id) => id !== item.id);+ field.onChange(newValue);+ }}+ />+ </FormControl>+ <Label htmlFor={String(item.id)}>{item.name}</Label>+ </div>+ ))}+ </div>+ <FormMessage />+ </FormItem>+ )}+ />+ </FormCardContent>+ </form>+ </Form>+ );+}diff --git a/apps/dashboard/src/components/forms/notifications/form.tsx b/apps/dashboard/src/components/forms/notifications/form.tsxindex 094e7266a..234ac5e81 100644--- a/apps/dashboard/src/components/forms/notifications/form.tsx+++ b/apps/dashboard/src/components/forms/notifications/form.tsx@@ -34,6 +34,7 @@ const schema = z.object({"telegram","whatsapp","google-chat",+ "grafana-oncall",]),data: z.record(z.string(), z.string()).or(z.string()),monitors: z.array(z.number()),diff --git a/apps/dashboard/src/data/notifications.client.ts b/apps/dashboard/src/data/notifications.client.tsindex 30943b9bb..30184ee0e 100644--- a/apps/dashboard/src/data/notifications.client.ts+++ b/apps/dashboard/src/data/notifications.client.ts@@ -1,6 +1,7 @@import { FormDiscord } from "@/components/forms/notifications/form-discord";import { FormEmail } from "@/components/forms/notifications/form-email";import { FormGoogleChat } from "@/components/forms/notifications/form-google-chat";+import { FormGrafanaOncall } from "@/components/forms/notifications/form-grafana-oncall";import { FormNtfy } from "@/components/forms/notifications/form-ntfy";import { FormOpsGenie } from "@/components/forms/notifications/form-opsgenie";import { FormPagerDuty } from "@/components/forms/notifications/form-pagerduty";@@ -12,6 +13,7 @@ import { FormWhatsApp } from "@/components/forms/notifications/form-whatsapp";import {DiscordIcon,GoogleIcon,+ GrafanaIcon,TelegramIcon,WhatsappIcon,} from "@openstatus/icons";@@ -19,6 +21,7 @@ import { OpsGenieIcon } from "@openstatus/icons";import { PagerDutyIcon } from "@openstatus/icons";import { SlackIcon } from "@openstatus/icons";import { sendTestDiscordMessage as sendTestDiscord } from "@openstatus/notification-discord";+import { sendTest as sendTestGrafanaOncall } from "@openstatus/notification-grafana-oncall";import { sendTest as sendTestNtfy } from "@openstatus/notification-ntfy";import { sendTest as sendTestOpsGenie } from "@openstatus/notification-opsgenie";import { sendTest as sendTestPagerDuty } from "@openstatus/notification-pagerduty";@@ -108,6 +111,12 @@ export const config = {form: FormGoogleChat,sendTest: sendTestWebhook,},+ "grafana-oncall": {+ icon: GrafanaIcon,+ label: "Grafana OnCall",+ form: FormGrafanaOncall,+ sendTest: sendTestGrafanaOncall,+ },pagerduty: {icon: PagerDutyIcon,label: "PagerDuty",diff --git a/apps/web/next-env.d.ts b/apps/web/next-env.d.tsindex 9edff1c7c..c4b7818fb 100644--- a/apps/web/next-env.d.ts+++ b/apps/web/next-env.d.ts@@ -1,6 +1,6 @@/// <reference types="next" />/// <reference types="next/image-types/global" />-import "./.next/types/routes.d.ts";+import "./.next/dev/types/routes.d.ts";// NOTE: This file should not be edited// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.diff --git a/apps/web/public/assets/changelog/grafana-oncall.png b/apps/web/public/assets/changelog/grafana-oncall.pngnew file mode 100644index 000000000..bc79f05c9Binary files /dev/null and b/apps/web/public/assets/changelog/grafana-oncall.png differdiff --git a/apps/web/src/content/pages/changelog/grafana-oncall-integration.mdx b/apps/web/src/content/pages/changelog/grafana-oncall-integration.mdxnew file mode 100644index 000000000..ecbdd226e--- /dev/null+++ b/apps/web/src/content/pages/changelog/grafana-oncall-integration.mdx@@ -0,0 +1,10 @@+---+title: "Grafana OnCall Notifications"+description: ""+image: "/assets/changelog/grafana-oncall.png"+publishedAt: "2026-01-31"+author: "openstatus"+category: "notifications"+---++You can now receive your uptime notifications via Grafana OnCall. This allows you to integrate OpenStatus with your existing incident management workflows in Grafana OnCall.diff --git a/apps/workflows/.dockerignore b/apps/workflows/.dockerignoreindex c304379d7..5e73b32b9 100644--- a/apps/workflows/.dockerignore+++ b/apps/workflows/.dockerignore@@ -1,4 +1,4 @@-# This file is generated by Dofigen v2.5.0+# This file is generated by Dofigen v2.6.0# See https://github.com/lenra-io/dofigennode_modulesdiff --git a/apps/workflows/Dockerfile b/apps/workflows/Dockerfileindex f713fe1f0..5bef03d41 100644--- a/apps/workflows/Dockerfile+++ b/apps/workflows/Dockerfile@@ -1,7 +1,14 @@-# syntax=docker/dockerfile:1.11-# This file is generated by Dofigen v2.5.0+# syntax=docker/dockerfile:1.19.0+# This file is generated by Dofigen v2.6.0# See https://github.com/lenra-io/dofigen+# ca-certs+FROM debian@sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734 AS ca-certs+LABEL \+ org.opencontainers.image.base.digest="sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734" \+ org.opencontainers.image.base.name="docker.io/debian:bullseye-slim"+RUN apt update && apt install -y ca-certificates curl && update-ca-certificates+# dockerFROM oven/bun@sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a AS dockerLABEL \@@ -30,6 +37,7 @@ RUN \--mount=type=bind,target=packages/notifications/base/package.json,source=packages/notifications/base/package.json \--mount=type=bind,target=packages/notifications/discord/package.json,source=packages/notifications/discord/package.json \--mount=type=bind,target=packages/notifications/email/package.json,source=packages/notifications/email/package.json \+ --mount=type=bind,target=packages/notifications/grafana-oncall/package.json,source=packages/notifications/grafana-oncall/package.json \--mount=type=bind,target=packages/notifications/google-chat/package.json,source=packages/notifications/google-chat/package.json \--mount=type=bind,target=packages/notifications/ntfy/package.json,source=packages/notifications/ntfy/package.json \--mount=type=bind,target=packages/notifications/opsgenie/package.json,source=packages/notifications/opsgenie/package.json \@@ -65,13 +73,6 @@ COPY \"/app/node_modules" "/app/node_modules"RUN bun build --compile --target bun --sourcemap src/index.ts --outfile=app-# ca-certs-FROM debian@sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734 AS ca-certs-LABEL \- org.opencontainers.image.base.digest="sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734" \- org.opencontainers.image.base.name="docker.io/debian:bullseye-slim"-RUN apt update && apt install -y ca-certificates curl && update-ca-certificates-# libsqlFROM oven/bun@sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a AS libsqlLABEL \@@ -87,7 +88,7 @@ RUN bun install# runtimeFROM debian@sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734 AS runtimeLABEL \- io.dofigen.version="2.5.0" \+ io.dofigen.version="2.6.0" \org.opencontainers.image.authors="OpenStatus Team" \org.opencontainers.image.base.digest="sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734" \org.opencontainers.image.base.name="docker.io/debian:bullseye-slim" \diff --git a/apps/workflows/dofigen.lock b/apps/workflows/dofigen.lockindex 52ded8cf6..557b847b0 100644--- a/apps/workflows/dofigen.lock+++ b/apps/workflows/dofigen.lock@@ -17,9 +17,9 @@ effective: |path: oven/bundigest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4alabel:+ org.opencontainers.image.base.digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4aorg.opencontainers.image.stage: buildorg.opencontainers.image.base.name: docker.io/oven/bun:1.3.6- org.opencontainers.image.base.digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4aworkdir: /app/apps/workflowsenv:NODE_ENV: production@@ -38,9 +38,9 @@ effective: |path: oven/bundigest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4alabel:- org.opencontainers.image.stage: installorg.opencontainers.image.base.digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4aorg.opencontainers.image.base.name: docker.io/oven/bun:1.3.6+ org.opencontainers.image.stage: installworkdir: /app/run:- bun install --production --frozen-lockfile --verbose@@ -65,6 +65,8 @@ effective: |source: packages/notifications/discord/package.json- target: packages/notifications/email/package.jsonsource: packages/notifications/email/package.json+ - target: packages/notifications/grafana-oncall/package.json+ source: packages/notifications/grafana-oncall/package.json- target: packages/notifications/google-chat/package.jsonsource: packages/notifications/google-chat/package.json- target: packages/notifications/ntfy/package.json@@ -95,28 +97,13 @@ effective: |source: packages/upstash/package.json- target: packages/theme-store/package.jsonsource: packages/theme-store/package.json- libsql:- fromImage:- path: oven/bun- digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a- label:- org.opencontainers.image.base.digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a- org.opencontainers.image.base.name: docker.io/oven/bun:1.3.6- workdir: /app/- copy:- - fromBuilder: docker- paths:- - /app/apps/build-docker/package.json- target: /app/package.json- run:- - bun installca-certs:fromImage:path: debiandigest: sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734label:- org.opencontainers.image.base.name: docker.io/debian:bullseye-slimorg.opencontainers.image.base.digest: sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734+ org.opencontainers.image.base.name: docker.io/debian:bullseye-slimrun:- apt update && apt install -y ca-certificates curl && update-ca-certificatesdocker:@@ -133,17 +120,32 @@ effective: |target: /app/run:- bun run src/build-docker.ts+ libsql:+ fromImage:+ path: oven/bun+ digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a+ label:+ org.opencontainers.image.base.digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a+ org.opencontainers.image.base.name: docker.io/oven/bun:1.3.6+ workdir: /app/+ copy:+ - fromBuilder: docker+ paths:+ - /app/apps/build-docker/package.json+ target: /app/package.json+ run:+ - bun installfromImage:path: debiandigest: sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734label:+ org.opencontainers.image.base.digest: sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734org.opencontainers.image.authors: OpenStatus Team+ io.dofigen.version: 2.6.0org.opencontainers.image.source: https://github.com/openstatusHQ/openstatus- org.opencontainers.image.title: OpenStatus Workflows- io.dofigen.version: 2.5.0- org.opencontainers.image.base.digest: sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734org.opencontainers.image.base.name: docker.io/debian:bullseye-slimorg.opencontainers.image.vendor: OpenStatus+ org.opencontainers.image.title: OpenStatus Workflowsorg.opencontainers.image.description: Background job processing and probe scheduling for OpenStatusworkdir: /app/copy:@@ -174,17 +176,17 @@ effective: |- port: 3000images:docker.io:- library:- debian:- bullseye-slim:- digest: sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734oven:bun:1.3.6:digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a+ library:+ debian:+ bullseye-slim:+ digest: sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734resources:dofigen.yml:- hash: 6a13d3715d011de108b8e7710153a84e1c2a05a1aaf9f89daf6ae6a7315490f8+ hash: 74add186097db908927534a6891f49e5f44fb056578c631c1afa534123c95769content: |ignore:- node_modules@@ -214,6 +216,7 @@ resources:- packages/notifications/base/package.json- packages/notifications/discord/package.json- packages/notifications/email/package.json+ - packages/notifications/grafana-oncall/package.json- packages/notifications/google-chat/package.json- packages/notifications/ntfy/package.json- packages/notifications/opsgenie/package.jsondiff --git a/apps/workflows/dofigen.yml b/apps/workflows/dofigen.ymlindex 401ea0f77..d330aaa25 100644--- a/apps/workflows/dofigen.yml+++ b/apps/workflows/dofigen.yml@@ -26,6 +26,7 @@ builders:- packages/notifications/base/package.json- packages/notifications/discord/package.json- packages/notifications/email/package.json+ - packages/notifications/grafana-oncall/package.json- packages/notifications/google-chat/package.json- packages/notifications/ntfy/package.json- packages/notifications/opsgenie/package.jsondiff --git a/apps/workflows/package.json b/apps/workflows/package.jsonindex 310615f6e..1df1352b8 100644--- a/apps/workflows/package.json+++ b/apps/workflows/package.json@@ -18,6 +18,7 @@"@openstatus/notification-discord": "workspace:*","@openstatus/notification-emails": "workspace:*","@openstatus/notification-google-chat": "workspace:*",+ "@openstatus/notification-grafana-oncall": "workspace:*","@openstatus/notification-ntfy": "workspace:*","@openstatus/notification-opsgenie": "workspace:*","@openstatus/notification-pagerduty": "workspace:*",diff --git a/apps/workflows/src/checker/utils.ts b/apps/workflows/src/checker/utils.tsindex 6bd18ed6c..4bb85b2c9 100644--- a/apps/workflows/src/checker/utils.ts+++ b/apps/workflows/src/checker/utils.ts@@ -15,6 +15,11 @@ import {sendDegraded as sendGoogleChatDegraded,sendRecovery as sendGoogleChatRecovery,} from "@openstatus/notification-google-chat";+import {+ sendAlert as sendGrafanaOncallAlert,+ sendDegraded as sendGrafanaOncallDegraded,+ sendRecovery as sendGrafanaOncallRecovery,+} from "@openstatus/notification-grafana-oncall";import {sendAlert as sendNtfyAlert,sendDegraded as sendNtfyDegraded,@@ -80,6 +85,11 @@ export const providerToFunction: Record<NotificationProvider, Notif> = {sendRecovery: sendGoogleChatRecovery,sendDegraded: sendGoogleChatDegraded,},+ "grafana-oncall": {+ sendAlert: sendGrafanaOncallAlert,+ sendRecovery: sendGrafanaOncallRecovery,+ sendDegraded: sendGrafanaOncallDegraded,+ },ntfy: {sendAlert: sendNtfyAlert,sendRecovery: sendNtfyRecovery,diff --git a/packages/api/package.json b/packages/api/package.jsonindex 21a9516e8..e078e322d 100644--- a/packages/api/package.json+++ b/packages/api/package.json@@ -14,6 +14,7 @@"@openstatus/emails": "workspace:*","@openstatus/error": "workspace:*","@openstatus/notification-google-chat": "workspace:*",+ "@openstatus/notification-grafana-oncall": "workspace:*","@openstatus/notification-telegram": "workspace:*","@openstatus/notification-twillio-whatsapp": "workspace:*","@openstatus/regions": "workspace:*",diff --git a/packages/api/src/router/notification.ts b/packages/api/src/router/notification.tsindex 22882b0e3..12f948a91 100644--- a/packages/api/src/router/notification.ts+++ b/packages/api/src/router/notification.ts@@ -5,6 +5,7 @@ import { type SQL, and, count, db, eq, inArray } from "@openstatus/db";import {NotificationDataSchema,googleChatDataSchema,+ grafanaOncallDataSchema,insertNotificationSchema,monitor,notification,@@ -19,6 +20,7 @@ import {import { Events } from "@openstatus/analytics";import { SchemaError } from "@openstatus/error";import { sendTest as sendGoogleChatTest } from "@openstatus/notification-google-chat";+import { sendTest as sendGrafanaTest } from "@openstatus/notification-grafana-oncall";import { sendTest as sendTelegramTest } from "@openstatus/notification-telegram";import { sendTest as sendWhatsAppTest } from "@openstatus/notification-twillio-whatsapp";@@ -48,11 +50,22 @@ export const notificationRouter = createTRPCRouter({});}- const limitedProviders = ["sms", "pagerduty", "opsgenie"];+ const limitedProviders = [+ "sms",+ "pagerduty",+ "opsgenie",+ "grafana-oncall",+ "whatsapp",+ ];if (limitedProviders.includes(props.provider)) {const isAllowed =opts.ctx.workspace.limits[- props.provider as "sms" | "pagerduty" | "opsgenie"+ props.provider as+ | "sms"+ | "pagerduty"+ | "opsgenie"+ | "grafana-oncall"+ | "whatsapp"];if (!isAllowed) {@@ -389,12 +402,23 @@ export const notificationRouter = createTRPCRouter({});}- const limitedProviders = ["sms", "pagerduty", "opsgenie"] as const;+ const limitedProviders = [+ "sms",+ "pagerduty",+ "opsgenie",+ "grafana-oncall",+ "whatsapp",+ ] as const;// biome-ignore lint/suspicious/noExplicitAny: <explanation>if (limitedProviders.includes(opts.input.provider as any)) {const isAllowed =opts.ctx.workspace.limits[- opts.input.provider as "sms" | "pagerduty" | "opsgenie"+ opts.input.provider as+ | "sms"+ | "pagerduty"+ | "opsgenie"+ | "grafana-oncall"+ | "whatsapp"];if (!isAllowed) {@@ -495,17 +519,28 @@ export const notificationRouter = createTRPCRouter({}if (opts.input.provider === "google-chat") {const _data = googleChatDataSchema.safeParse(opts.input.data);- console.log(opts.input.data);- console.log(_data);if (!_data.success) {throw new TRPCError({code: "BAD_REQUEST",message: SchemaError.fromZod(_data.error, opts.input).message,});}+await sendGoogleChatTest(_data.data["google-chat"]);return;}+ if (opts.input.provider === "grafana-oncall") {+ const _data = grafanaOncallDataSchema.safeParse(opts.input.data);+ if (!_data.success) {+ throw new TRPCError({+ code: "BAD_REQUEST",+ message: SchemaError.fromZod(_data.error, opts.input).message,+ });+ }++ await sendGrafanaTest(_data.data["grafana-oncall"]);+ return;+ }throw new TRPCError({code: "BAD_REQUEST",diff --git a/packages/db/src/schema/notifications/constants.ts b/packages/db/src/schema/notifications/constants.tsindex cab6a568f..8ba9adbff 100644--- a/packages/db/src/schema/notifications/constants.ts+++ b/packages/db/src/schema/notifications/constants.ts@@ -2,6 +2,7 @@ export const notificationProvider = ["discord","email","google-chat",+ "grafana-oncall","ntfy","pagerduty","opsgenie",diff --git a/packages/db/src/schema/notifications/validation.ts b/packages/db/src/schema/notifications/validation.tsindex dc6bba2e0..763377b54 100644--- a/packages/db/src/schema/notifications/validation.ts+++ b/packages/db/src/schema/notifications/validation.ts@@ -67,6 +67,12 @@ export const telegramDataSchema = z.object({telegram: z.object({ chatId: z.string() }),});+export const grafanaOncallDataSchema = z.object({+ "grafana-oncall": z.object({+ webhookUrl: z.url(),+ }),+});+export const whatsappDataSchema = z.object({whatsapp: phoneSchema,});@@ -74,6 +80,7 @@ export const whatsappDataSchema = z.object({export const NotificationDataSchema = z.union([discordDataSchema,emailDataSchema,+ grafanaOncallDataSchema,ntfyDataSchema,opsgenieDataSchema,pagerdutyDataSchema,@@ -106,6 +113,12 @@ export const InsertNotificationWithDataSchema = z.discriminatedUnion(data: googleChatDataSchema,}).shape,),+ insertNotificationSchema.extend(+ z.object({+ provider: z.literal("grafana-oncall"),+ data: grafanaOncallDataSchema,+ }).shape,+ ),insertNotificationSchema.extend(z.object({provider: z.literal("ntfy"),@@ -136,17 +149,23 @@ export const InsertNotificationWithDataSchema = z.discriminatedUnion(data: slackDataSchema,}).shape,),+ insertNotificationSchema.extend(+ z.object({+ provider: z.literal("telegram"),+ data: telegramDataSchema,+ }).shape,+ ),insertNotificationSchema.extend(z.object({provider: z.literal("webhook"),data: webhookDataSchema,}).shape,),- insertNotificationSchema.merge(+ insertNotificationSchema.extend(z.object({provider: z.literal("whatsapp"),data: whatsappDataSchema,- }),+ }).shape,),],);diff --git a/packages/db/src/schema/plan/config.ts b/packages/db/src/schema/plan/config.tsindex a7a86cb53..8f8dd5fa1 100644--- a/packages/db/src/schema/plan/config.ts+++ b/packages/db/src/schema/plan/config.ts@@ -54,6 +54,7 @@ export const allPlans: Record<WorkspacePlan, PlanConfig> = {"sms-limit": 0,pagerduty: false,opsgenie: false,+ "grafana-oncall": false,whatsapp: false,"notification-channels": 1,members: 1,@@ -125,6 +126,7 @@ export const allPlans: Record<WorkspacePlan, PlanConfig> = {notifications: true,pagerduty: true,opsgenie: true,+ "grafana-oncall": true,whatsapp: true,sms: true,"sms-limit": 50,@@ -200,6 +202,7 @@ export const allPlans: Record<WorkspacePlan, PlanConfig> = {"sms-limit": 100,pagerduty: true,opsgenie: true,+ "grafana-oncall": true,whatsapp: true,"notification-channels": 20,members: "Unlimited",diff --git a/packages/db/src/schema/plan/schema.ts b/packages/db/src/schema/plan/schema.tsindex ba7f12014..483b2eafc 100644--- a/packages/db/src/schema/plan/schema.ts+++ b/packages/db/src/schema/plan/schema.ts@@ -42,6 +42,7 @@ export const limitsSchema = z.object({notifications: z.boolean().prefault(true),pagerduty: z.boolean().prefault(false),opsgenie: z.boolean().prefault(false),+ "grafana-oncall": z.boolean().prefault(false),whatsapp: z.boolean().prefault(false),sms: z.boolean().prefault(false),"sms-limit": z.number().prefault(0),diff --git a/packages/icons/src/grafana.tsx b/packages/icons/src/grafana.tsxnew file mode 100644index 000000000..cc345d23a--- /dev/null+++ b/packages/icons/src/grafana.tsx@@ -0,0 +1,15 @@+export function GrafanaIcon(props: React.ComponentProps<"svg">) {+ return (+ <svg+ role="img"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ stroke="currentColor"+ fill="currentColor"+ {...props}+ >+ <title>Grafana</title>+ <path d="M23.02 10.59a8.578 8.578 0 0 0-.862-3.034 8.911 8.911 0 0 0-1.789-2.445c.337-1.342-.413-2.505-.413-2.505-1.292-.08-2.113.4-2.416.62-.052-.02-.102-.044-.154-.064-.22-.089-.446-.172-.677-.247-.231-.073-.47-.14-.711-.197a9.867 9.867 0 0 0-.875-.161C14.557.753 12.94 0 12.94 0c-1.804 1.145-2.147 2.744-2.147 2.744l-.018.093c-.098.029-.2.057-.298.088-.138.042-.275.094-.413.143-.138.055-.275.107-.41.166a8.869 8.869 0 0 0-1.557.87l-.063-.029c-2.497-.955-4.716.195-4.716.195-.203 2.658.996 4.33 1.235 4.636a11.608 11.608 0 0 0-.607 2.635C1.636 12.677.953 15.014.953 15.014c1.926 2.214 4.171 2.351 4.171 2.351.003-.002.006-.002.006-.005.285.509.615.994.986 1.446.156.19.32.371.488.548-.704 2.009.099 3.68.099 3.68 2.144.08 3.553-.937 3.849-1.173a9.784 9.784 0 0 0 3.164.501h.08l.055-.003.107-.002.103-.005.003.002c1.01 1.44 2.788 1.646 2.788 1.646 1.264-1.332 1.337-2.653 1.337-2.94v-.058c0-.02-.003-.039-.003-.06.265-.187.52-.387.758-.6a7.875 7.875 0 0 0 1.415-1.7c1.43.083 2.437-.885 2.437-.885-.236-1.49-1.085-2.216-1.264-2.354l-.018-.013-.016-.013a.217.217 0 0 1-.031-.02c.008-.092.016-.18.02-.27.011-.162.016-.323.016-.48v-.253l-.005-.098-.008-.135a1.891 1.891 0 0 0-.01-.13c-.003-.042-.008-.083-.013-.125l-.016-.124-.018-.122a6.215 6.215 0 0 0-2.032-3.73 6.015 6.015 0 0 0-3.222-1.46 6.292 6.292 0 0 0-.85-.048l-.107.002h-.063l-.044.003-.104.008a4.777 4.777 0 0 0-3.335 1.695c-.332.4-.592.84-.768 1.297a4.594 4.594 0 0 0-.312 1.817l.003.091c.005.055.007.11.013.164a3.615 3.615 0 0 0 .698 1.82 3.53 3.53 0 0 0 1.827 1.282c.33.098.66.14.971.137.039 0 .078 0 .114-.002l.063-.003c.02 0 .041-.003.062-.003.034-.002.065-.007.099-.01.007 0 .018-.003.028-.003l.031-.005.06-.008a1.18 1.18 0 0 0 .112-.02c.036-.008.072-.013.109-.024a2.634 2.634 0 0 0 .914-.415c.028-.02.056-.041.085-.065a.248.248 0 0 0 .039-.35.244.244 0 0 0-.309-.06l-.078.042c-.09.044-.184.083-.283.116a2.476 2.476 0 0 1-.475.096c-.028.003-.054.006-.083.006l-.083.002c-.026 0-.054 0-.08-.002l-.102-.006h-.012l-.024.006c-.016-.003-.031-.003-.044-.006-.031-.002-.06-.007-.091-.01a2.59 2.59 0 0 1-.724-.213 2.557 2.557 0 0 1-.667-.438 2.52 2.52 0 0 1-.805-1.475 2.306 2.306 0 0 1-.029-.444l.006-.122v-.023l.002-.031c.003-.021.003-.04.005-.06a3.163 3.163 0 0 1 1.352-2.29 3.12 3.12 0 0 1 .937-.43 2.946 2.946 0 0 1 .776-.101h.06l.07.002.045.003h.026l.07.005a4.041 4.041 0 0 1 1.635.49 3.94 3.94 0 0 1 1.602 1.662 3.77 3.77 0 0 1 .397 1.414l.005.076.003.075c.002.026.002.05.002.075 0 .024.003.052 0 .07v.065l-.002.073-.008.174a6.195 6.195 0 0 1-.08.639 5.1 5.1 0 0 1-.267.927 5.31 5.31 0 0 1-.624 1.13 5.052 5.052 0 0 1-3.237 2.014 4.82 4.82 0 0 1-.649.066l-.039.003h-.287a6.607 6.607 0 0 1-1.716-.265 6.776 6.776 0 0 1-3.4-2.274 6.75 6.75 0 0 1-.746-1.15 6.616 6.616 0 0 1-.714-2.596l-.005-.083-.002-.02v-.056l-.003-.073v-.096l-.003-.104v-.07l.003-.163c.008-.22.026-.45.054-.678a8.707 8.707 0 0 1 .28-1.355c.128-.444.286-.872.473-1.277a7.04 7.04 0 0 1 1.456-2.1 5.925 5.925 0 0 1 .953-.763c.169-.111.343-.213.524-.306.089-.05.182-.091.273-.135.047-.02.093-.042.138-.062a7.177 7.177 0 0 1 .714-.267l.145-.045c.049-.015.098-.026.148-.041.098-.029.197-.052.296-.076.049-.013.1-.02.15-.033l.15-.032.151-.028.076-.013.075-.01.153-.024c.057-.01.114-.013.171-.023l.169-.021c.036-.003.073-.008.106-.01l.073-.008.036-.003.042-.002c.057-.003.114-.008.171-.01l.086-.006h.023l.037-.003.145-.007a7.999 7.999 0 0 1 1.708.125 7.917 7.917 0 0 1 2.048.68 8.253 8.253 0 0 1 1.672 1.09l.09.077.089.078c.06.052.114.107.171.159.057.052.112.106.166.16.052.055.107.107.159.164a8.671 8.671 0 0 1 1.41 1.978c.012.026.028.052.04.078l.04.078.075.156c.023.051.05.1.07.153l.065.15a8.848 8.848 0 0 1 .45 1.34.19.19 0 0 0 .201.142.186.186 0 0 0 .172-.184c.01-.246.002-.532-.024-.856z" />+ </svg>+ );+}diff --git a/packages/icons/src/index.tsx b/packages/icons/src/index.tsxindex 553ab2bb4..91c1c3b65 100644--- a/packages/icons/src/index.tsx+++ b/packages/icons/src/index.tsx@@ -1,6 +1,7 @@export * from "./discord";export * from "./github";export * from "./google";+export * from "./grafana";export * from "./pagerduty";export * from "./slack";export * from "./opsgenie";diff --git a/packages/notifications/grafana-oncall/package.json b/packages/notifications/grafana-oncall/package.jsonnew file mode 100644index 000000000..87711baac--- /dev/null+++ b/packages/notifications/grafana-oncall/package.json@@ -0,0 +1,20 @@+{+ "name": "@openstatus/notification-grafana-oncall",+ "version": "0.0.0",+ "main": "src/index.ts",+ "scripts": {+ "test": "bun test",+ "tsc": "tsc"+ },+ "dependencies": {+ "@openstatus/db": "workspace:*",+ "@openstatus/notification-base": "workspace:*",+ "zod": "4.1.13"+ },+ "devDependencies": {+ "@openstatus/tsconfig": "workspace:*",+ "@types/node": "24.0.8",+ "bun-types": "1.3.1",+ "typescript": "5.9.3"+ }+}diff --git a/packages/notifications/grafana-oncall/src/index.test.ts b/packages/notifications/grafana-oncall/src/index.test.tsnew file mode 100644index 000000000..4e82c165f--- /dev/null+++ b/packages/notifications/grafana-oncall/src/index.test.ts@@ -0,0 +1,249 @@+import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";+import { selectNotificationSchema } from "@openstatus/db/src/schema";+import { sendAlert, sendDegraded, sendRecovery, sendTest } from "./index";++describe("Grafana OnCall Notifications", () => {+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>+ let fetchMock: any = undefined;++ beforeEach(() => {+ // @ts-expect-error+ fetchMock = spyOn(global, "fetch").mockImplementation(() =>+ Promise.resolve(new Response(null, { status: 200 })),+ );+ });++ afterEach(() => {+ if (fetchMock) {+ fetchMock.mockRestore();+ }+ });++ const createMockMonitor = () => ({+ id: "monitor-1",+ name: "API Health Check",+ url: "https://api.example.com/health",+ jobType: "http" as const,+ periodicity: "5m" as const,+ status: "active" as const,+ createdAt: new Date(),+ updatedAt: new Date(),+ region: "iad",+ });++ const createMockNotification = () => ({+ id: 1,+ name: "Grafana OnCall Notification",+ provider: "grafana-oncall",+ workspaceId: 1,+ createdAt: new Date(),+ updatedAt: new Date(),+ data: '{"grafana-oncall":{"webhookUrl":"https://oncall.example.com/integrations/v1/webhook/abc123"}}',+ });++ test("Send Alert", async () => {+ const monitor = createMockMonitor();+ const notification = selectNotificationSchema.parse(+ createMockNotification(),+ );++ await sendAlert({+ // @ts-expect-error+ monitor,+ notification,+ statusCode: 500,+ message: "Something went wrong",+ cronTimestamp: Date.now(),+ });++ expect(fetchMock).toHaveBeenCalledTimes(1);+ const callArgs = fetchMock.mock.calls[0];+ expect(callArgs[0]).toBe(+ "https://oncall.example.com/integrations/v1/webhook/abc123",+ );+ expect(callArgs[1].method).toBe("POST");+ expect(callArgs[1].headers["Content-Type"]).toBe("application/json");++ const body = JSON.parse(callArgs[1].body);+ expect(body.alert_uid).toBe("openstatus-monitor-monitor-1");+ expect(body.title).toBe("API Health Check is down");+ expect(body.message).toBe("Something went wrong");+ expect(body.state).toBe("alerting");+ expect(body.link_to_upstream_details).toBe(+ "https://www.openstatus.dev/app/monitor-1/overview",+ );+ });++ test("Send Alert uses status code as message when no message provided", async () => {+ const monitor = createMockMonitor();+ const notification = selectNotificationSchema.parse(+ createMockNotification(),+ );++ await sendAlert({+ // @ts-expect-error+ monitor,+ notification,+ statusCode: 503,+ cronTimestamp: Date.now(),+ });++ expect(fetchMock).toHaveBeenCalledTimes(1);+ const callArgs = fetchMock.mock.calls[0];+ const body = JSON.parse(callArgs[1].body);+ expect(body.message).toBe("Status code: 503");+ });++ test("Send Degraded", async () => {+ const monitor = createMockMonitor();+ const notification = selectNotificationSchema.parse(+ createMockNotification(),+ );++ await sendDegraded({+ // @ts-expect-error+ monitor,+ notification,+ statusCode: 503,+ message: "Service degraded",+ cronTimestamp: Date.now(),+ });++ expect(fetchMock).toHaveBeenCalledTimes(1);+ const callArgs = fetchMock.mock.calls[0];+ expect(callArgs[0]).toBe(+ "https://oncall.example.com/integrations/v1/webhook/abc123",+ );++ const body = JSON.parse(callArgs[1].body);+ expect(body.alert_uid).toBe("openstatus-monitor-monitor-1");+ expect(body.title).toBe("API Health Check is degraded");+ expect(body.message).toBe("Service degraded");+ expect(body.state).toBe("alerting");+ });++ test("Send Recovery", async () => {+ const monitor = createMockMonitor();+ const notification = selectNotificationSchema.parse(+ createMockNotification(),+ );++ await sendRecovery({+ // @ts-expect-error+ monitor,+ notification,+ statusCode: 200,+ message: "Service recovered",+ cronTimestamp: Date.now(),+ });++ expect(fetchMock).toHaveBeenCalledTimes(1);+ const callArgs = fetchMock.mock.calls[0];+ expect(callArgs[0]).toBe(+ "https://oncall.example.com/integrations/v1/webhook/abc123",+ );++ const body = JSON.parse(callArgs[1].body);+ expect(body.alert_uid).toBe("openstatus-monitor-monitor-1");+ expect(body.title).toBe("API Health Check has recovered");+ expect(body.message).toBe("Service recovered");+ expect(body.state).toBe("ok");+ });++ test("Send Test", async () => {+ const webhookUrl =+ "https://oncall.example.com/integrations/v1/webhook/test123";++ const result = await sendTest({ webhookUrl });++ expect(result).toBe(true);+ expect(fetchMock).toHaveBeenCalledTimes(1);+ const callArgs = fetchMock.mock.calls[0];+ expect(callArgs[0]).toBe(webhookUrl);+ expect(callArgs[1].method).toBe("POST");++ const body = JSON.parse(callArgs[1].body);+ expect(body.alert_uid).toBe("openstatus-test");+ expect(body.title).toBe("Test Alert <OpenStatus>");+ expect(body.message).toContain("Grafana OnCall integration is functioning");+ expect(body.state).toBe("alerting");+ expect(body.link_to_upstream_details).toBe("https://www.openstatus.dev");+ });++ test("Send Test returns false on network error", async () => {+ fetchMock.mockImplementation(() =>+ Promise.reject(new Error("Network error")),+ );++ const result = await sendTest({+ webhookUrl: "https://oncall.example.com/integrations/v1/webhook/test123",+ });++ expect(result).toBe(false);+ expect(fetchMock).toHaveBeenCalledTimes(1);+ });++ test("Send Test returns false on non-ok response", async () => {+ fetchMock.mockImplementation(() =>+ Promise.resolve(new Response(null, { status: 401 })),+ );++ const result = await sendTest({+ webhookUrl: "https://oncall.example.com/integrations/v1/webhook/test123",+ });++ expect(result).toBe(false);+ expect(fetchMock).toHaveBeenCalledTimes(1);+ });++ test("Send Alert throws on non-ok response", async () => {+ fetchMock.mockImplementation(() =>+ Promise.resolve(+ new Response(null, {+ status: 500,+ statusText: "Internal Server Error",+ }),+ ),+ );++ const monitor = createMockMonitor();+ const notification = selectNotificationSchema.parse(+ createMockNotification(),+ );++ expect(+ sendAlert({+ // @ts-expect-error+ monitor,+ notification,+ statusCode: 500,+ message: "Error",+ cronTimestamp: Date.now(),+ }),+ ).rejects.toThrow("Failed to send Grafana OnCall alert");+ });++ test("Handle fetch error gracefully", async () => {+ fetchMock.mockImplementation(() =>+ Promise.reject(new Error("Network error")),+ );++ const monitor = createMockMonitor();+ const notification = selectNotificationSchema.parse(+ createMockNotification(),+ );++ expect(+ sendAlert({+ // @ts-expect-error+ monitor,+ notification,+ statusCode: 500,+ message: "Error",+ cronTimestamp: Date.now(),+ }),+ ).rejects.toThrow();++ expect(fetchMock).toHaveBeenCalledTimes(1);+ });+});diff --git a/packages/notifications/grafana-oncall/src/index.ts b/packages/notifications/grafana-oncall/src/index.tsnew file mode 100644index 000000000..8f5eedb78--- /dev/null+++ b/packages/notifications/grafana-oncall/src/index.ts@@ -0,0 +1,138 @@+import type { NotificationContext } from "@openstatus/notification-base";+import { GrafanaOncallPayload, GrafanaOncallSchema } from "./schema";++export const sendAlert = async ({+ monitor,+ notification,+ statusCode,+ message,+}: NotificationContext) => {+ const { "grafana-oncall": config } = GrafanaOncallSchema.parse(+ JSON.parse(notification.data),+ );+ const { name } = monitor;++ const event = GrafanaOncallPayload.parse({+ alert_uid: `openstatus-monitor-${monitor.id}`,+ title: `${name} is down`,+ message: message || `Status code: ${statusCode}`,+ state: "alerting",+ link_to_upstream_details: `https://www.openstatus.dev/app/${monitor.id}/overview`,+ });++ const res = await fetch(config.webhookUrl, {+ method: "POST",+ body: JSON.stringify(event),+ headers: {+ "Content-Type": "application/json",+ },+ });++ if (!res.ok) {+ throw new Error(+ `Failed to send Grafana OnCall alert: ${res.status} ${res.statusText}`,+ );+ }+};++export const sendDegraded = async ({+ monitor,+ notification,+ statusCode,+ message,+}: NotificationContext) => {+ const { "grafana-oncall": config } = GrafanaOncallSchema.parse(+ JSON.parse(notification.data),+ );+ const { name } = monitor;++ const event = GrafanaOncallPayload.parse({+ alert_uid: `openstatus-monitor-${monitor.id}`,+ title: `${name} is degraded`,+ message: message || `Status code: ${statusCode}`,+ state: "alerting",+ link_to_upstream_details: `https://www.openstatus.dev/app/${monitor.id}/overview`,+ });++ const res = await fetch(config.webhookUrl, {+ method: "POST",+ body: JSON.stringify(event),+ headers: {+ "Content-Type": "application/json",+ },+ });++ if (!res.ok) {+ throw new Error(+ `Failed to send Grafana OnCall degraded alert: ${res.status} ${res.statusText}`,+ );+ }+};++export const sendRecovery = async ({+ monitor,+ notification,+ statusCode,+ message,+}: NotificationContext) => {+ const { "grafana-oncall": config } = GrafanaOncallSchema.parse(+ JSON.parse(notification.data),+ );+ const { name } = monitor;++ const event = GrafanaOncallPayload.parse({+ alert_uid: `openstatus-monitor-${monitor.id}`,+ title: `${name} has recovered`,+ message: message || `Status code: ${statusCode}`,+ state: "ok",+ link_to_upstream_details: `https://www.openstatus.dev/app/${monitor.id}/overview`,+ });++ const res = await fetch(config.webhookUrl, {+ method: "POST",+ body: JSON.stringify(event),+ headers: {+ "Content-Type": "application/json",+ },+ });++ if (!res.ok) {+ throw new Error(+ `Failed to send Grafana OnCall recovery: ${res.status} ${res.statusText}`,+ );+ }+};++export const sendTest = async (props: { webhookUrl: string }) => {+ const { webhookUrl } = props;++ const event = GrafanaOncallPayload.parse({+ alert_uid: "openstatus-test",+ title: "Test Alert <OpenStatus>",+ message:+ "If you can read this, your Grafana OnCall integration is functioning correctly! Please ignore this alert.",+ state: "alerting",+ link_to_upstream_details: "https://www.openstatus.dev",+ });++ try {+ const res = await fetch(webhookUrl, {+ method: "POST",+ body: JSON.stringify(event),+ headers: {+ "Content-Type": "application/json",+ },+ });++ if (!res.ok) {+ throw new Error(`Failed to send test: ${res.status} ${res.statusText}`);+ }++ return true;+ } catch (err) {+ console.log(err);+ return false;+ }+};++export { GrafanaOncallSchema };diff --git a/packages/notifications/grafana-oncall/src/schema.ts b/packages/notifications/grafana-oncall/src/schema.tsnew file mode 100644index 000000000..53213ab68--- /dev/null+++ b/packages/notifications/grafana-oncall/src/schema.ts@@ -0,0 +1,12 @@+import { grafanaOncallDataSchema } from "@openstatus/db/src/schema";+import { z } from "zod";++export const GrafanaOncallSchema = grafanaOncallDataSchema;++export const GrafanaOncallPayload = z.object({+ alert_uid: z.string(),+ title: z.string(),+ message: z.string().optional(),+ state: z.enum(["alerting", "ok"]),+ link_to_upstream_details: z.string().optional(),+});diff --git a/packages/notifications/grafana-oncall/tsconfig.json b/packages/notifications/grafana-oncall/tsconfig.jsonnew file mode 100644index 000000000..b4382e67e--- /dev/null+++ b/packages/notifications/grafana-oncall/tsconfig.json@@ -0,0 +1,7 @@+{+ "extends": "@openstatus/tsconfig/nextjs.json",+ "include": ["src", "*.ts"],+ "compilerOptions": {+ "types": ["bun-types"]+ }+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex f025b6b0b..88ecfef16 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -73,7 +73,7 @@ importers:version: 0.15.15'@openpanel/nextjs':specifier: 1.0.8- version: 1.0.8([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])+ version: 1.0.8([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])'@openstatus/analytics':specifier: workspace:*version: link:../../packages/analytics@@ -107,6 +107,9 @@ importers:'@openstatus/notification-google-chat':specifier: workspace:*version: link:../../packages/notifications/google-chat+ '@openstatus/notification-grafana-oncall':+ specifier: workspace:*+ version: link:../../packages/notifications/grafana-oncall'@openstatus/notification-ntfy':specifier: workspace:*version: link:../../packages/notifications/ntfy@@ -208,7 +211,7 @@ importers:version: 1.2.7(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@sentry/nextjs':specifier: 10.31.0- version: 10.31.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected])+ version: 10.31.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected])'@stripe/stripe-js':specifier: 2.1.6version: 2.1.6@@ -223,7 +226,7 @@ importers:'@trpc/next':specifier: 11.4.4- version: 11.4.4(@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected](@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected]))(@trpc/[email protected]([email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])+ version: 11.4.4(@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected](@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected]))(@trpc/[email protected]([email protected]))([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])'@trpc/react-query':specifier: 11.4.4version: 11.4.4(@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected])@@ -256,13 +259,13 @@ importers:version: 16.0.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])next-auth:specifier: 5.0.0-beta.29- version: 5.0.0-beta.29([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])+ version: 5.0.0-beta.29([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])next-themes:specifier: 0.4.6nuqs:specifier: 2.8.5- version: 2.8.5([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])+ version: 2.8.5([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])random-word-slugs:specifier: 0.1.7version: 0.1.7@@ -593,7 +596,7 @@ importers:version: 0.15.15'@openpanel/nextjs':specifier: 1.0.8- version: 1.0.8([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])+ version: 1.0.8([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])'@openstatus/analytics':specifier: workspace:*version: link:../../packages/analytics@@ -683,7 +686,7 @@ importers:version: 1.2.7(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@sentry/nextjs':specifier: 10.31.0- version: 10.31.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected])+ version: 10.31.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected])'@stripe/stripe-js':specifier: 2.1.6version: 2.1.6@@ -698,7 +701,7 @@ importers:'@trpc/next':specifier: 11.4.4- version: 11.4.4(@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected](@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected]))(@trpc/[email protected]([email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])+ version: 11.4.4(@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected](@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected]))(@trpc/[email protected]([email protected]))([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])'@trpc/react-query':specifier: 11.4.4version: 11.4.4(@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected])@@ -731,16 +734,16 @@ importers:version: 16.0.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])next-auth:specifier: 5.0.0-beta.29- version: 5.0.0-beta.29([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])+ version: 5.0.0-beta.29([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])next-plausible:specifier: 3.12.5- version: 3.12.5([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])+ version: 3.12.5([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])next-themes:specifier: 0.4.6nuqs:specifier: 2.8.5- version: 2.8.5([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])+ version: 2.8.5([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])react:specifier: 19.2.3version: 19.2.3@@ -837,7 +840,7 @@ importers:version: 0.15.15'@openpanel/nextjs':specifier: 1.0.8- version: 1.0.8([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])+ version: 1.0.8([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])'@openstatus/analytics':specifier: workspace:*version: link:../../packages/analytics@@ -912,7 +915,7 @@ importers:version: 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@sentry/nextjs':specifier: 10.31.0- version: 10.31.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected])+ version: 10.31.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected])'@stripe/stripe-js':specifier: 2.1.6version: 2.1.6@@ -939,7 +942,7 @@ importers:'@trpc/next':specifier: 11.4.4- version: 11.4.4(@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected](@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected]))(@trpc/[email protected]([email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])+ version: 11.4.4(@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected](@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected]))(@trpc/[email protected]([email protected]))([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])'@trpc/react-query':specifier: 11.4.4version: 11.4.4(@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected])@@ -987,19 +990,19 @@ importers:version: 16.0.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])next-auth:specifier: 5.0.0-beta.29- version: 5.0.0-beta.29([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])+ version: 5.0.0-beta.29([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])next-mdx-remote:specifier: 5.0.0version: 5.0.0(@types/[email protected])([email protected])next-plausible:specifier: 3.12.5- version: 3.12.5([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])+ version: 3.12.5([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])next-themes:specifier: 0.4.6nuqs:specifier: 2.8.5- version: 2.8.5([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])+ version: 2.8.5([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])random-word-slugs:specifier: 0.1.7version: 0.1.7@@ -1139,6 +1142,9 @@ importers:'@openstatus/notification-google-chat':specifier: workspace:*version: link:../../packages/notifications/google-chat+ '@openstatus/notification-grafana-oncall':+ specifier: workspace:*+ version: link:../../packages/notifications/grafana-oncall'@openstatus/notification-ntfy':specifier: workspace:*version: link:../../packages/notifications/ntfy@@ -1246,6 +1252,9 @@ importers:'@openstatus/notification-google-chat':specifier: workspace:*version: link:../notifications/google-chat+ '@openstatus/notification-grafana-oncall':+ specifier: workspace:*+ version: link:../notifications/grafana-oncall'@openstatus/notification-telegram':specifier: workspace:*version: link:../notifications/telegram@@ -1380,7 +1389,7 @@ importers:version: 0.31.4next-auth:specifier: 5.0.0-beta.29- version: 5.0.0-beta.29([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])+ version: 5.0.0-beta.29([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])typescript:specifier: 5.9.3version: 5.9.3@@ -1599,6 +1608,31 @@ importers:specifier: 5.9.3version: 5.9.3+ packages/notifications/grafana-oncall:+ dependencies:+ '@openstatus/db':+ specifier: workspace:*+ version: link:../../db+ '@openstatus/notification-base':+ specifier: workspace:*+ version: link:../base+ zod:+ specifier: 4.1.13+ version: 4.1.13+ devDependencies:+ '@openstatus/tsconfig':+ specifier: workspace:*+ version: link:../../tsconfig+ '@types/node':+ specifier: 24.0.8+ version: 24.0.8+ bun-types:+ specifier: 1.3.1+ version: 1.3.1(@types/[email protected])+ typescript:+ specifier: 5.9.3+ version: 5.9.3+packages/notifications/ntfy:dependencies:'@openstatus/db':@@ -1903,6 +1937,8 @@ importers:specifier: 5.9.3version: 5.9.3+ packages/react/dist: {}+packages/regions:dependencies:zod:@@ -13591,7 +13627,7 @@ snapshots:'@openpanel/web': 1.0.1astro: 5.16.6(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])- '@openpanel/[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])':+ '@openpanel/[email protected]([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])':dependencies:'@openpanel/web': 1.0.1next: 16.0.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])@@ -15618,7 +15654,7 @@ snapshots:'@sentry/types': 8.9.2'@sentry/utils': 8.9.2- '@sentry/[email protected](@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected])':+ '@sentry/[email protected](@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected])':dependencies:'@opentelemetry/api': 1.9.0'@opentelemetry/semantic-conventions': 1.38.0@@ -16320,7 +16356,7 @@ snapshots:'@trpc/server': 11.4.4([email protected])typescript: 5.9.3- '@trpc/[email protected](@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected](@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected]))(@trpc/[email protected]([email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])':+ '@trpc/[email protected](@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected](@tanstack/[email protected]([email protected]))(@trpc/[email protected](@trpc/[email protected]([email protected]))([email protected]))(@trpc/[email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected]))(@trpc/[email protected]([email protected]))([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])':dependencies:'@trpc/server': 11.4.4([email protected])@@ -19779,7 +19815,7 @@ snapshots:- [email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]):+ [email protected]([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]):dependencies:'@auth/core': 0.40.0next: 16.0.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])@@ -19798,7 +19834,7 @@ snapshots:- '@types/react'- supports-color- [email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected]):+ [email protected]([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected]):dependencies:next: 16.0.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])react: 19.2.3@@ -19895,7 +19931,7 @@ snapshots:dependencies:boolbase: 1.0.0- [email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]):+ [email protected]([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]):dependencies:'@standard-schema/spec': 1.0.0react: 19.2.3