Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
chore: feedback v2 (#1300)
Maximilian Kaske12eeb4460003
diff --git a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsxindex 90ac5af4a..9016eef1f 100644--- a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx+++ b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx@@ -3,6 +3,7 @@import { ChartAreaLatency } from "@/components/chart/chart-area-latency";import { ChartAreaTimingPhases } from "@/components/chart/chart-area-timing-phases";import { ChartBarUptime } from "@/components/chart/chart-bar-uptime";+import { ChartLineRegions } from "@/components/chart/chart-line-regions";import {Section,SectionDescription,@@ -18,7 +19,10 @@ import { DropdownPeriod } from "@/components/controls-search/dropdown-period";import { AuditLogsWrapper } from "@/components/data-table/audit-logs/wrapper";import { columns as regionColumns } from "@/components/data-table/response-logs/regions/columns";import { GlobalUptimeSection } from "@/components/metric/global-uptime/section";+import { PopoverQuantile } from "@/components/popovers/popover-quantile";+import { PopoverResolution } from "@/components/popovers/popover-resolution";import { DataTable } from "@/components/ui/data-table/data-table";+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";import { mapRegionMetrics } from "@/data/metrics.client";import type { RegionMetric } from "@/data/region-metrics";import { useTRPC } from "@/lib/trpc/client";@@ -54,8 +58,8 @@ export function Client() {const { data: regionTimeline } = useQuery(regionTimelineQuery);const regionMetrics: RegionMetric[] = React.useMemo(() => {- return mapRegionMetrics(regionTimeline, monitor?.regions ?? []);- }, [regionTimeline, monitor]);+ return mapRegionMetrics(regionTimeline, monitor?.regions ?? [], percentile);+ }, [regionTimeline, monitor, percentile]);if (!monitor) return null;@@ -94,7 +98,7 @@ export function Client() {<SectionHeader><SectionTitle>Uptime</SectionTitle><SectionDescription>- Uptime accross all the regions+ Uptime accross all the selected regions</SectionDescription></SectionHeader><ChartBarUptime@@ -116,8 +120,10 @@ export function Client() {</SectionHeader><div className="flex flex-wrap gap-2"><div>- The <DropdownPercentile /> quantile within a <DropdownInterval />{" "}- resolution+ The <DropdownPercentile />{" "}+ <PopoverQuantile>quantile</PopoverQuantile> within a{" "}+ <DropdownInterval />{" "}+ <PopoverResolution>resolution</PopoverResolution></div><div><ButtonReset only={["percentile", "interval"]} />@@ -148,10 +154,55 @@ export function Client() {<SectionHeader><SectionTitle>Regions</SectionTitle><SectionDescription>- Every region's latency over the last 24 hours+ Every selected region's latency trend</SectionDescription></SectionHeader>- <DataTable data={regionMetrics} columns={regionColumns} />+ <div className="flex flex-wrap gap-2">+ <div>+ The <DropdownPercentile />{" "}+ <PopoverQuantile>quantile</PopoverQuantile> trend over the{" "}+ <DropdownPeriod />+ </div>+ <div>+ <ButtonReset only={["percentile", "period"]} />+ </div>+ </div>+ <Tabs defaultValue="table">+ <TabsList>+ <TabsTrigger value="table">Table</TabsTrigger>+ <TabsTrigger value="chart">Chart</TabsTrigger>+ </TabsList>+ <TabsContent value="table">+ <DataTable data={regionMetrics} columns={regionColumns} />+ </TabsContent>+ <TabsContent value="chart">+ <ChartLineRegions+ className="mt-3"+ regions={monitor.regions.filter((region) =>+ selectedRegions.includes(region),+ )}+ data={regionMetrics.reduce(+ (acc, region) => {+ region.trend.forEach((t) => {+ const existing = acc.find(+ (d) => d.timestamp === t.timestamp,+ );+ if (existing) {+ existing[region.region] = t[region.region];+ } else {+ acc.push({+ timestamp: t.timestamp,+ [region.region]: t[region.region],+ });+ }+ });+ return acc;+ },+ [] as { timestamp: number; [key: string]: number }[],+ )}+ />+ </TabsContent>+ </Tabs></Section><Section><SectionHeader>diff --git a/apps/dashboard/src/app/(dashboard)/onboarding/client.tsx b/apps/dashboard/src/app/(dashboard)/onboarding/client.tsxindex cd4b410ac..25b7f1857 100644--- a/apps/dashboard/src/app/(dashboard)/onboarding/client.tsx+++ b/apps/dashboard/src/app/(dashboard)/onboarding/client.tsx@@ -70,17 +70,32 @@ const moreActions = [description: "See what's new in OpenStatus.",href: "https://openstatus.dev/changelog",},+ {+ id: "discord",+ title: "Discord",+ description: "Join our Discord server if you get stuck.",+ href: "https://discord.gg/openstatus",+ },+ {+ id: "github",+ title: "GitHub",+ description: "Leave a star on GitHub, request features or report issues.",+ href: "https://github.com/openstatus-dev/openstatus",+ },];export function Client() {const [{ step }, setSearchParams] = useQueryStates(searchParamsParsers);const trpc = useTRPC();const queryClient = useQueryClient();- const { data: workspace } = useQuery(trpc.workspace.get.queryOptions());+ const { data: workspace, refetch } = useQuery(+ trpc.workspace.get.queryOptions(),+ );const createMonitorMutation = useMutation(trpc.monitor.create.mutationOptions({onSuccess: () => {setSearchParams({ step: "2" });+ refetch();queryClient.invalidateQueries({queryKey: trpc.monitor.list.queryKey(),});@@ -91,6 +106,7 @@ export function Client() {trpc.page.create.mutationOptions({onSuccess: () => {setSearchParams({ step: "next" });+ refetch();queryClient.invalidateQueries({queryKey: trpc.page.list.queryKey(),});@@ -203,7 +219,9 @@ export function Client() {<LearnFromFormonSubmit={async (values) => {await createFeedbackMutation.mutateAsync({- message: `I learned about OpenStatus from ${values.from}${values.other ? `: ${values.other}` : ""}`,+ message: `I learned about OpenStatus from *${values.from}${+ values.other ? `: ${values.other}` : ""+ }*`,});}}/>diff --git a/apps/dashboard/src/components/chart/chart-area-timing-phases.tsx b/apps/dashboard/src/components/chart/chart-area-timing-phases.tsxindex 5339f04c2..751428dc2 100644--- a/apps/dashboard/src/components/chart/chart-area-timing-phases.tsx+++ b/apps/dashboard/src/components/chart/chart-area-timing-phases.tsx@@ -103,7 +103,6 @@ export function ChartAreaTimingPhases({/><ChartTooltipcursor={false}- defaultIndex={10}content={<ChartTooltipContentindicator="dot"diff --git a/apps/dashboard/src/components/chart/chart-bar-uptime-light.tsx b/apps/dashboard/src/components/chart/chart-bar-uptime-light.tsxnew file mode 100644index 000000000..dc45166c0--- /dev/null+++ b/apps/dashboard/src/components/chart/chart-bar-uptime-light.tsx@@ -0,0 +1,88 @@+"use client";++import { Skeleton } from "@/components/ui/skeleton";+import { Bar, BarChart, XAxis } from "recharts";++import {+ type ChartConfig,+ ChartContainer,+ ChartTooltip,+ ChartTooltipContent,+} from "@/components/ui/chart";+import { mapUptime } from "@/data/metrics.client";+import { useTRPC } from "@/lib/trpc/client";+import type { Region } from "@openstatus/db/src/schema/constants";+import { useQuery } from "@tanstack/react-query";+// import { startOfDay, subDays } from "date-fns";++const chartConfig = {+ ok: {+ label: "Success",+ color: "var(--color-success)",+ },+ degraded: {+ label: "Degraded",+ color: "var(--color-warning)",+ },+ error: {+ label: "Error",+ color: "var(--color-destructive)",+ },+} satisfies ChartConfig;++export function ChartBarUptimeLight({+ monitorId,+ type,+ regions,+}: {+ monitorId: string;+ type: "http" | "tcp";+ regions?: Region[];+}) {+ const trpc = useTRPC();++ const { data: uptime, isLoading } = useQuery(+ trpc.tinybird.uptime.queryOptions({+ interval: 60 * 24,+ // fromDate: startOfDay(subDays(new Date(), 7)).toISOString(), // FIXME:+ period: "7d",+ monitorId,+ regions,+ type,+ }),+ );++ if (isLoading) {+ return <Skeleton className=" my-auto h-5 w-full" />;+ }++ const refinedUptime = uptime ? mapUptime(uptime) : [];++ if (refinedUptime.length === 0) {+ return <span className="text-muted-foreground">-</span>;+ }++ return (+ <ChartContainer config={chartConfig} className="h-[28px] w-full">+ <BarChart accessibilityLayer data={refinedUptime} barCategoryGap={1}>+ <ChartTooltip+ cursor={false}+ allowEscapeViewBox={{ x: false, y: true }}+ wrapperStyle={{ zIndex: 1 }}+ content={<ChartTooltipContent indicator="dot" />}+ />+ <Bar dataKey="ok" stackId="a" fill="var(--color-ok)" />+ <Bar dataKey="error" stackId="a" fill="var(--color-error)" />+ <Bar dataKey="degraded" stackId="a" fill="var(--color-degraded)" />+ <XAxis+ dataKey="interval"+ tickLine={false}+ tickMargin={8}+ minTickGap={10}+ axisLine={false}+ hide+ />+ </BarChart>+ </ChartContainer>+ );+}diff --git a/apps/dashboard/src/components/chart/chart-line-regions.tsx b/apps/dashboard/src/components/chart/chart-line-regions.tsxnew file mode 100644index 000000000..9da240255--- /dev/null+++ b/apps/dashboard/src/components/chart/chart-line-regions.tsx@@ -0,0 +1,140 @@+"use client";++import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";++import {+ type ChartConfig,+ ChartContainer,+ ChartLegend,+ ChartLegendContent,+ ChartTooltip,+ ChartTooltipContent,+} from "@/components/ui/chart";+import { regionColors } from "@/data/regions";+import { cn } from "@/lib/utils";+import { flyRegionsDict } from "@openstatus/utils";+import { ChartTooltipNumber } from "./chart-tooltip-number";++const chartConfig = {+ ams: { label: flyRegionsDict.ams.location, color: regionColors.ams },+ arn: { label: flyRegionsDict.arn.location, color: regionColors.arn },+ atl: { label: flyRegionsDict.atl.location, color: regionColors.atl },+ bog: { label: flyRegionsDict.bog.location, color: regionColors.bog },+ bom: { label: flyRegionsDict.bom.location, color: regionColors.bom },+ bos: { label: flyRegionsDict.bos.location, color: regionColors.bos },+ cdg: { label: flyRegionsDict.cdg.location, color: regionColors.cdg },+ den: { label: flyRegionsDict.den.location, color: regionColors.den },+ dfw: { label: flyRegionsDict.dfw.location, color: regionColors.dfw },+ ewr: { label: flyRegionsDict.ewr.location, color: regionColors.ewr },+ eze: { label: flyRegionsDict.eze.location, color: regionColors.eze },+ fra: { label: flyRegionsDict.fra.location, color: regionColors.fra },+ gdl: { label: flyRegionsDict.gdl.location, color: regionColors.gdl },+ gig: { label: flyRegionsDict.gig.location, color: regionColors.gig },+ gru: { label: flyRegionsDict.gru.location, color: regionColors.gru },+ hkg: { label: flyRegionsDict.hkg.location, color: regionColors.hkg },+ iad: { label: flyRegionsDict.iad.location, color: regionColors.iad },+ jnb: { label: flyRegionsDict.jnb.location, color: regionColors.jnb },+ lax: { label: flyRegionsDict.lax.location, color: regionColors.lax },+ lhr: { label: flyRegionsDict.lhr.location, color: regionColors.lhr },+ mad: { label: flyRegionsDict.mad.location, color: regionColors.mad },+ mia: { label: flyRegionsDict.mia.location, color: regionColors.mia },+ nrt: { label: flyRegionsDict.nrt.location, color: regionColors.nrt },+ ord: { label: flyRegionsDict.ord.location, color: regionColors.ord },+ otp: { label: flyRegionsDict.otp.location, color: regionColors.otp },+ phx: { label: flyRegionsDict.phx.location, color: regionColors.phx },+ qro: { label: flyRegionsDict.qro.location, color: regionColors.qro },+ scl: { label: flyRegionsDict.scl.location, color: regionColors.scl },+ sjc: { label: flyRegionsDict.sjc.location, color: regionColors.sjc },+ sea: { label: flyRegionsDict.sea.location, color: regionColors.sea },+ sin: { label: flyRegionsDict.sin.location, color: regionColors.sin },+ syd: { label: flyRegionsDict.syd.location, color: regionColors.syd },+ waw: { label: flyRegionsDict.waw.location, color: regionColors.waw },+ yul: { label: flyRegionsDict.yul.location, color: regionColors.yul },+ yyz: { label: flyRegionsDict.yyz.location, color: regionColors.yyz },+} satisfies ChartConfig;++export type TrendPoint = {+ timestamp: number; // unix millis+ [key: string]: number; // milliseconds+};++export function ChartLineRegions({+ className,+ data,+ regions,+}: {+ className?: string;+ data: TrendPoint[];+ regions: string[];+}) {+ const trendData = data ?? [];++ console.log({ data, regions });++ const chartData = trendData.map((d) => ({+ ...d,+ timestamp: new Date(d.timestamp).toLocaleString("default", {+ hour: "numeric",+ minute: "numeric",+ day: "numeric",+ month: "short",+ }),+ }));++ return (+ <ChartContainer+ config={chartConfig}+ className={cn("h-[250px] w-full", className)}+ >+ <LineChart+ accessibilityLayer+ data={chartData}+ margin={{+ left: 12,+ right: 12,+ }}+ >+ <CartesianGrid vertical={false} />+ <XAxis dataKey="timestamp" />+ <ChartTooltip+ cursor={false}+ content={+ <ChartTooltipContent+ formatter={(value, name) => (+ <ChartTooltipNumber+ chartConfig={chartConfig}+ value={value}+ name={name}+ />+ )}+ />+ }+ />+ {regions.map((region) => {+ return (+ <Line+ key={region}+ dataKey={region}+ type="monotone"+ stroke={`var(--color-${region})`}+ strokeWidth={2}+ dot={false}+ />+ );+ })}+ <YAxis+ domain={["dataMin", "dataMax"]}+ tickLine={false}+ axisLine={false}+ tickMargin={8}+ orientation="right"+ tickFormatter={(value) => `${value}ms`}+ />+ <ChartLegend+ className="flex-wrap"+ content={<ChartLegendContent className="text-nowrap" />}+ />+ </LineChart>+ </ChartContainer>+ );+}diff --git a/apps/dashboard/src/components/data-table/monitors/columns.tsx b/apps/dashboard/src/components/data-table/monitors/columns.tsxindex c8489b993..93439262c 100644--- a/apps/dashboard/src/components/data-table/monitors/columns.tsx+++ b/apps/dashboard/src/components/data-table/monitors/columns.tsx@@ -1,10 +1,8 @@"use client";import { TableCellLink } from "@/components/data-table/table-cell-link";-// import { TableCellNumber } from "@/components/data-table/table-cell-number";import { Badge } from "@/components/ui/badge";import { Checkbox } from "@/components/ui/checkbox";-// import { DataTableColumnHeader } from "@/components/ui/data-table/data-table-column-header";import type { ColumnDef } from "@tanstack/react-table";import { DataTableRowActions } from "./data-table-row-actions";@@ -176,6 +174,21 @@ export const columns: ColumnDef<Monitor>[] = [enableHiding: false,enableGlobalFilter: false,},+ // {+ // id: "uptime",+ // accessorFn: (row) => `uptime-${row.id}`,+ // header: "Last Week",+ // cell: ({ row }) => {+ // return (+ // <ChartBarUptimeLight+ // monitorId={String(row.original.id)}+ // type={row.original.jobType as "http" | "tcp"}+ // />+ // );+ // },+ // enableHiding: false,+ // enableGlobalFilter: false,+ // },{id: "lastTimestamp",header: "Last Checked",@@ -185,7 +198,7 @@ export const columns: ColumnDef<Monitor>[] = [: row.globalMetrics,cell: ({ row }) => {const value = row.getValue("lastTimestamp");- if (value === undefined) return <TableCellSkeleton />;+ if (value === undefined) return <TableCellSkeleton className="w-full" />;return (<TableCellDatevalue={diff --git a/apps/dashboard/src/components/popovers/popover-quantile.tsx b/apps/dashboard/src/components/popovers/popover-quantile.tsxnew file mode 100644index 000000000..4521562d0--- /dev/null+++ b/apps/dashboard/src/components/popovers/popover-quantile.tsx@@ -0,0 +1,38 @@+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";+import { Separator } from "@/components/ui/separator";+import { cn } from "@/lib/utils";++export function PopoverQuantile({+ children,+ className,+ ...props+}: React.ComponentProps<typeof PopoverTrigger>) {+ return (+ <Popover>+ <PopoverTrigger+ className={cn(+ "shrink-0 rounded-md p-0 underline decoration-muted-foreground/70 decoration-dotted underline-offset-2 outline-none transition-all hover:decoration-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=open]:decoration-foreground dark:aria-invalid:ring-destructive/40",+ className,+ )}+ {...props}+ >+ {children}+ </PopoverTrigger>+ <PopoverContent side="top" className="p-0 text-sm">+ <p className="px-3 py-2 font-medium">+ A quantile represents a specific percentile in your dataset.+ </p>+ <Separator />+ <p className="px-3 py-2 text-muted-foreground">+ For example, p50 is the 50th percentile - the point below which 50% of+ data falls. Higher percentiles include more data and highlight the+ upper range.+ </p>+ </PopoverContent>+ </Popover>+ );+}diff --git a/apps/dashboard/src/components/popovers/popover-resolution.tsx b/apps/dashboard/src/components/popovers/popover-resolution.tsxnew file mode 100644index 000000000..d0305bcf4--- /dev/null+++ b/apps/dashboard/src/components/popovers/popover-resolution.tsx@@ -0,0 +1,37 @@+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";+import { Separator } from "@/components/ui/separator";+import { cn } from "@/lib/utils";++export function PopoverResolution({+ children,+ className,+ ...props+}: React.ComponentProps<typeof PopoverTrigger>) {+ return (+ <Popover>+ <PopoverTrigger+ className={cn(+ "shrink-0 rounded-md p-0 underline decoration-muted-foreground/70 decoration-dotted underline-offset-2 outline-none transition-all hover:decoration-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=open]:decoration-foreground dark:aria-invalid:ring-destructive/40",+ className,+ )}+ {...props}+ >+ {children}+ </PopoverTrigger>+ <PopoverContent side="top" className="p-0 text-sm">+ <p className="px-3 py-2 font-medium">+ Run data aggregation on fixed time boundaries.+ </p>+ <Separator />+ <p className="px-3 py-2 text-muted-foreground">+ A 30-minute resolution aligns to the top or bottom of the hour (e.g.,+ 00:00, 00:30) so all intervals are consistent for analysis.+ </p>+ </PopoverContent>+ </Popover>+ );+}diff --git a/apps/dashboard/src/components/ui/data-table/data-table.tsx b/apps/dashboard/src/components/ui/data-table/data-table.tsxindex b91d8b0d4..f823dd384 100644--- a/apps/dashboard/src/components/ui/data-table/data-table.tsx+++ b/apps/dashboard/src/components/ui/data-table/data-table.tsx@@ -66,7 +66,7 @@ export function DataTable<TData, TValue>({defaultSorting = [],defaultColumnVisibility = {},defaultColumnFilters = [],- defaultPagination = { pageIndex: 0, pageSize: 20 },+ defaultPagination = { pageIndex: 0, pageSize: 10 },autoResetPageIndex = true,columnFilters,setColumnFilters,diff --git a/apps/dashboard/src/data/metrics.client.ts b/apps/dashboard/src/data/metrics.client.tsindex 9477b1f88..effbb3aa3 100644--- a/apps/dashboard/src/data/metrics.client.ts+++ b/apps/dashboard/src/data/metrics.client.ts@@ -109,6 +109,7 @@ export function mapUptime(status: RouterOutputs["tinybird"]["uptime"]) {export function mapRegionMetrics(timeline: RouterOutputs["tinybird"]["metricsRegions"] | undefined,regions: Region[],+ percentile: (typeof PERCENTILES)[number],): RegionMetric[] {if (!timeline)return (regions@@ -118,7 +119,11 @@ export function mapRegionMetrics(p50: 0,p90: 0,p99: 0,- trend: [] as { latency: number; timestamp: number }[],+ trend: [] as {+ latency: number;+ timestamp: number;+ [key: string]: number;+ }[],})) ?? []) as RegionMetric[];type TimelineRow = (typeof timeline.data)[number];@@ -130,7 +135,11 @@ export function mapRegionMetrics(p50: number;p90: number;p99: number;- trend: { latency: number; timestamp: number }[];+ trend: {+ latency: number;+ timestamp: number;+ [key: string]: number;+ }[];}>();@@ -148,8 +157,9 @@ export function mapRegionMetrics(};entry.trend.push({- latency: row.p50Latency ?? 0,+ latency: row[PERCENTILE_MAP[percentile]] ?? 0,timestamp: row.timestamp,+ [region]: row[PERCENTILE_MAP[percentile]] ?? 0,});entry.p50 += row.p50Latency ?? 0;@@ -161,6 +171,7 @@ export function mapRegionMetrics(map.forEach((entry) => {const count = entry.trend.length || 1;+ entry.trend.reverse();entry.p50 = Math.round(entry.p50 / count);entry.p90 = Math.round(entry.p90 / count);entry.p99 = Math.round(entry.p99 / count);diff --git a/apps/dashboard/src/data/region-metrics.ts b/apps/dashboard/src/data/region-metrics.tsindex babe7139e..ba57820b7 100644--- a/apps/dashboard/src/data/region-metrics.ts+++ b/apps/dashboard/src/data/region-metrics.ts@@ -6,21 +6,33 @@ export const regionMetrics = [p50: 100,p90: 150,p99: 200,- trend: [{ latency: 100, timestamp: 1716729600 }],+ trend: [{ ams: 100, timestamp: 1716729600, latency: 100 }] as {+ [key: string]: number;+ timestamp: number;+ latency: number;+ }[],},{region: "fra" as const satisfies Region,p50: 110,p90: 155,p99: 220,- trend: [{ latency: 100, timestamp: 1716729600 }],+ trend: [{ fra: 100, timestamp: 1716729600, latency: 100 }] as {+ [key: string]: number;+ timestamp: number;+ latency: number;+ }[],},{region: "gru" as const satisfies Region,p50: 120,p90: 160,p99: 230,- trend: [{ latency: 100, timestamp: 1716729600 }],+ trend: [{ gru: 100, timestamp: 1716729600, latency: 100 }] as {+ [key: string]: number;+ timestamp: number;+ latency: number;+ }[],},];diff --git a/apps/dashboard/src/data/regions.ts b/apps/dashboard/src/data/regions.tsindex 362e0f163..2d9df6d0f 100644--- a/apps/dashboard/src/data/regions.ts+++ b/apps/dashboard/src/data/regions.ts@@ -224,3 +224,41 @@ export const groupedRegions = regions.reduce(},{} as Record<string, Region[]>,);++export const regionColors = {+ ams: "hsl(217.2 91.2% 59.8%)",+ arn: "hsl(238.7 83.5% 66.7%)",+ atl: "hsl(258.3 89.5% 66.3%)",+ bog: "hsl(270.7 91% 65.1%)",+ bom: "hsl(292.2 84.1% 60.6%)",+ bos: "hsl(330.4 81.2% 60.4%)",+ cdg: "hsl(349.7 89.2% 60.2%)",+ den: "hsl(215.4 16.3% 46.9%)",+ dfw: "hsl(220 8.9% 46.1%)",+ ewr: "hsl(240 3.8% 46.1%)",+ eze: "hsl(0 0% 45.1%)",+ fra: "hsl(25 5.3% 44.7%)",+ gdl: "hsl(0 84.2% 60.2%)",+ gig: "hsl(24.6 95% 53.1%)",+ gru: "hsl(37.7 92.1% 50.2%)",+ hkg: "hsl(45.4 93.4% 47.5%)",+ iad: "hsl(83.7 80.5% 44.3%)",+ jnb: "hsl(142.1 70.6% 45.3%)",+ lax: "hsl(160.1 84.1% 39.4%)",+ lhr: "hsl(173.4 80.4% 40%)",+ mad: "hsl(188.7 94.5% 42.7%)",+ mia: "hsl(198.6 88.7% 48.4%)",+ nrt: "hsl(217.2 91.2% 59.8%)",+ ord: "hsl(238.7 83.5% 66.7%)",+ otp: "hsl(258.3 89.5% 66.3%)",+ phx: "hsl(270.7 91% 65.1%)",+ qro: "hsl(292.2 84.1% 60.6%)",+ scl: "hsl(330.4 81.2% 60.4%)",+ sjc: "hsl(349.7 89.2% 60.2%)",+ sea: "hsl(215.4 16.3% 46.9%)",+ sin: "hsl(220 8.9% 46.1%)",+ syd: "hsl(240 3.8% 46.1%)",+ waw: "hsl(0 0% 45.1%)",+ yul: "hsl(25 5.3% 44.7%)",+ yyz: "hsl(0 84.2% 60.2%)",+} satisfies Record<Region, string>;diff --git a/packages/api/src/router/tinybird/index.ts b/packages/api/src/router/tinybird/index.tsindex c0da8fa2f..a91601f1d 100644--- a/packages/api/src/router/tinybird/index.ts+++ b/packages/api/src/router/tinybird/index.ts@@ -136,8 +136,15 @@ function getGlobalMetricsProcedure(type: Type) {return type === "http" ? tb.httpGlobalMetricsDaily : tb.tcpGlobalMetricsDaily;}-function getUptime30dProcedure(type: Type) {- return type === "http" ? tb.httpUptime30d : tb.tcpUptime30d;+function getUptimeProcedure(period: "7d" | "30d", type: Type) {+ switch (period) {+ case "7d":+ return type === "http" ? tb.httpUptimeWeekly : tb.tcpUptimeWeekly;+ case "30d":+ return type === "http" ? tb.httpUptime30d : tb.tcpUptime30d;+ default:+ return type === "http" ? tb.httpUptime30d : tb.httpUptime30d;+ }}// TODO: missing pipes for other periods@@ -213,6 +220,7 @@ export const tinybirdRouter = createTRPCRouter({interval: z.number().int().optional(), // in minutes, default 30regions: z.enum(flyRegions).array().optional(),type: z.enum(types).default("http"),+ period: z.enum(["7d", "30d"]).default("30d"),}),).query(async (opts) => {@@ -232,7 +240,7 @@ export const tinybirdRouter = createTRPCRouter({});}- const procedure = getUptime30dProcedure(opts.input.type);+ const procedure = getUptimeProcedure(opts.input.period, opts.input.type);return await procedure(opts.input);}),diff --git a/packages/emails/src/client.tsx b/packages/emails/src/client.tsxindex 1041c97e7..116777223 100644--- a/packages/emails/src/client.tsx+++ b/packages/emails/src/client.tsx@@ -12,6 +12,15 @@ import type { StatusReportProps } from "../emails/status-report";import TeamInvitationEmail from "../emails/team-invitation";import type { TeamInvitationProps } from "../emails/team-invitation";+// split an array into chunks of a given size.+function chunk<T>(array: T[], size: number): T[][] {+ const result: T[][] = [];+ for (let i = 0; i < array.length; i += size) {+ result.push(array.slice(i, i + size));+ }+ return result;+}+export class EmailClient {public readonly client: Resend;@@ -88,21 +97,27 @@ export class EmailClient {try {const html = await render(<StatusReportEmail {...req} />);- const result = await this.client.batch.send(- req.to.map((subscriber) => ({- from: `${req.pageTitle} <[email protected]>`,- subject: req.reportTitle,- to: subscriber,- html,- })),- );- if (!result.error) {- console.log(`Sent status report update email to ${req.to}`);- return;+ for (const recipients of chunk(req.to, 100)) {+ const result = await this.client.batch.send(+ recipients.map((subscriber) => ({+ from: `${req.pageTitle} <[email protected]>`,+ subject: req.reportTitle,+ to: subscriber,+ html,+ })),+ );++ if (result.error) {+ console.error(+ `Error sending status report update batch to ${recipients}: ${result.error}`,+ );+ }}- throw result.error;+ console.log(+ `Sent status report update email to ${req.to.length} subscribers`,+ );} catch (err) {console.error(`Error sending status report update email to ${req.to}`,diff --git a/packages/tinybird/datasources/mv__http_uptime_7d__v1.datasource b/packages/tinybird/datasources/mv__http_uptime_7d__v1.datasourcenew file mode 100644index 000000000..b112b173f--- /dev/null+++ b/packages/tinybird/datasources/mv__http_uptime_7d__v1.datasource@@ -0,0 +1,13 @@+# Data Source created from Pipe 'aggregate__http_uptime_7d__v1'++SCHEMA >+ `time` DateTime,+ `region` LowCardinality(String),+ `requestStatus` Nullable(String),+ `monitorId` String,+ `workspaceId` String++ENGINE "MergeTree"+ENGINE_PARTITION_KEY "toYYYYMM(time)"+ENGINE_SORTING_KEY "monitorId, time"+ENGINE_TTL "time + toIntervalDay(7)"diff --git a/packages/tinybird/datasources/mv__tcp_uptime_7d__v1.datasource b/packages/tinybird/datasources/mv__tcp_uptime_7d__v1.datasourcenew file mode 100644index 000000000..331501b9e--- /dev/null+++ b/packages/tinybird/datasources/mv__tcp_uptime_7d__v1.datasource@@ -0,0 +1,13 @@+# Data Source created from Pipe 'aggregate__tcp_uptime_7d__v1'++SCHEMA >+ `time` DateTime,+ `region` String,+ `requestStatus` Nullable(String),+ `monitorId` Int32,+ `workspaceId` Int32++ENGINE "MergeTree"+ENGINE_PARTITION_KEY "toYYYYMM(time)"+ENGINE_SORTING_KEY "monitorId, time"+ENGINE_TTL "time + toIntervalDay(7)"diff --git a/packages/tinybird/pipes/aggregate__http_uptime_7d__v1.pipe b/packages/tinybird/pipes/aggregate__http_uptime_7d__v1.pipenew file mode 100644index 000000000..7d5c21b64--- /dev/null+++ b/packages/tinybird/pipes/aggregate__http_uptime_7d__v1.pipe@@ -0,0 +1,15 @@+NODE aggregate+SQL >++ SELECT+ toDateTime(fromUnixTimestamp64Milli(cronTimestamp)) AS time,+ region,+ requestStatus,+ monitorId,+ workspaceId+ FROM ping_response__v8++TYPE materialized+DATASOURCE mv__http_uptime_7d__v1++diff --git a/packages/tinybird/pipes/aggregate__tcp_uptime_7d__v1.pipe b/packages/tinybird/pipes/aggregate__tcp_uptime_7d__v1.pipenew file mode 100644index 000000000..cb3a96c83--- /dev/null+++ b/packages/tinybird/pipes/aggregate__tcp_uptime_7d__v1.pipe@@ -0,0 +1,15 @@+NODE aggregate+SQL >++ SELECT+ toDateTime(fromUnixTimestamp64Milli(cronTimestamp)) AS time,+ region,+ requestStatus,+ monitorId,+ workspaceId+ FROM tcp_response__v0++TYPE materialized+DATASOURCE mv__tcp_uptime_7d__v1++diff --git a/packages/tinybird/pipes/endpoint__http_uptime_7d__v1.pipe b/packages/tinybird/pipes/endpoint__http_uptime_7d__v1.pipenew file mode 100644index 000000000..1924c23cb--- /dev/null+++ b/packages/tinybird/pipes/endpoint__http_uptime_7d__v1.pipe@@ -0,0 +1,21 @@+TAGS "http"++NODE endpoint+SQL >++ %+ SELECT+ toStartOfInterval(time, INTERVAL {{ String(interval, '30', required=True) }} minute) AS interval,+ countIf(requestStatus = 'success') AS success,+ countIf(requestStatus = 'degraded') AS degraded,+ countIf(requestStatus = 'error') AS error+ FROM mv__http_uptime_7d__v1+ WHERE+ monitorId = {{ String(monitorId, '1', required=True) }}+ {% if fromDate %} AND time >= parseDateTimeBestEffortOrNull({{ String(fromDate) }}) {% end %}+ {% if toDate %} AND time <= parseDateTimeBestEffortOrNull({{ String(toDate) }}) {% end %}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}+ GROUP BY interval+ ORDER BY interval DESC++diff --git a/packages/tinybird/pipes/endpoint__tcp_uptime_7d__v1.pipe b/packages/tinybird/pipes/endpoint__tcp_uptime_7d__v1.pipenew file mode 100644index 000000000..5815b90f5--- /dev/null+++ b/packages/tinybird/pipes/endpoint__tcp_uptime_7d__v1.pipe@@ -0,0 +1,21 @@+TAGS "http"++NODE endpoint+SQL >++ %+ SELECT+ toStartOfInterval(time, INTERVAL {{ String(interval, '30', required=True) }} minute) AS interval,+ countIf(requestStatus = 'success') AS success,+ countIf(requestStatus = 'degraded') AS degraded,+ countIf(requestStatus = 'error') AS error+ FROM mv__tcp_uptime_7d__v1+ WHERE+ monitorId = {{ String(monitorId, '4433', required=True) }}+ {% if fromDate %} AND time >= parseDateTimeBestEffortOrNull({{ String(fromDate) }}) {% end %}+ {% if toDate %} AND time <= parseDateTimeBestEffortOrNull({{ String(toDate) }}) {% end %}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}+ GROUP BY interval+ ORDER BY interval DESC++diff --git a/packages/tinybird/src/client.ts b/packages/tinybird/src/client.tsindex 5acf893d7..93f67a47b 100644--- a/packages/tinybird/src/client.ts+++ b/packages/tinybird/src/client.ts@@ -1144,6 +1144,25 @@ export class OSTinybird {});}+ public get httpUptimeWeekly() {+ return this.tb.buildPipe({+ pipe: "endpoint__http_uptime_7d__v1",+ parameters: z.object({+ monitorId: z.string(),+ fromDate: z.string().optional(),+ toDate: z.string().optional(),+ regions: z.enum(flyRegions).array().optional(),+ interval: z.number().int().optional(),+ }),+ data: z.object({+ interval: z.coerce.date(),+ success: z.number().int(),+ degraded: z.number().int(),+ error: z.number().int(),+ }),+ });+ }+public get httpUptime30d() {return this.tb.buildPipe({pipe: "endpoint__http_uptime_30d__v1",@@ -1163,6 +1182,25 @@ export class OSTinybird {});}+ public get tcpUptimeWeekly() {+ return this.tb.buildPipe({+ pipe: "endpoint__tcp_uptime_7d__v1",+ parameters: z.object({+ monitorId: z.string(),+ fromDate: z.string().optional(),+ toDate: z.string().optional(),+ regions: z.enum(flyRegions).array().optional(),+ interval: z.number().int().optional(),+ }),+ data: z.object({+ interval: z.coerce.date(),+ success: z.number().int(),+ degraded: z.number().int(),+ error: z.number().int(),+ }),+ });+ }+public get tcpUptime30d() {return this.tb.buildPipe({pipe: "endpoint__tcp_uptime_30d__v1",