Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
feat(dashboard): show per-region latency spread as range plots (#2917)
Maximilian Kaskef7284ebfa91b
diff --git a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsxindex eaecd0af9..4fe52c33a 100644--- a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx+++ b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx@@ -1,27 +1,26 @@"use client";-import {- Tabs,- TabsContent,- TabsList,- TabsTrigger,-} from "@openstatus/ui/components/ui/tabs";import { useQuery } from "@tanstack/react-query";import { endOfDay } from "date-fns";import { useParams } from "next/navigation";import { useQueryStates } from "nuqs";-import React, { useEffect, useMemo } from "react";+import React, { useEffect } from "react";import { toast } from "sonner";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 {+ EmptyStateContainer,+ EmptyStateDescription,+ EmptyStateTitle,+} from "@/components/content/empty-state";import {Section,SectionDescription,SectionGroup,SectionHeader,+ SectionHeaderRow,SectionTitle,} from "@/components/content/section";import { ButtonReset } from "@/components/controls-search/button-reset";@@ -30,12 +29,13 @@ import { DropdownInterval } from "@/components/controls-search/dropdown-intervalimport { DropdownPercentile } from "@/components/controls-search/dropdown-percentile";import { DropdownPeriod } from "@/components/controls-search/dropdown-period";import { AuditLogsWrapper } from "@/components/data-table/audit-logs/wrapper";-import { getColumns as getRegionColumns } from "@/components/data-table/response-logs/regions/columns";+import {+ RegionsDataTable,+ RegionsLegend,+} from "@/components/data-table/response-logs/regions/data-table";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 { DataTablePagination } from "@/components/ui/data-table/data-table-pagination";import {FREE_MAX_PERIOD,isPaidPeriod,@@ -98,54 +98,58 @@ export function Client() {enabled: !!monitor,} as const;- const { data: regionTimeline } = useQuery(regionTimelineQuery);+ const { data: regionTimeline, isError: isRegionTimelineError } =+ useQuery(regionTimelineQuery);++ // free plans ignore the region filter server-side, so they keep every row+ const filtersRegions =+ workspace?.plan !== "free" && !!selectedRegions?.length;const regionMetrics: RegionMetric[] = React.useMemo(() => {+ const configured = [+ ...(monitor?.regions ?? []),+ ...(monitor?.privateLocations?.map((location) =>+ location.id.toString(),+ ) ?? []),+ ];return mapRegionMetrics(regionTimeline,- [- ...(monitor?.regions ?? []),- ...(monitor?.privateLocations?.map((location) =>- location.id.toString(),- ) ?? []),- ],- percentile,+ filtersRegions+ ? configured.filter((region) => selectedRegions?.includes(region))+ : configured,);- }, [regionTimeline, monitor, percentile]);-- const regionColumns = useMemo(- () => getRegionColumns(monitor?.privateLocations ?? []),- [monitor?.privateLocations],- );+ }, [regionTimeline, monitor, filtersRegions, selectedRegions]);if (!monitor) return null;return (<SectionGroup><Section>- <SectionHeader>- <SectionTitle>{monitor.name}</SectionTitle>- <SectionDescription>- {monitor.jobType === "http" ? (- <a href={monitor.url} target="_blank" rel="noopener noreferrer">- {monitor.url}- </a>- ) : (- monitor.url- )}- </SectionDescription>- </SectionHeader>- <div className="flex flex-wrap gap-2">+ <SectionHeaderRow>+ <SectionHeader>+ <SectionTitle>{monitor.name}</SectionTitle>+ <SectionDescription className="truncate">+ {monitor.jobType === "http" ? (+ <a href={monitor.url} target="_blank" rel="noopener noreferrer">+ {monitor.url}+ </a>+ ) : (+ monitor.url+ )}+ </SectionDescription>+ </SectionHeader><div>- <DropdownPeriod /> including{" "}- <CommandRegion- regions={monitor.regions}- privateLocations={monitor.privateLocations}+ <ButtonReset+ only={["period", "regions", "percentile", "interval"]}/></div>- <div>- <ButtonReset only={["period", "regions"]} />- </div>+ </SectionHeaderRow>+ <div>+ <DropdownPeriod /> including{" "}+ <CommandRegion+ regions={monitor.regions}+ privateLocations={monitor.privateLocations}+ /></div><GlobalUptimeSectionmonitorId={id}@@ -173,19 +177,13 @@ export function Client() {<SectionHeader><SectionTitle>Latency</SectionTitle><SectionDescription>- Response time across all the regions+ Response time across the selected regions</SectionDescription></SectionHeader>- <div className="flex flex-wrap gap-2">- <div>- The <DropdownPercentile />{" "}- <PopoverQuantile>quantile</PopoverQuantile> within a{" "}- <DropdownInterval />{" "}- <PopoverResolution>resolution</PopoverResolution>- </div>- <div>- <ButtonReset only={["percentile", "interval"]} />- </div>+ <div>+ The <DropdownPercentile /> <PopoverQuantile>quantile</PopoverQuantile>{" "}+ within a <DropdownInterval />{" "}+ <PopoverResolution>resolution</PopoverResolution></div>{monitor.jobType === "http" ? (<ChartAreaTimingPhases@@ -212,60 +210,30 @@ export function Client() {<SectionHeader><SectionTitle>Regions</SectionTitle><SectionDescription>- Every selected region's latency trend+ Response time spread per selected region</SectionDescription></SectionHeader>- <div className="flex flex-wrap gap-2">+ <div className="flex flex-wrap items-center justify-between gap-x-4 gap-y-2"><div>- The <DropdownPercentile />{" "}- <PopoverQuantile>quantile</PopoverQuantile> trend over the{" "}- <DropdownPeriod />- </div>- <div>- <ButtonReset only={["percentile", "period"]} />+ Latency spread over the <DropdownPeriod /></div>+ <RegionsLegend degradedAfter={monitor.degradedAfter} /></div>- <Tabs defaultValue="table">- <TabsList>- <TabsTrigger value="table">Table</TabsTrigger>- <TabsTrigger value="chart">Chart</TabsTrigger>- </TabsList>- <TabsContent value="table">- <DataTable- data={regionMetrics}- columns={regionColumns}- paginationComponent={({ table }) => (- <DataTablePagination table={table} />- )}- />- </TabsContent>- <TabsContent value="chart">- <ChartLineRegions- className="mt-3"- regions={regionMetrics.map((region) => region.region)}- privateLocations={monitor?.privateLocations ?? []}- 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>+ {isRegionTimelineError ? (+ <EmptyStateContainer>+ <EmptyStateTitle>Couldn't load region metrics</EmptyStateTitle>+ <EmptyStateDescription>+ Try again in a moment or pick another period.+ </EmptyStateDescription>+ </EmptyStateContainer>+ ) : (+ <RegionsDataTable+ data={regionMetrics}+ privateLocations={monitor.privateLocations ?? []}+ loading={!regionTimeline}+ degradedAfter={monitor.degradedAfter}+ />+ )}</Section><Section><SectionHeader>diff --git a/apps/dashboard/src/components/chart/chart-line-region.tsx b/apps/dashboard/src/components/chart/chart-line-region.tsxdeleted file mode 100644index f8ab945db..000000000--- a/apps/dashboard/src/components/chart/chart-line-region.tsx+++ /dev/null@@ -1,93 +0,0 @@-"use client";--import {- type ChartConfig,- ChartContainer,- ChartTooltip,- ChartTooltipContent,-} from "@openstatus/ui/components/ui/chart";-import { cn } from "@openstatus/ui/lib/utils";-import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";--import { ChartTooltipNumber } from "./chart-tooltip-number";--const chartConfig = {- latency: {- label: "Latency",- color: "var(--success)",- },-} satisfies ChartConfig;--export type TrendPoint = {- timestamp: number; // unix millis- latency: number; // milliseconds-};--export function ChartLineRegion({- className,- data,-}: {- className?: string;- data: TrendPoint[];-}) {- const trendData = data ?? [];-- const chartData = trendData.map((d) => ({- timestamp: new Date(d.timestamp).toLocaleString("default", {- hour: "numeric",- minute: "numeric",- day: "numeric",- month: "short",- }),- latency: d.latency,- }));-- return (- <ChartContainer- config={chartConfig}- className={cn("h-[100px] w-full", className)}- >- <LineChart- accessibilityLayer- data={chartData}- margin={{- left: 12,- right: 12,- }}- >- <CartesianGrid vertical={false} />- <XAxis dataKey="timestamp" hide />- <ChartTooltip- cursor={false}- content={- <ChartTooltipContent- className="w-[180px]"- formatter={(value, name) => (- <ChartTooltipNumber- chartConfig={chartConfig}- value={value}- name={name}- />- )}- />- }- />- <Line- dataKey="latency"- type="monotone"- stroke="var(--color-latency)"- strokeWidth={2}- dot={false}- />- <YAxis- domain={["dataMin", "dataMax"]}- tickLine={false}- axisLine={false}- tickMargin={8}- orientation="right"- tickFormatter={(value) => `${value}ms`}- />- </LineChart>- </ChartContainer>- );-}diff --git a/apps/dashboard/src/components/chart/chart-line-regions.tsx b/apps/dashboard/src/components/chart/chart-line-regions.tsxdeleted file mode 100644index 40d97b184..000000000--- a/apps/dashboard/src/components/chart/chart-line-regions.tsx+++ /dev/null@@ -1,133 +0,0 @@-"use client";--import type { PrivateLocation } from "@openstatus/db/src/schema";-import { monitorRegions } from "@openstatus/db/src/schema/constants";-import { getRegionInfo } from "@openstatus/regions";-import {- type ChartConfig,- ChartContainer,- ChartLegend,- ChartLegendContent,- ChartTooltip,- ChartTooltipContent,-} from "@openstatus/ui/components/ui/chart";-import { useIsMobile } from "@openstatus/ui/hooks/use-mobile";-import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";--import { getRegionColor } from "@/data/regions";-import { cn } from "@/lib/utils";--import { ChartTooltipNumber } from "./chart-tooltip-number";--function getChartConfig(privateLocations?: PrivateLocation[]) {- return [- ...monitorRegions,- ...(privateLocations?.map((location) => location.id.toString()) ?? []),- ].reduce((config, region) => {- const privateLocation = privateLocations?.find(- (location) => String(location.id) === String(region),- );- const regionInfo = getRegionInfo(region, {- location: privateLocation?.name,- });- const color = getRegionColor(region);-- if (regionInfo && color) {- config[region] = {- label: `${regionInfo.location} (${regionInfo.provider})`,- color,- };- }-- return config;- }, {} as ChartConfig) satisfies ChartConfig;-}--export type TrendPoint = {- timestamp: number; // unix millis- [key: string]: number; // milliseconds-};--export function ChartLineRegions({- className,- data,- regions,- privateLocations,-}: {- className?: string;- data: TrendPoint[];- regions: string[] | undefined;- privateLocations?: PrivateLocation[];-}) {- const isMobile = useIsMobile();- const trendData = data ?? [];- const chartConfig = getChartConfig(privateLocations);- 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`}- />- {regions && regions.length <= 6 && !isMobile ? (- <ChartLegend- className="flex-wrap"- content={<ChartLegendContent className="text-nowrap" />}- />- ) : null}- </LineChart>- </ChartContainer>- );-}diff --git a/apps/dashboard/src/components/content/composer.tsx b/apps/dashboard/src/components/content/composer.tsxindex 0e99767fb..2be7684bc 100644--- a/apps/dashboard/src/components/content/composer.tsx+++ b/apps/dashboard/src/components/content/composer.tsx@@ -33,8 +33,8 @@ import {} from "react";import { ProcessMessage } from "@/components/content/process-message";-import { useHydrated } from "@/hooks/use-hydrated";import { useComposedRefs } from "@/lib/composition";+import { isKeyboardOwned, useModifierKey } from "@/lib/keyboard";type ComposerView = "write" | "preview";@@ -113,14 +113,7 @@ function useFocusOnMount() {function isPreviewHotkey(e: KeyboardEvent) {if (e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return false;if (e.key.toLowerCase() !== "e" || e.isComposing || e.repeat) return false;- return !(- e.target instanceof HTMLElement &&- (e.target.isContentEditable ||- e.target.matches("input, textarea, select") ||- e.target.closest(- '[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="combobox"]',- ))- );+ return !isKeyboardOwned(e.target);}// With several composers on a page (incident notes and postmortem) the key@@ -128,14 +121,6 @@ function isPreviewHotkey(e: KeyboardEvent) {const composers: Array<() => void> = [];let activeComposer: (() => void) | null = null;-/** "⌘" on Apple platforms, "Ctrl" elsewhere; ⌘ until hydrated. */-function useModifierKey() {- const hydrated = useHydrated();- return hydrated && !/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)- ? "Ctrl"- : "⌘";-}-function useComposer() {const ctx = useContext(ComposerContext);if (!ctx)diff --git a/apps/dashboard/src/components/content/range-plot.tsx b/apps/dashboard/src/components/content/range-plot.tsxnew file mode 100644index 000000000..c75e86e53--- /dev/null+++ b/apps/dashboard/src/components/content/range-plot.tsx@@ -0,0 +1,291 @@+import { cn } from "@openstatus/ui/lib/utils";+import { type VariantProps, cva } from "class-variance-authority";+import type * as React from "react";++/*+ * Every part is positioned in CSS from `--max` (set once on `RangePlot`) and+ * its own `--value`, so rows on the same `max` share one axis without context.+ * Values past `max` clamp to the edge; flag them with `RangePlotOverflow`.+ */+const AT = "left-[calc(min(var(--value),var(--max))/var(--max)*100%)]";++function vars(values: Record<string, number>) {+ return Object.fromEntries(+ Object.entries(values).map(([key, value]) => [`--${key}`, value]),+ ) as React.CSSProperties;+}++export function RangePlot({+ max,+ className,+ style,+ ...props+}: React.ComponentProps<"div"> & { max: number }) {+ return (+ <div+ data-slot="range-plot"+ className={cn("@container relative h-5 w-full", className)}+ style={{ ...vars({ max }), ...style }}+ {...props}+ />+ );+}++/** Vertical lines at 0, half and max; bleeds into the cell padding so stacked rows join. */+export function RangePlotGrid({+ className,+ ...props+}: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="range-plot-grid"+ aria-hidden+ className={cn(+ "*:bg-border pointer-events-none absolute inset-x-0 -inset-y-2 *:absolute *:inset-y-0 *:w-px",+ className,+ )}+ {...props}+ >+ <div className="left-0" />+ <div className="left-1/2" />+ <div className="right-0" />+ </div>+ );+}++/** Axis labels for a header cell: 0, half and max with the unit. */+export function RangePlotAxis({+ max,+ unit,+ className,+ ...props+}: React.ComponentProps<"div"> & { max: number; unit?: string }) {+ return (+ <div+ data-slot="range-plot-axis"+ className={cn(+ "text-muted-foreground relative h-4 w-full font-mono text-xs font-normal tabular-nums",+ className,+ )}+ {...props}+ >+ <span className="absolute left-0">0</span>+ <span className="absolute left-1/2 -translate-x-1/2">{max / 2}</span>+ <span className="absolute right-0">+ {max}+ {unit}+ </span>+ </div>+ );+}++/** Vertical line at a value (e.g. a degraded threshold); bleeds into the cell padding like the grid so rows join. */+export function RangePlotThreshold({+ value,+ className,+ style,+ ...props+}: React.ComponentProps<"div"> & { value: number }) {+ return (+ <div+ data-slot="range-plot-threshold"+ aria-hidden+ className={cn(+ "border-warning/60 pointer-events-none absolute -inset-y-2 w-0 border-l",+ AT,+ className,+ )}+ style={{ ...vars({ value }), ...style }}+ {...props}+ />+ );+}++const rangeVariants = cva(+ "absolute top-1/2 right-[calc(100%_-_min(var(--to),var(--max))/var(--max)*100%)] left-[calc(min(var(--from),var(--max))/var(--max)*100%)] -translate-y-1/2",+ {+ variants: {+ variant: {+ whisker: "bg-muted-foreground/50 h-px",+ box: "border-muted-foreground/50 bg-muted h-2.5 rounded-xs border",+ },+ },+ defaultVariants: { variant: "whisker" },+ },+);++export function RangePlotRange({+ from,+ to,+ variant,+ className,+ style,+ ...props+}: React.ComponentProps<"div"> &+ VariantProps<typeof rangeVariants> & { from: number; to: number }) {+ return (+ <div+ data-slot="range-plot-range"+ data-variant={variant ?? "whisker"}+ aria-hidden+ className={cn(rangeVariants({ variant }), className)}+ style={{ ...vars({ from, to }), ...style }}+ {...props}+ />+ );+}++const markerVariants = cva(+ "bg-foreground absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",+ {+ variants: {+ variant: {+ dot: "bg-muted-foreground size-2",+ tick: "h-3 w-0.5",+ end: "bg-muted-foreground h-2 w-px",+ },+ },+ defaultVariants: { variant: "dot" },+ },+);++export function RangePlotMarker({+ value,+ variant,+ className,+ style,+ ...props+}: React.ComponentProps<"div"> &+ VariantProps<typeof markerVariants> & { value: number }) {+ return (+ <div+ data-slot="range-plot-marker"+ data-variant={variant ?? "dot"}+ aria-hidden+ className={cn(markerVariants({ variant }), AT, className)}+ style={{ ...vars({ value }), ...style }}+ {...props}+ />+ );+}++/** Pinned to the right edge when a value runs past `max`. */+export function RangePlotOverflow({+ className,+ ...props+}: React.ComponentProps<"span">) {+ return (+ <span+ data-slot="range-plot-overflow"+ className={cn(+ "bg-foreground text-background absolute top-1/2 right-0 flex -translate-y-1/2 items-center gap-1 rounded-sm px-1 py-0.5 font-mono text-xs leading-none tabular-nums",+ className,+ )}+ {...props}+ />+ );+}++export function RangePlotEmpty({+ className,+ ...props+}: React.ComponentProps<"p">) {+ return (+ <p+ data-slot="range-plot-empty"+ className={cn(+ "text-muted-foreground absolute inset-0 flex items-center truncate pl-2 font-mono text-xs",+ className,+ )}+ {...props}+ />+ );+}++export function RangePlotLegend({+ className,+ ...props+}: React.ComponentProps<"ul">) {+ return (+ <ul+ data-slot="range-plot-legend"+ className={cn(+ "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs",+ className,+ )}+ {...props}+ />+ );+}++const swatchVariants = cva("bg-foreground shrink-0 rounded-full", {+ variants: {+ variant: {+ dot: "bg-muted-foreground size-2",+ tick: "h-3 w-0.5",+ end: "bg-muted-foreground h-2 w-px",+ box: "border-muted-foreground/50 bg-muted h-2.5 w-3 rounded-xs border",+ warning: "border-warning h-3 w-0 rounded-none border-l bg-transparent",+ },+ },+ defaultVariants: { variant: "dot" },+});++export function RangePlotLegendItem({+ variant,+ className,+ children,+ ...props+}: React.ComponentProps<"li"> & VariantProps<typeof swatchVariants>) {+ return (+ <li+ data-slot="range-plot-legend-item"+ className={cn("flex items-center gap-1.5", className)}+ {...props}+ >+ <span aria-hidden className={cn(swatchVariants({ variant }))} />+ {children}+ </li>+ );+}++/** px offsets inside the 26px icon: whisker ends, box edges and middle. */+const POSITIONS = { min: 2, start: 8, mid: 13, end: 18, max: 24 } as const;++const positionDotVariants = cva(+ "absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full",+ {+ variants: {+ variant: {+ default: "bg-foreground",+ warning: "bg-warning",+ },+ },+ defaultVariants: { variant: "default" },+ },+);++/** A miniature of the plot (whisker + box) with one dot where a percentile sits. */+export function RangePlotPositionIcon({+ at,+ variant,+ className,+ ...props+}: React.ComponentProps<"span"> &+ VariantProps<typeof positionDotVariants> & { at: keyof typeof POSITIONS }) {+ return (+ <span+ data-slot="range-plot-position-icon"+ aria-hidden+ className={cn("relative h-2.5 w-[26px] shrink-0", className)}+ {...props}+ >+ <span className="bg-muted-foreground/50 absolute inset-x-[2px] top-1/2 h-px -translate-y-1/2" />+ <span className="border-muted-foreground/50 bg-muted absolute top-1/2 left-[8px] h-1.5 w-2.5 -translate-y-1/2 rounded-xs border" />+ <span+ className={positionDotVariants({ variant })}+ style={{ left: POSITIONS[at] }}+ />+ </span>+ );+}diff --git a/apps/dashboard/src/components/content/section.tsx b/apps/dashboard/src/components/content/section.tsxindex bbf12c6b0..3c3b068a5 100644--- a/apps/dashboard/src/components/content/section.tsx+++ b/apps/dashboard/src/components/content/section.tsx@@ -18,7 +18,7 @@ export function SectionHeader({...props}: React.ComponentProps<"div">) {return (- <div className={cn("flex flex-col gap-1.5", className)} {...props}>+ <div className={cn("flex min-w-0 flex-col gap-1.5", className)} {...props}>{children}</div>);diff --git a/apps/dashboard/src/components/controls-search/button-reset.tsx b/apps/dashboard/src/components/controls-search/button-reset.tsxindex 83ed8f38d..5b1bc48ca 100644--- a/apps/dashboard/src/components/controls-search/button-reset.tsx+++ b/apps/dashboard/src/components/controls-search/button-reset.tsx@@ -2,19 +2,28 @@import { Close } from "@openstatus/icons";import { Button } from "@openstatus/ui/components/ui/button";+import { Kbd, KbdGroup } from "@openstatus/ui/components/ui/kbd";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@openstatus/ui/components/ui/tooltip";import { useRouter, useSearchParams } from "next/navigation";+import { useEffect, useEffectEvent } from "react";++import { isResetShortcut, useModifierKey } from "@/lib/keyboard";export function ButtonReset({ only }: { only?: string[] }) {const searchParams = useSearchParams();const router = useRouter();+ const modifier = useModifierKey();// Determine if at least one parameter that should be reset is present (or any parameter if `only` is undefined)const hasParamsToReset = only? only.some((key) => searchParams.has(key)): !!searchParams.toString();- if (!hasParamsToReset) return null;-const handleClick = () => {// Clone the current search params so we can mutate themconst params = new URLSearchParams(searchParams.toString());@@ -34,12 +43,38 @@ export function ButtonReset({ only }: { only?: string[] }) {}};+ const onShortcut = useEffectEvent(handleClick);++ useEffect(() => {+ if (!hasParamsToReset) return;+ const handleKeyDown = (e: KeyboardEvent) => {+ if (!isResetShortcut(e)) return;+ e.preventDefault();+ onShortcut();+ };+ window.addEventListener("keydown", handleKeyDown);+ return () => window.removeEventListener("keydown", handleKeyDown);+ }, [hasParamsToReset]);+if (!hasParamsToReset) return null;return (- <Button variant="ghost" size="sm" onClick={handleClick}>- <Close />- Reset- </Button>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button variant="outline" size="sm" onClick={handleClick}>+ <Close />+ Reset+ </Button>+ </TooltipTrigger>+ <TooltipContent className="flex items-center gap-2">+ Reset filters+ <KbdGroup>+ <Kbd>{modifier}</Kbd>+ <Kbd>Esc</Kbd>+ </KbdGroup>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>);}diff --git a/apps/dashboard/src/components/controls-search/command-region.tsx b/apps/dashboard/src/components/controls-search/command-region.tsxindex b2ff3ab99..62ff2aad0 100644--- a/apps/dashboard/src/components/controls-search/command-region.tsx+++ b/apps/dashboard/src/components/controls-search/command-region.tsx@@ -61,7 +61,11 @@ export function CommandRegion({return (<Popover><PopoverTrigger asChild>- <Button variant="outline" size="sm">+ <Button+ variant="ghost"+ size="sm"+ className="decoration-border hover:decoration-foreground data-[state=open]:decoration-foreground h-auto rounded-md px-1 py-0 text-[length:inherit] leading-[inherit] font-medium underline underline-offset-3 hover:bg-transparent dark:hover:bg-transparent"+ >{selectedRegions.length === regions.length? "All Regions": `${selectedRegions.length} Regions`}diff --git a/apps/dashboard/src/components/controls-search/dropdown-interval.tsx b/apps/dashboard/src/components/controls-search/dropdown-interval.tsxindex f69600cef..48f938109 100644--- a/apps/dashboard/src/components/controls-search/dropdown-interval.tsx+++ b/apps/dashboard/src/components/controls-search/dropdown-interval.tsx@@ -1,15 +1,15 @@"use client";-import { Check } from "@openstatus/icons";import { Button } from "@openstatus/ui/components/ui/button";import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuGroup,- DropdownMenuItem,- DropdownMenuLabel,- DropdownMenuTrigger,-} from "@openstatus/ui/components/ui/dropdown-menu";+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectLabel,+ SelectValue,+} from "@openstatus/ui/components/ui/select";+import { SelectTrigger } from "@radix-ui/react-select";import {parseAsNumberLiteral,parseAsStringLiteral,@@ -49,27 +49,31 @@ export function DropdownInterval() {const selected = Math.max(interval, min) as (typeof INTERVALS)[number];return (- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button variant="outline" size="sm">- {MAPPING[selected]}+ <Select+ value={String(selected)}+ onValueChange={(value) =>+ setInterval(Number(value) as (typeof INTERVALS)[number])+ }+ >+ <SelectTrigger asChild>+ <Button+ variant="ghost"+ size="sm"+ className="decoration-border hover:decoration-foreground data-[state=open]:decoration-foreground h-auto rounded-md px-1 py-0 text-[length:inherit] leading-[inherit] font-medium underline underline-offset-3 hover:bg-transparent dark:hover:bg-transparent"+ >+ <SelectValue /></Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="start">- <DropdownMenuGroup>- <DropdownMenuLabel className="text-muted-foreground text-xs font-medium">- Resolution- </DropdownMenuLabel>+ </SelectTrigger>+ <SelectContent position="item-aligned">+ <SelectGroup>+ <SelectLabel>Resolution</SelectLabel>{options.map((item) => (- <DropdownMenuItem key={item} onSelect={() => setInterval(item)}>+ <SelectItem key={item} value={String(item)}>{MAPPING[item]}- {selected === item ? (- <Check className="ml-auto shrink-0" />- ) : null}- </DropdownMenuItem>+ </SelectItem>))}- </DropdownMenuGroup>- </DropdownMenuContent>- </DropdownMenu>+ </SelectGroup>+ </SelectContent>+ </Select>);}diff --git a/apps/dashboard/src/components/controls-search/dropdown-percentile.tsx b/apps/dashboard/src/components/controls-search/dropdown-percentile.tsxindex 137630d52..66d045928 100644--- a/apps/dashboard/src/components/controls-search/dropdown-percentile.tsx+++ b/apps/dashboard/src/components/controls-search/dropdown-percentile.tsx@@ -1,16 +1,15 @@"use client";-import { Check } from "@openstatus/icons";import { Button } from "@openstatus/ui/components/ui/button";import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuGroup,- DropdownMenuItem,- DropdownMenuLabel,- DropdownMenuTrigger,-} from "@openstatus/ui/components/ui/dropdown-menu";-import { cn } from "@openstatus/ui/lib/utils";+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectLabel,+ SelectValue,+} from "@openstatus/ui/components/ui/select";+import { SelectTrigger } from "@radix-ui/react-select";import { parseAsStringLiteral, useQueryState } from "nuqs";import { PERCENTILES } from "@/data/metrics.client";@@ -24,31 +23,31 @@ export function DropdownPercentile() {);return (- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button variant="outline" size="sm" className="capitalize">- {percentile}+ <Select+ value={percentile}+ onValueChange={(value) =>+ setPercentile(value as (typeof PERCENTILES)[number])+ }+ >+ <SelectTrigger asChild>+ <Button+ variant="ghost"+ size="sm"+ className="decoration-border hover:decoration-foreground data-[state=open]:decoration-foreground h-auto rounded-md px-1 py-0 text-[length:inherit] leading-[inherit] font-medium capitalize underline underline-offset-3 hover:bg-transparent dark:hover:bg-transparent"+ >+ <SelectValue /></Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="start">- <DropdownMenuGroup>- <DropdownMenuLabel className="text-muted-foreground text-xs font-medium">- Percentile- </DropdownMenuLabel>+ </SelectTrigger>+ <SelectContent position="item-aligned">+ <SelectGroup>+ <SelectLabel>Percentile</SelectLabel>{PERCENTILES.map((item) => (- <DropdownMenuItem- key={item}- onSelect={() => setPercentile(item)}- className={cn("capitalize")}- >+ <SelectItem key={item} value={item} className="capitalize">{item}- {percentile === item ? (- <Check className="ml-auto shrink-0" />- ) : null}- </DropdownMenuItem>+ </SelectItem>))}- </DropdownMenuGroup>- </DropdownMenuContent>- </DropdownMenu>+ </SelectGroup>+ </SelectContent>+ </Select>);}diff --git a/apps/dashboard/src/components/controls-search/dropdown-period.tsx b/apps/dashboard/src/components/controls-search/dropdown-period.tsxindex a5ddc6dcb..e53d8bae2 100644--- a/apps/dashboard/src/components/controls-search/dropdown-period.tsx+++ b/apps/dashboard/src/components/controls-search/dropdown-period.tsx@@ -1,15 +1,16 @@"use client";-import { Check, Lock } from "@openstatus/icons";+import { Lock } from "@openstatus/icons";import { Button } from "@openstatus/ui/components/ui/button";import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuGroup,- DropdownMenuItem,- DropdownMenuLabel,- DropdownMenuTrigger,-} from "@openstatus/ui/components/ui/dropdown-menu";+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectLabel,+ SelectValue,+} from "@openstatus/ui/components/ui/select";+import { SelectTrigger } from "@radix-ui/react-select";import { useQuery } from "@tanstack/react-query";import { parseAsStringLiteral, useQueryState } from "nuqs";import { useState } from "react";@@ -53,40 +54,43 @@ export function DropdownPeriod() {return (<>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button variant="outline" size="sm">- {PERIOD_VALUES.find(({ value }) => value === period)?.label}+ <Select+ value={period}+ onValueChange={(value) => {+ const next = value as (typeof PERIODS)[number];+ if (isFree && isPaidPeriod(next)) setUpgradeOpen(true);+ else setPeriod(next);+ }}+ >+ <SelectTrigger asChild>+ <Button+ variant="ghost"+ size="sm"+ className="decoration-border hover:decoration-foreground data-[state=open]:decoration-foreground h-auto rounded-md px-1 py-0 text-[length:inherit] leading-[inherit] font-medium underline underline-offset-3 hover:bg-transparent dark:hover:bg-transparent"+ >+ <SelectValue /></Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="start">- <DropdownMenuGroup>- <DropdownMenuLabel className="text-muted-foreground text-xs font-medium">- Period- </DropdownMenuLabel>+ </SelectTrigger>+ <SelectContent position="item-aligned">+ <SelectGroup>+ <SelectLabel>Period</SelectLabel>{PERIOD_VALUES.map(({ value, label }) => {const locked = isFree && isPaidPeriod(value);return (- <DropdownMenuItem+ <SelectItemkey={value}+ value={value}data-locked={locked}- onSelect={() =>- locked ? setUpgradeOpen(true) : setPeriod(value)- }- className={"data-[locked=true]:opacity-70"}+ className="data-[locked=true]:opacity-70">{label}- {locked ? (- <Lock className="ml-auto shrink-0" />- ) : period === value ? (- <Check className="ml-auto shrink-0" />- ) : null}- </DropdownMenuItem>+ {locked ? <Lock className="ml-auto shrink-0" /> : null}+ </SelectItem>);})}- </DropdownMenuGroup>- </DropdownMenuContent>- </DropdownMenu>+ </SelectGroup>+ </SelectContent>+ </Select><UpgradeDialogopen={upgradeOpen}onOpenChange={setUpgradeOpen}diff --git a/apps/dashboard/src/components/data-table/response-logs/regions/columns.tsx b/apps/dashboard/src/components/data-table/response-logs/regions/columns.tsxindex e79350c40..88f359cdd 100644--- a/apps/dashboard/src/components/data-table/response-logs/regions/columns.tsx+++ b/apps/dashboard/src/components/data-table/response-logs/regions/columns.tsx@@ -1,146 +1,294 @@"use client";import type { PrivateLocation } from "@openstatus/db/src/schema";+import { ChevronRight } from "@openstatus/icons";import { formatRegionCode, getRegionInfo } from "@openstatus/regions";import {- Tooltip,- TooltipContent,- TooltipProvider,- TooltipTrigger,-} from "@openstatus/ui/components/ui/tooltip";+ HoverCard,+ HoverCardContent,+ HoverCardTrigger,+} from "@openstatus/ui/components/ui/hover-card";+import { Skeleton } from "@openstatus/ui/components/ui/skeleton";+import { cn } from "@openstatus/ui/lib/utils";import type { ColumnDef } from "@tanstack/react-table";-// import { toast } from "sonner";-import { useRouter } from "next/navigation";+import { useState } from "react";-import { ChartLineRegion } from "@/components/chart/chart-line-region";+import { IconCloudProvider } from "@/components/common/icon-cloud-provider";+import {+ RangePlot,+ RangePlotAxis,+ RangePlotEmpty,+ RangePlotGrid,+ RangePlotMarker,+ RangePlotOverflow,+ RangePlotPositionIcon,+ RangePlotRange,+ RangePlotThreshold,+} from "@/components/content/range-plot";import { TableCellNumber } from "@/components/data-table/table-cell-number";-import { QuickActions } from "@/components/dropdowns/quick-actions";import { DataTableColumnHeader } from "@/components/ui/data-table/data-table-column-header";import type { RegionMetric } from "@/data/region-metrics";-import { getActions } from "@/data/region-metrics.client";-function TrendCell({ trend }: { trend: RegionMetric["trend"] }) {- return <ChartLineRegion className="h-[50px]" data={trend} />;+const PERCENTILES = [+ { key: "p50", at: "min" },+ { key: "p75", at: "start" },+ { key: "p90", at: "mid" },+ { key: "p95", at: "end" },+ { key: "p99", at: "max" },+] as const;++type RegionInfo = ReturnType<typeof getRegionInfo>;++/** Provider icon, code and location; shared by the row and its tooltip so they read the same. */+function RegionLabel({+ region,+ city,+ className,+ ...props+}: React.ComponentProps<"div"> & {+ region: RegionInfo;+ /** City only, to fit the table column. */+ city?: boolean;+}) {+ return (+ <div className={cn("flex items-center gap-1", className)} {...props}>+ {/* codes repeat across providers (fly fra, koyeb fra) */}+ <IconCloudProvider+ provider={region.provider}+ className="text-muted-foreground size-3 shrink-0"+ />+ <span className="max-w-[90px] shrink-0 truncate font-mono">+ {formatRegionCode(region.code)}+ </span>+ <span+ className={cn(+ "text-muted-foreground ml-1 truncate font-sans",+ city && "hidden sm:inline",+ )}+ >+ {city ? region.location.split(",")[0] : region.location}+ </span>+ </div>+ );+}++function SpreadCell({+ metric,+ region,+ max,+ loading,+ degradedAfter,+}: {+ metric: RegionMetric;+ region: RegionInfo;+ max: number;+ loading: boolean;+ degradedAfter: number | null;+}) {+ const [open, setOpen] = useState(false);+ const { p50, p75, p90, p95, p99, buckets } = metric;+ const clipped = p99 > max;++ if (loading || buckets === 0) {+ return (+ <RangePlot max={max}>+ <RangePlotGrid />+ {degradedAfter != null && degradedAfter <= max ? (+ <RangePlotThreshold value={degradedAfter} />+ ) : null}+ {loading ? (+ <Skeleton className="absolute top-1/2 h-1 w-1/3 -translate-y-1/2" />+ ) : (+ <RangePlotEmpty>+ No checks from this region in the selected period+ </RangePlotEmpty>+ )}+ </RangePlot>+ );+ }++ return (+ // The whole cell opens the card; it anchors to the P90 tick so it sits above the markers.+ <HoverCard open={open}>+ {/* hit area bleeds over the cell padding and row border, so moving between rows never leaves a hover gap */}+ <div+ className="-mt-2 -mb-[9px] pt-2 pb-[9px]"+ onPointerEnter={() => setOpen(true)}+ onPointerLeave={() => setOpen(false)}+ >+ <RangePlot+ max={max}+ tabIndex={0}+ role="img"+ aria-label={`${formatRegionCode(region.code)}: ${PERCENTILES.map(+ ({ key }) => `${key.toUpperCase()} ${metric[key]} ms`,+ ).join(", ")}`}+ onFocus={() => setOpen(true)}+ onBlur={() => setOpen(false)}+ onKeyDown={(event) => {+ if (event.key === "Escape") setOpen(false);+ }}+ className="focus-visible:ring-ring/50 rounded-sm outline-none focus-visible:ring-[3px]"+ >+ <RangePlotGrid />+ {degradedAfter != null && degradedAfter <= max ? (+ <RangePlotThreshold value={degradedAfter} />+ ) : null}+ <RangePlotRange variant="whisker" from={p50} to={p99} />+ <RangePlotRange variant="box" from={p75} to={p95} />+ {clipped ? null : <RangePlotMarker value={p99} variant="end" />}+ <HoverCardTrigger asChild>+ {/* lifted over the overflow badge, ringed so it reads on top of it */}+ <RangePlotMarker+ value={p90}+ variant="tick"+ className={cn(clipped && "ring-background z-10 ring-2")}+ />+ </HoverCardTrigger>+ <RangePlotMarker value={p50} variant="dot" />+ {clipped ? (+ <RangePlotOverflow>+ {/* narrow plots keep only the chevron so the P90 tick stays visible */}+ <span className="@max-xs:hidden">P99 {p99}</span>+ <ChevronRight aria-hidden className="-mr-0.5 size-3" />+ </RangePlotOverflow>+ ) : null}+ </RangePlot>+ </div>+ {/* same card as the uptime cell; duration-0 so moving down the rows swaps cards instead of re-animating.+ Read-only and pointer-transparent: it mirrors the hovered plot, so the pointer passes through to the rows it covers */}+ <HoverCardContent+ side="top"+ className="border-border/50 pointer-events-none grid w-auto min-w-40 gap-1.5 rounded-lg p-0 px-2.5 py-1.5 text-xs shadow-xl duration-0"+ >+ <RegionLabel region={region} />+ <ul className="grid gap-1.5">+ {PERCENTILES.map(({ key, at }) => {+ const variant =+ degradedAfter != null && metric[key] > degradedAfter+ ? "warning"+ : "default";+ return (+ <li key={key} className="flex items-center gap-2">+ <RangePlotPositionIcon at={at} variant={variant} />+ <span className="text-muted-foreground font-mono">+ {key.toUpperCase()}+ </span>+ <TableCellNumber+ value={metric[key]}+ unit="ms"+ variant={variant}+ className="ml-auto pl-4 tabular-nums"+ />+ </li>+ );+ })}+ </ul>+ </HoverCardContent>+ </HoverCard>+ );}-export function getColumns(- privateLocations: PrivateLocation[],-): ColumnDef<RegionMetric>[] {+function percentileColumn(+ key: "p50" | "p90" | "p99",+ loading: boolean,+ degradedAfter: number | null,+): ColumnDef<RegionMetric> {+ return {+ id: key,+ // regions without data sort last instead of as 0 ms+ accessorFn: (row) => (row.buckets ? row[key] : undefined),+ sortUndefined: "last",+ header: ({ column }) => (+ <DataTableColumnHeader+ column={column}+ title={key.toUpperCase()}+ className="justify-end"+ />+ ),+ cell: ({ row }) =>+ loading ? (+ <Skeleton className="h-4 w-12" />+ ) : (+ <TableCellNumber+ value={row.original.buckets ? row.original[key] : undefined}+ variant={+ degradedAfter != null && row.original[key] > degradedAfter+ ? "warning"+ : "default"+ }+ unit="ms"+ empty="–"+ />+ ),+ enableHiding: false,+ meta: {+ cellClassName: "w-12 text-right",+ },+ };+}++export function getColumns({+ privateLocations,+ max,+ loading,+ degradedAfter,+}: {+ privateLocations: PrivateLocation[];+ max: number;+ loading: boolean;+ degradedAfter: number | null;+}): ColumnDef<RegionMetric>[] {return [{accessorKey: "region",header: "Region",cell: ({ row }) => {- const value = row.getValue("region");- if (typeof value === "string") {- const region = getRegionInfo(value, {- location: privateLocations.find(- (location) => String(location.id) === String(value),- )?.name,- });- return (- <TooltipProvider>- <Tooltip>- <TooltipTrigger className="flex h-[50px] items-center gap-1">- {region.flag}{" "}- <span className="max-w-[90px] truncate">- {formatRegionCode(region.code)}- </span>- </TooltipTrigger>- <TooltipContent side="left">- {region.location} ({region.provider})- </TooltipContent>- </Tooltip>- </TooltipProvider>- );- }- return null;- },- enableSorting: false,- enableHiding: false,- meta: {- cellClassName: "w-24 font-mono",- },- },- {- accessorKey: "trend",- header: "Trend",- cell: ({ row }) => {- return <TrendCell trend={row.original.trend} />;+ const region = getRegionInfo(row.original.region, {+ location: privateLocations.find(+ (location) => String(location.id) === row.original.region,+ )?.name,+ });+ return (+ <RegionLabel+ region={region}+ city+ data-empty={!loading && row.original.buckets === 0}+ className="data-[empty=true]:text-muted-foreground max-w-56"+ />+ );},enableSorting: false,enableHiding: false,meta: {- cellClassName: "w-full min-w-[200px] max-w-full",- },- },- {- accessorKey: "p50",- header: ({ column }) => (- <DataTableColumnHeader column={column} title="P50" />- ),- cell: ({ row }) => {- return <TableCellNumber value={row.getValue("p50")} unit="ms" />;- },- enableHiding: false,- meta: {- cellClassName: "w-12",- },- },- {- accessorKey: "p90",- header: ({ column }) => (- <DataTableColumnHeader column={column} title="P90" />- ),- cell: ({ row }) => {- return <TableCellNumber value={row.getValue("p90")} unit="ms" />;- },- enableHiding: false,- meta: {- cellClassName: "w-12",+ cellClassName: "w-24 font-mono sm:w-56",},},{- accessorKey: "p99",- header: ({ column }) => (- <DataTableColumnHeader column={column} title="P99" />+ id: "spread",+ header: () => (loading ? null : <RangePlotAxis max={max} unit="ms" />),+ cell: ({ row }) => (+ <SpreadCell+ metric={row.original}+ region={getRegionInfo(row.original.region, {+ location: privateLocations.find(+ (location) => String(location.id) === row.original.region,+ )?.name,+ })}+ max={max}+ loading={loading}+ degradedAfter={degradedAfter}+ />),- cell: ({ row }) => {- return <TableCellNumber value={row.getValue("p99")} unit="ms" />;- },+ enableSorting: false,enableHiding: false,meta: {- cellClassName: "w-12",- },- },- {- id: "actions",- cell: ({ row }) => {- // NOTE: works, but is not very react-esque- // eslint-disable-next-line react-hooks/rules-of-hooks- const router = useRouter();- const actions = getActions({- filter: async () => {- router.push(`?regions=${row.original.region}`);- },- // TODO: add triggerById in TRPC client- // trigger: async () => {- // console.log(row.original);- // const promise = new Promise((resolve) => setTimeout(resolve, 1000));- // toast.promise(promise, {- // loading: "Checking...",- // success: "Success",- // error: "Failed",- // });- // await promise;- // },- });- return <QuickActions actions={actions} />;- },- meta: {- headerClassName: "w-12",- cellClassName: "text-right",+ headerClassName: "px-4",+ cellClassName: "relative w-full min-w-[200px] max-w-full px-4",},},+ percentileColumn("p50", loading, degradedAfter),+ percentileColumn("p90", loading, degradedAfter),+ percentileColumn("p99", loading, degradedAfter),];}diff --git a/apps/dashboard/src/components/data-table/response-logs/regions/data-table.tsx b/apps/dashboard/src/components/data-table/response-logs/regions/data-table.tsxnew file mode 100644index 000000000..b02da9e40--- /dev/null+++ b/apps/dashboard/src/components/data-table/response-logs/regions/data-table.tsx@@ -0,0 +1,80 @@+"use client";++import type { PrivateLocation } from "@openstatus/db/src/schema";+import { cn } from "@openstatus/ui/lib/utils";+import { useMemo } from "react";++import {+ RangePlotLegend,+ RangePlotLegendItem,+} from "@/components/content/range-plot";+import { DataTable } from "@/components/ui/data-table/data-table";+import { getRegionAxisMax } from "@/data/metrics.client";+import type { RegionMetric } from "@/data/region-metrics";++import { getColumns } from "./columns";++export function RegionsLegend({+ degradedAfter,+ className,+ ...props+}: React.ComponentProps<typeof RangePlotLegend> & {+ degradedAfter?: number | null;+}) {+ return (+ <RangePlotLegend className={className} {...props}>+ <RangePlotLegendItem variant="dot">P50</RangePlotLegendItem>+ <RangePlotLegendItem variant="box">P75 – P95</RangePlotLegendItem>+ <RangePlotLegendItem variant="tick">P90</RangePlotLegendItem>+ <RangePlotLegendItem variant="end">P99</RangePlotLegendItem>+ {degradedAfter != null ? (+ <RangePlotLegendItem variant="warning">+ Degraded+ <span className="text-muted-foreground font-mono tabular-nums">+ >{degradedAfter}ms+ </span>+ </RangePlotLegendItem>+ ) : null}+ </RangePlotLegend>+ );+}++export function RegionsDataTable({+ data,+ privateLocations,+ loading,+ degradedAfter,+}: {+ data: RegionMetric[];+ privateLocations: PrivateLocation[];+ loading: boolean;+ /** Values above it render in the warning color. */+ degradedAfter: number | null;+}) {+ const max = useMemo(() => getRegionAxisMax(data), [data]);+ const columns = useMemo(+ () => getColumns({ privateLocations, max, loading, degradedAfter }),+ [privateLocations, max, loading, degradedAfter],+ );++ return (+ // A hovered or keyboard-focused row lifts: the others fade.+ <div+ className={cn(+ // flush with the section text instead of inset by the cell padding+ "[&_tr>*:first-child]:pl-0 [&_tr>*:last-child]:pr-0",+ // the plot hover area bleeds past the last row; clip it instead of scrolling+ "[&_[data-slot=table-container]]:overflow-y-hidden",+ "[&_tbody_tr]:transition-[opacity,background-color] [&_tbody_tr]:duration-150 [&_tbody_tr]:ease-out",+ "[&_tbody:has(tr:hover,:focus-visible)_tr:not(:hover,:has(:focus-visible))]:opacity-50",+ )}+ >+ <DataTable+ data={data}+ columns={columns}+ pagination={{ pageIndex: 0, pageSize: Math.max(data.length, 1) }}+ defaultSorting={[{ id: "p50", desc: false }]}+ />+ </div>+ );+}diff --git a/apps/dashboard/src/components/data-table/table-cell-number.tsx b/apps/dashboard/src/components/data-table/table-cell-number.tsxindex ccd99e910..77cfeb85c 100644--- a/apps/dashboard/src/components/data-table/table-cell-number.tsx+++ b/apps/dashboard/src/components/data-table/table-cell-number.tsx@@ -1,18 +1,36 @@+import { type VariantProps, cva } from "class-variance-authority";++import type { StatusVariant } from "@/components/common/status-dot";import { cn } from "@/lib/utils";import { TableCellEmpty } from "./table-cell-empty";+const tableCellNumberVariants = cva("font-mono", {+ variants: {+ variant: {+ default: "text-foreground",+ success: "text-success",+ warning: "text-warning",+ destructive: "text-destructive",+ info: "text-info",+ } satisfies Record<StatusVariant, string>,+ },+ defaultVariants: { variant: "default" },+});+export function TableCellNumber({value,className,unit,empty = "No data",+ variant,...props-}: React.ComponentProps<"div"> & {- value: unknown;- unit?: string;- empty?: string;-}) {+}: React.ComponentProps<"div"> &+ VariantProps<typeof tableCellNumberVariants> & {+ value: unknown;+ unit?: string;+ empty?: string;+ }) {const _value = Number(value);if (Number.isNaN(_value)) {return (@@ -23,7 +41,10 @@ export function TableCellNumber({}return (- <div className={cn("text-foreground font-mono", className)} {...props}>+ <div+ className={cn(tableCellNumberVariants({ variant }), className)}+ {...props}+ >{_value}{unit && <span className="text-muted-foreground p-0.5">{unit}</span>}</div>diff --git a/apps/dashboard/src/components/popovers/popover-quantile.tsx b/apps/dashboard/src/components/popovers/popover-quantile.tsxindex afdb48841..a49436fb4 100644--- a/apps/dashboard/src/components/popovers/popover-quantile.tsx+++ b/apps/dashboard/src/components/popovers/popover-quantile.tsx@@ -15,7 +15,7 @@ export function PopoverQuantile({<Popover><PopoverTriggerclassName={cn(- "decoration-muted-foreground/70 hover:decoration-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=open]:decoration-foreground dark:aria-invalid:ring-destructive/40 shrink-0 rounded-md p-0 underline decoration-dotted underline-offset-2 transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50",+ "decoration-muted-foreground/70 hover:decoration-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=open]:decoration-foreground dark:aria-invalid:ring-destructive/40 shrink-0 rounded-md p-0 underline decoration-dotted underline-offset-3 transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50",className,)}{...props}diff --git a/apps/dashboard/src/components/popovers/popover-resolution.tsx b/apps/dashboard/src/components/popovers/popover-resolution.tsxindex 94897a088..a16b9be0c 100644--- a/apps/dashboard/src/components/popovers/popover-resolution.tsx+++ b/apps/dashboard/src/components/popovers/popover-resolution.tsx@@ -15,7 +15,7 @@ export function PopoverResolution({<Popover><PopoverTriggerclassName={cn(- "decoration-muted-foreground/70 hover:decoration-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=open]:decoration-foreground dark:aria-invalid:ring-destructive/40 shrink-0 rounded-md p-0 underline decoration-dotted underline-offset-2 transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50",+ "decoration-muted-foreground/70 hover:decoration-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=open]:decoration-foreground dark:aria-invalid:ring-destructive/40 shrink-0 rounded-md p-0 underline decoration-dotted underline-offset-3 transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50",className,)}{...props}diff --git a/apps/dashboard/src/data/metrics.client.test.ts b/apps/dashboard/src/data/metrics.client.test.tsindex 3ba9fb785..95202dc46 100644--- a/apps/dashboard/src/data/metrics.client.test.ts+++ b/apps/dashboard/src/data/metrics.client.test.ts@@ -3,6 +3,7 @@ import { describe, it } from "@std/testing/bdd";import {getMonitorListMetrics,+ getRegionAxisMax,isPaidPeriod,mapMetrics,mapRegionMetrics,@@ -69,13 +70,24 @@ describe("mapRegionMetrics", () => {}it("returns empty sorted entries without a timeline", () => {- expect(mapRegionMetrics(undefined, ["iad", "ams"], "p50")).toEqual([- { region: "ams", p50: 0, p90: 0, p99: 0, trend: [] },- { region: "iad", p50: 0, p90: 0, p99: 0, trend: [] },+ expect(mapRegionMetrics(undefined, ["iad", "ams"])).toEqual([+ { region: "ams", p50: 0, p75: 0, p90: 0, p95: 0, p99: 0, buckets: 0 },+ { region: "iad", p50: 0, p75: 0, p90: 0, p95: 0, p99: 0, buckets: 0 },]);});- it("averages percentiles and reverses the trend per region", () => {+ it("keeps requested regions without data", () => {+ const timeline = {+ data: [row("iad", 1, 10, 20)],+ } as unknown as Timeline;+ const result = mapRegionMetrics(timeline, ["iad", "fra"]);+ expect(result.map((r) => [r.region, r.buckets])).toEqual([+ ["fra", 0],+ ["iad", 1],+ ]);+ });++ it("averages percentiles per region", () => {const timeline = {data: [row("iad", 2, 100, 300),@@ -85,25 +97,57 @@ describe("mapRegionMetrics", () => {],} as unknown as Timeline;- const result = mapRegionMetrics(timeline, ["ams", "iad"], "p99");+ const result = mapRegionMetrics(timeline, ["ams", "iad"]);expect(result.map((r) => r.region)).toEqual(["ams", "iad"]);const iad = result[1];expect(iad.p50).toBe(151);expect(iad.p99).toBe(350);- expect(iad.trend).toEqual([- { latency: 400, timestamp: 1, iad: 400 },- { latency: 300, timestamp: 2, iad: 300 },- ]);});it("treats missing percentile values as 0", () => {const timeline = {data: [row("ams", 1, 10, 20)],} as unknown as Timeline;- expect(mapRegionMetrics(timeline, ["ams"], "p75")[0].trend).toEqual([- { latency: 0, timestamp: 1, ams: 0 },- ]);+ expect(mapRegionMetrics(timeline, ["ams"])[0].p75).toBe(0);+ });+});++describe("getRegionAxisMax", () => {+ function metric(p90: number, p99: number, buckets = 1) {+ return { region: "x", p50: 0, p75: 0, p90, p95: 0, p99, buckets };+ }++ it("rounds the largest P99 up", () => {+ expect(getRegionAxisMax([metric(192, 301), metric(410, 556)])).toBe(600);+ });++ it("clips an outlier P99 but keeps every P90", () => {+ expect(+ getRegionAxisMax([metric(192, 301), metric(410, 1240), metric(177, 254)]),+ ).toBe(500);+ });++ it("adds headroom for the overflow badge when a P99 is clipped", () => {+ expect(+ getRegionAxisMax([metric(500, 600), metric(100, 200), metric(100, 2000)]),+ ).toBe(700);+ });++ it("draws an outlier normally once the rounded axis covers it", () => {+ const metrics = [50, 100, 100, 200, 201].map((p99) => metric(10, p99));+ const max = getRegionAxisMax(metrics);+ expect(max).toBe(300);+ expect(metrics.some((m) => m.p99 > max)).toBe(false);+ });++ it("averages the two middle P99s for an even count", () => {+ expect(getRegionAxisMax([metric(50, 100), metric(50, 210)])).toBe(300);+ });++ it("ignores regions without data", () => {+ expect(getRegionAxisMax([metric(0, 0, 0)])).toBe(100);+ expect(getRegionAxisMax([metric(50, 80), metric(0, 9000, 0)])).toBe(80);});});diff --git a/apps/dashboard/src/data/metrics.client.ts b/apps/dashboard/src/data/metrics.client.tsindex f7a4149a2..99e413dce 100644--- a/apps/dashboard/src/data/metrics.client.ts+++ b/apps/dashboard/src/data/metrics.client.ts@@ -121,79 +121,66 @@ export function mapUptime(status: RouterOutputs["tinybird"]["uptime"]) {/*** Transform Tinybird `metricsRegions` response into RegionMetric[] for UI.+ * Every requested region is returned, with `buckets: 0` when it has no data.*/export function mapRegionMetrics(timeline: RouterOutputs["tinybird"]["metricsRegions"] | undefined,regions: string[],- percentile: (typeof PERCENTILES)[number],): RegionMetric[] {- if (!timeline)- return (regions+ const map = new Map<string, RegionMetric>(+ [...regions].sort((a, b) => a.localeCompare(b))- .map((region) => ({+ .map((region) => [region,- p50: 0,- p90: 0,- p99: 0,- trend: [] as {- latency: number;- timestamp: number;- [key: string]: number;- }[],- })) ?? []) satisfies RegionMetric[];-- type TimelineRow = (typeof timeline.data)[number];-- const map = new Map<- string,- {- region: string;- p50: number;- p90: number;- p99: number;- trend: {- latency: number;- timestamp: number;- [key: string]: number;- }[];- }- >();-- (timeline.data as TimelineRow[])- .filter((row) => regions.includes(row.region))- .sort((a, b) => a.region.localeCompare(b.region))- .forEach((row) => {- const region = row.region;- const entry = map.get(region) ?? {- region,- p50: 0,- p90: 0,- p99: 0,- trend: [],- };-- entry.trend.push({- latency: row[PERCENTILE_MAP[percentile]] ?? 0,- timestamp: row.timestamp,- [region]: row[PERCENTILE_MAP[percentile]] ?? 0,- });-- entry.p50 += row.p50Latency ?? 0;- entry.p90 += row.p90Latency ?? 0;- entry.p99 += row.p99Latency ?? 0;-- map.set(region, entry);- });+ { region, p50: 0, p75: 0, p90: 0, p95: 0, p99: 0, buckets: 0 },+ ]),+ );++ for (const row of timeline?.data ?? []) {+ const entry = map.get(row.region);+ if (!entry) continue;+ entry.p50 += row.p50Latency ?? 0;+ entry.p75 += row.p75Latency ?? 0;+ entry.p90 += row.p90Latency ?? 0;+ entry.p95 += row.p95Latency ?? 0;+ entry.p99 += row.p99Latency ?? 0;+ entry.buckets++;+ }- map.forEach((entry) => {- const count = entry.trend.length || 1;- entry.trend.reverse();+ for (const entry of map.values()) {+ const count = entry.buckets || 1;entry.p50 = Math.round(entry.p50 / count);+ entry.p75 = Math.round(entry.p75 / count);entry.p90 = Math.round(entry.p90 / count);+ entry.p95 = Math.round(entry.p95 / count);entry.p99 = Math.round(entry.p99 / count);- });+ }- return Array.from(map.values()) as RegionMetric[];+ return Array.from(map.values());+}++/**+ * Shared axis end for the regions range plot, rounded up to a readable value.+ * A P99 more than twice the median P99 is an outlier: the axis ignores it+ * instead of squashing every other region to the left, plus 10% headroom for+ * the overflow badge. Every P90 fits. An outlier that still lands under the+ * rounded axis is drawn normally; the cell flags only `p99 > max`.+ */+export function getRegionAxisMax(metrics: RegionMetric[]) {+ const reporting = metrics.filter((m) => m.buckets > 0);+ if (!reporting.length) return 100;+ const p99s = reporting.map((m) => m.p99).sort((a, b) => a - b);+ const mid = p99s.length / 2;+ const median =+ p99s.length % 2 ? p99s[Math.floor(mid)] : (p99s[mid - 1] + p99s[mid]) / 2;+ const fits = p99s.filter((p99) => p99 <= median * 2);+ // headroom on the right keeps the overflow badge clear of the markers+ const value =+ Math.max(...fits, ...reporting.map((m) => m.p90)) *+ (fits.length < p99s.length ? 1.1 : 1);+ if (value <= 0) return 100;+ const step = 10 ** Math.floor(Math.log10(value));+ return Math.ceil(value / step) * step;}export function mapGlobalMetrics(diff --git a/apps/dashboard/src/data/region-metrics.client.ts b/apps/dashboard/src/data/region-metrics.client.tsdeleted file mode 100644index 8c5d7a70f..000000000--- a/apps/dashboard/src/data/region-metrics.client.ts+++ /dev/null@@ -1,27 +0,0 @@-import { Filter } from "@openstatus/icons";--export const actions = [- {- id: "filter",- label: "Filter",- icon: Filter,- variant: "default" as const,- },- // {- // id: "trigger",- // label: "Trigger",- // icon: Zap,- // variant: "default" as const,- // },-] as const;--export type RegionMetricAction = (typeof actions)[number];--export const getActions = (- props: Partial<Record<RegionMetricAction["id"], () => Promise<void> | void>>,-): (RegionMetricAction & { onClick?: () => Promise<void> | void })[] => {- return actions.map((action) => ({- ...action,- onClick: props[action.id as keyof typeof props],- }));-};diff --git a/apps/dashboard/src/data/region-metrics.ts b/apps/dashboard/src/data/region-metrics.tsindex b0bf6af46..af480794f 100644--- a/apps/dashboard/src/data/region-metrics.ts+++ b/apps/dashboard/src/data/region-metrics.ts@@ -1,37 +1,10 @@-export const regionMetrics = [- {- region: "ams",- p50: 100,- p90: 150,- p99: 200,- trend: [{ ams: 100, timestamp: 1716729600, latency: 100 }] as {- [key: string]: number;- timestamp: number;- latency: number;- }[],- },- {- region: "fra",- p50: 110,- p90: 155,- p99: 220,- trend: [{ fra: 100, timestamp: 1716729600, latency: 100 }] as {- [key: string]: number;- timestamp: number;- latency: number;- }[],- },- {- region: "gru",- p50: 120,- p90: 160,- p99: 230,- trend: [{ gru: 100, timestamp: 1716729600, latency: 100 }] as {- [key: string]: number;- timestamp: number;- latency: number;- }[],- },-];--export type RegionMetric = (typeof regionMetrics)[number];+export type RegionMetric = {+ region: string;+ p50: number;+ p75: number;+ p90: number;+ p95: number;+ p99: number;+ /** Buckets with data in the period; 0 means the region never reported. */+ buckets: number;+};diff --git a/apps/dashboard/src/lib/keyboard.test.ts b/apps/dashboard/src/lib/keyboard.test.tsnew file mode 100644index 000000000..3ed769787--- /dev/null+++ b/apps/dashboard/src/lib/keyboard.test.ts@@ -0,0 +1,106 @@+import { expect } from "@std/expect";+import { afterAll, beforeAll, describe, it } from "@std/testing/bdd";++import { getModifierKey, isKeyboardOwned, isResetShortcut } from "./keyboard";++// No DOM under deno test: a minimal HTMLElement that answers matches/closest.+class FakeElement {+ constructor(+ private tag: string,+ private role?: string,+ public isContentEditable = false,+ ) {}+ matches(selector: string) {+ return selector.split(", ").includes(this.tag);+ }+ closest(selector: string) {+ return this.role && selector.includes(`[role="${this.role}"]`)+ ? this+ : null;+ }+}++const original = Object.getOwnPropertyDescriptor(globalThis, "HTMLElement");+beforeAll(() => {+ Object.defineProperty(globalThis, "HTMLElement", {+ value: FakeElement,+ configurable: true,+ });+});+afterAll(() => {+ if (original) Object.defineProperty(globalThis, "HTMLElement", original);+ else delete (globalThis as { HTMLElement?: unknown }).HTMLElement;+});++const el = (...args: ConstructorParameters<typeof FakeElement>) =>+ new FakeElement(...args) as unknown as EventTarget;++describe("isKeyboardOwned", () => {+ it("is owned by form fields and contenteditable", () => {+ expect(isKeyboardOwned(el("input"))).toBe(true);+ expect(isKeyboardOwned(el("textarea"))).toBe(true);+ expect(isKeyboardOwned(el("select"))).toBe(true);+ expect(isKeyboardOwned(el("div", undefined, true))).toBe(true);+ });++ it("is owned inside an open overlay", () => {+ expect(isKeyboardOwned(el("button", "dialog"))).toBe(true);+ expect(isKeyboardOwned(el("div", "menu"))).toBe(true);+ expect(isKeyboardOwned(el("div", "listbox"))).toBe(true);+ });++ it("is free on the page and for non-elements", () => {+ expect(isKeyboardOwned(el("button"))).toBe(false);+ expect(isKeyboardOwned(el("div", "row"))).toBe(false);+ expect(isKeyboardOwned(null)).toBe(false);+ expect(isKeyboardOwned({} as EventTarget)).toBe(false);+ });+});++describe("isResetShortcut", () => {+ const event = (+ overrides: Partial<Parameters<typeof isResetShortcut>[0]>,+ ) => ({+ key: "Escape",+ metaKey: false,+ ctrlKey: false,+ repeat: false,+ target: el("body"),+ ...overrides,+ });++ it("fires on ⌘+Esc and Ctrl+Esc", () => {+ expect(isResetShortcut(event({ metaKey: true }))).toBe(true);+ expect(isResetShortcut(event({ ctrlKey: true }))).toBe(true);+ });++ it("ignores bare Esc, other keys and repeats", () => {+ expect(isResetShortcut(event({}))).toBe(false);+ expect(isResetShortcut(event({ metaKey: true, key: "k" }))).toBe(false);+ expect(isResetShortcut(event({ metaKey: true, repeat: true }))).toBe(false);+ });++ it("leaves Esc to a focused field or open overlay", () => {+ expect(isResetShortcut(event({ metaKey: true, target: el("input") }))).toBe(+ false,+ );+ expect(+ isResetShortcut(event({ ctrlKey: true, target: el("div", "dialog") })),+ ).toBe(false);+ });+});++describe("getModifierKey", () => {+ it("shows ⌘ on Apple platforms and Ctrl elsewhere", () => {+ expect(+ getModifierKey("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"),+ ).toBe("⌘");+ expect(getModifierKey("Mozilla/5.0 (iPhone; CPU iPhone OS 17_0)")).toBe(+ "⌘",+ );+ expect(getModifierKey("Mozilla/5.0 (Windows NT 10.0; Win64; x64)")).toBe(+ "Ctrl",+ );+ expect(getModifierKey("Mozilla/5.0 (X11; Linux x86_64)")).toBe("Ctrl");+ });+});diff --git a/apps/dashboard/src/lib/keyboard.ts b/apps/dashboard/src/lib/keyboard.tsnew file mode 100644index 000000000..2382dd89f--- /dev/null+++ b/apps/dashboard/src/lib/keyboard.ts@@ -0,0 +1,35 @@+import { useHydrated } from "@/hooks/use-hydrated";++/** A focused field or an open overlay (select, menu, dialog) owns the keyboard; page shortcuts skip it. */+export function isKeyboardOwned(target: EventTarget | null) {+ return (+ target instanceof HTMLElement &&+ (target.isContentEditable ||+ target.matches("input, textarea, select") ||+ !!target.closest(+ '[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="combobox"]',+ ))+ );+}++/** ⌘/Ctrl+Esc clears the page filters, unless a field or overlay owns the keyboard. */+export function isResetShortcut(+ e: Pick<KeyboardEvent, "key" | "metaKey" | "ctrlKey" | "repeat" | "target">,+) {+ return (+ e.key === "Escape" &&+ (e.metaKey || e.ctrlKey) &&+ !e.repeat &&+ !isKeyboardOwned(e.target)+ );+}++/** "⌘" on Apple platforms, "Ctrl" elsewhere; ⌘ until hydrated. */+export function useModifierKey() {+ const hydrated = useHydrated();+ return hydrated ? getModifierKey(navigator.userAgent) : "⌘";+}++export function getModifierKey(userAgent: string) {+ return /Mac|iPhone|iPad|iPod/.test(userAgent) ? "⌘" : "Ctrl";+}diff --git a/packages/tinybird/endpoints/endpoint__dns_metrics_latency_30d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_metrics_latency_30d__v0.pipeindex c08d8d684..e9e750009 100644--- a/packages/tinybird/endpoints/endpoint__dns_metrics_latency_30d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__dns_metrics_latency_30d__v0.pipe@@ -18,6 +18,7 @@ FROM dns_response__v0WHEREmonitorId = {{ String(monitorId, '7417', required=True) }}AND timestamp >= toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 30 DAY, 3))+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__dns_metrics_latency_7d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_metrics_latency_7d__v0.pipeindex 88b995aa0..a7944df3f 100644--- a/packages/tinybird/endpoints/endpoint__dns_metrics_latency_7d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__dns_metrics_latency_7d__v0.pipe@@ -23,6 +23,7 @@ WHERE{% if defined(toDate) %}AND toDateTime(timestamp / 1000) <= parseDateTimeBestEffortOrNull({{ String(toDate) }}){% end %}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__dns_metrics_latency_90d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_metrics_latency_90d__v0.pipeindex fb6b7c1ff..33bacc8e3 100644--- a/packages/tinybird/endpoints/endpoint__dns_metrics_latency_90d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__dns_metrics_latency_90d__v0.pipe@@ -18,6 +18,7 @@ FROM dns_response__v0WHEREmonitorId = {{ String(monitorId, '7417', required=True) }}AND timestamp >= toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 90 DAY, 3))+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_1d__v0.pipe b/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_1d__v0.pipeindex 1a37d8ede..7a9814669 100644--- a/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_1d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_1d__v0.pipe@@ -18,6 +18,7 @@ SQL >WHEREmonitorId = {{ String(monitorId, '4433', required=True) }}AND servingStatus IS NOT NULL+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_30d__v0.pipe b/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_30d__v0.pipeindex aa158359a..b98d9170f 100644--- a/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_30d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_30d__v0.pipe@@ -20,6 +20,7 @@ SQL >AND servingStatus IS NOT NULL{% 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 hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_7d__v0.pipe b/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_7d__v0.pipeindex 35a051def..7672c97e7 100644--- a/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_7d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_7d__v0.pipe@@ -18,6 +18,7 @@ SQL >WHEREmonitorId = {{ String(monitorId, '4433', required=True) }}AND servingStatus IS NOT NULL+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_90d__v0.pipe b/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_90d__v0.pipeindex 59015abe8..55a7e3ee3 100644--- a/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_90d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__grpc_metrics_latency_90d__v0.pipe@@ -20,6 +20,7 @@ SQL >AND servingStatus IS NOT NULL{% 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 hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__http_metrics_latency_1d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_metrics_latency_1d__v1.pipeindex cdc9de5f4..85b350acd 100644--- a/packages/tinybird/endpoints/endpoint__http_metrics_latency_1d__v1.pipe+++ b/packages/tinybird/endpoints/endpoint__http_metrics_latency_1d__v1.pipe@@ -17,6 +17,7 @@ SELECTFROM mv__http_1d__v0WHEREmonitorId = {{ String(monitorId, '1', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__http_metrics_latency_7d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_metrics_latency_7d__v1.pipeindex 9dfd7f06b..1a622daa4 100644--- a/packages/tinybird/endpoints/endpoint__http_metrics_latency_7d__v1.pipe+++ b/packages/tinybird/endpoints/endpoint__http_metrics_latency_7d__v1.pipe@@ -17,6 +17,7 @@ SELECTFROM mv__http_7d__v0WHEREmonitorId = {{ String(monitorId, '1', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__http_timing_phases_14d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_timing_phases_14d__v1.pipeindex 7dacb40c9..c2b328f70 100644--- a/packages/tinybird/endpoints/endpoint__http_timing_phases_14d__v1.pipe+++ b/packages/tinybird/endpoints/endpoint__http_timing_phases_14d__v1.pipe@@ -34,6 +34,7 @@ SELECTround(quantile(0.99)(tls)) as p99TlsFROM mv__http_timing_phases_14d__v1WHERE monitorId = {{ String(monitorId, '141', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h ASCdiff --git a/packages/tinybird/endpoints/endpoint__http_timing_phases_30d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_timing_phases_30d__v1.pipeindex d86a115d0..ddf325674 100644--- a/packages/tinybird/endpoints/endpoint__http_timing_phases_30d__v1.pipe+++ b/packages/tinybird/endpoints/endpoint__http_timing_phases_30d__v1.pipe@@ -36,6 +36,7 @@ FROM mv__http_timing_phases_90d__v1WHEREmonitorId = {{ String(monitorId, '141', required=True) }}AND time >= toDateTime64(now() - INTERVAL 30 DAY, 3)+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h ASCdiff --git a/packages/tinybird/endpoints/endpoint__http_timing_phases_90d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_timing_phases_90d__v1.pipeindex 643981ce9..aef9c3389 100644--- a/packages/tinybird/endpoints/endpoint__http_timing_phases_90d__v1.pipe+++ b/packages/tinybird/endpoints/endpoint__http_timing_phases_90d__v1.pipe@@ -34,6 +34,7 @@ SELECTround(quantile(0.99)(tls)) as p99TlsFROM mv__http_timing_phases_90d__v1WHERE monitorId = {{ String(monitorId, '141', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h ASCdiff --git a/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_1d__v0.pipe b/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_1d__v0.pipeindex 2e00ff92b..6d426fec7 100644--- a/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_1d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_1d__v0.pipe@@ -17,6 +17,7 @@ SQL >FROM mv__icmp_1d__v0WHEREmonitorId = {{ String(monitorId, '4433', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_30d__v0.pipe b/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_30d__v0.pipeindex 7b6a79e7e..d9b769b0c 100644--- a/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_30d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_30d__v0.pipe@@ -17,6 +17,7 @@ SQL >FROM mv__icmp_30d__v0WHEREmonitorId = {{ String(monitorId, '4433', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_7d__v0.pipe b/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_7d__v0.pipeindex 045e47c16..4d87f97f0 100644--- a/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_7d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_7d__v0.pipe@@ -17,6 +17,7 @@ SQL >FROM mv__icmp_7d__v0WHEREmonitorId = {{ String(monitorId, '4433', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_90d__v0.pipe b/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_90d__v0.pipeindex e8c5d4057..2b7af6fd6 100644--- a/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_90d__v0.pipe+++ b/packages/tinybird/endpoints/endpoint__icmp_metrics_latency_90d__v0.pipe@@ -17,6 +17,7 @@ SQL >FROM mv__icmp_90d__v0WHEREmonitorId = {{ String(monitorId, '4433', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_1d__v1.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_1d__v1.pipeindex 1ca170aca..855a3d487 100644--- a/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_1d__v1.pipe+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_1d__v1.pipe@@ -17,6 +17,7 @@ SELECTFROM mv__tcp_1d__v0WHEREmonitorId = {{ String(monitorId, '4433', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_30d__v1.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_30d__v1.pipeindex 18cbf09da..b4822697e 100644--- a/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_30d__v1.pipe+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_30d__v1.pipe@@ -16,6 +16,7 @@ SELECTround(quantile(0.99)(latency)) as p99LatencyFROM mv__tcp_30d__v1WHERE monitorId = {{ String(monitorId, '4433', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_7d__v1.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_7d__v1.pipeindex f30e3c7ea..e619b95f7 100644--- a/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_7d__v1.pipe+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_7d__v1.pipe@@ -17,6 +17,7 @@ SELECTFROM mv__tcp_7d__v1WHEREmonitorId = {{ String(monitorId, '4433', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_90d__v1.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_90d__v1.pipeindex 1e4ce0ead..799b54d27 100644--- a/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_90d__v1.pipe+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_90d__v1.pipe@@ -16,6 +16,7 @@ SELECTround(quantile(0.99)(latency)) as p99LatencyFROM mv__tcp_90d__v1WHERE monitorId = {{ String(monitorId, '4433', required=True) }}+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}GROUP BY hORDER BY h DESCdiff --git a/packages/tinybird/src/client.ts b/packages/tinybird/src/client.tsindex 565acea63..fde1f7af5 100644--- a/packages/tinybird/src/client.ts+++ b/packages/tinybird/src/client.ts@@ -1793,6 +1793,7 @@ export class OSTinybird {pipe: "endpoint__icmp_metrics_latency_7d__v0",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -1805,6 +1806,7 @@ export class OSTinybird {pipe: "endpoint__icmp_metrics_latency_30d__v0",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -1817,6 +1819,7 @@ export class OSTinybird {pipe: "endpoint__icmp_metrics_latency_90d__v0",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2274,6 +2277,7 @@ export class OSTinybird {pipe: "endpoint__grpc_metrics_latency_7d__v0",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2286,6 +2290,7 @@ export class OSTinybird {pipe: "endpoint__grpc_metrics_latency_30d__v0",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2298,6 +2303,7 @@ export class OSTinybird {pipe: "endpoint__grpc_metrics_latency_90d__v0",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2774,6 +2780,7 @@ export class OSTinybird {pipe: "endpoint__http_metrics_latency_1d__v1",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2793,6 +2800,7 @@ export class OSTinybird {pipe: "endpoint__http_metrics_latency_7d__v1",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -2853,6 +2861,7 @@ export class OSTinybird {pipe: "endpoint__tcp_metrics_latency_7d__v1",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3059,6 +3068,7 @@ export class OSTinybird {pipe: "endpoint__dns_metrics_latency_7d__v0",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3473,6 +3483,7 @@ export class OSTinybird {pipe: "endpoint__tcp_metrics_latency_30d__v1",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3492,6 +3503,7 @@ export class OSTinybird {pipe: "endpoint__tcp_metrics_latency_90d__v1",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3511,6 +3523,7 @@ export class OSTinybird {pipe: "endpoint__dns_metrics_latency_30d__v0",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),@@ -3530,6 +3543,7 @@ export class OSTinybird {pipe: "endpoint__dns_metrics_latency_90d__v0",parameters: z.object({monitorId: z.string(),+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),fromDate: z.string().optional(),toDate: z.string().optional(),}),