Skip to content

Open-source status page, incident response and uptime monitoring

chore: uptime monitoring 30d 90d aggregated data (#2237)

Maximilian Kaske8040b0aaab16
diff --git a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx
index 3256999ef..bb683288b 100644
--- a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx
+++ b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx
@@ -23,8 +23,12 @@ 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 { mapRegionMetrics } from "@/data/metrics.client";
-import { periodToFromDate } from "@/data/metrics.client";
+import {
+ FREE_MAX_PERIOD,
+ isPaidPeriod,
+ mapRegionMetrics,
+} from "@/data/metrics.client";
+import { periodToFromDate, periodToInterval } from "@/data/metrics.client";
import type { RegionMetric } from "@/data/region-metrics";
import { useTRPC } from "@/lib/trpc/client";
import {
@@ -37,7 +41,8 @@ import { useQuery } from "@tanstack/react-query";
import { endOfDay } from "date-fns";
import { useParams } from "next/navigation";
import { useQueryStates } from "nuqs";
-import React, { useMemo } from "react";
+import React, { useEffect, useMemo } from "react";
+import { toast } from "sonner";
import { searchParamsParsers } from "./search-params";
const TIMELINE_INTERVAL = 30; // in days
@@ -45,23 +50,41 @@ const TIMELINE_INTERVAL = 30; // in days
export function Client() {
const trpc = useTRPC();
const { id } = useParams<{ id: string }>();
- const [{ period, regions, percentile, interval }] =
+ const [{ period, regions, percentile, interval }, setSearchParams] =
useQueryStates(searchParamsParsers);
const { data: monitor } = useQuery(
trpc.monitor.get.queryOptions({ id: Number.parseInt(id) }),
);
+ const { data: workspace } = useQuery(trpc.workspace.get.queryOptions());
+
+ const isBlockedPeriod = workspace?.plan === "free" && isPaidPeriod(period);
+ // snap free workspaces back synchronously so charts never fire (and the server
+ // never rejects) a paid-only window; the effect below fixes the URL.
+ const effectivePeriod = isBlockedPeriod ? FREE_MAX_PERIOD : period;
+
+ useEffect(() => {
+ if (!isBlockedPeriod) return;
+ const timeout = setTimeout(() => {
+ toast.error("30 and 90 day windows require a paid plan", {
+ description: "Showing the last 14 days instead.",
+ });
+ setSearchParams({ period: FREE_MAX_PERIOD });
+ }, 0);
+ return () => clearTimeout(timeout);
+ }, [isBlockedPeriod, setSearchParams]);
+
const selectedRegions = regions ?? undefined;
- const fromDate = periodToFromDate[period];
+ const fromDate = periodToFromDate[effectivePeriod];
const toDate = endOfDay(new Date());
const regionTimelineQuery = {
...trpc.tinybird.metricsRegions.queryOptions({
monitorId: id,
- period: period,
+ period: effectivePeriod,
type: (monitor?.jobType ?? "http") as "http" | "tcp",
regions: selectedRegions,
- // Request 30-minute buckets by default
- interval: 30,
+ // bucket by period (daily at 30d/90d) to keep payload + chart readable
+ interval: periodToInterval[effectivePeriod],
fromDate: fromDate.toISOString(),
toDate: toDate.toISOString(),
}),
@@ -120,7 +143,7 @@ export function Client() {
<GlobalUptimeSection
monitorId={id}
jobType={monitor.jobType as "http" | "tcp"}
- period={period}
+ period={effectivePeriod}
regions={selectedRegions}
/>
</Section>
@@ -134,7 +157,7 @@ export function Client() {
<ChartBarUptime
monitorId={id}
type={monitor.jobType as "http" | "tcp"}
- period={period}
+ period={effectivePeriod}
regions={selectedRegions}
/>
</Section>
@@ -162,7 +185,7 @@ export function Client() {
monitorId={id}
degradedAfter={monitor.degradedAfter}
type={monitor.jobType as "http"}
- period={period}
+ period={effectivePeriod}
percentile={percentile}
interval={interval}
regions={selectedRegions}
@@ -173,7 +196,7 @@ export function Client() {
percentile={percentile}
degradedAfter={monitor.degradedAfter}
type={monitor.jobType as "http" | "tcp"}
- period={period}
+ period={effectivePeriod}
regions={selectedRegions}
/>
)}
diff --git a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/search-params.ts b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/search-params.ts
index aa95cf64b..1db48b0fd 100644
--- a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/search-params.ts
+++ b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/search-params.ts
@@ -7,7 +7,7 @@ import {
parseAsStringLiteral,
} from "nuqs/server";
-const PERIOD = ["1d", "7d", "14d"] as const;
+const PERIOD = ["1d", "7d", "14d", "30d", "90d"] as const;
const PERCENTILE = ["p50", "p75", "p90", "p95", "p99"] as const;
export const searchParamsParsers = {
diff --git a/apps/dashboard/src/app/(dashboard)/monitors/[id]/sidebar.tsx b/apps/dashboard/src/app/(dashboard)/monitors/[id]/sidebar.tsx
index 8725b3958..c4f0238d5 100644
--- a/apps/dashboard/src/app/(dashboard)/monitors/[id]/sidebar.tsx
+++ b/apps/dashboard/src/app/(dashboard)/monitors/[id]/sidebar.tsx
@@ -102,6 +102,7 @@ export function Sidebar() {
},
{
label: "Notifications",
+ emptyMessage: "No notifications attached",
items: monitor.notifications.flatMap((notification) => {
const arr = [];
arr.push({
@@ -129,43 +130,41 @@ export function Sidebar() {
},
{
label: "Assertions",
- items:
- assertions.length > 0
- ? assertions.flatMap((assertion) => {
- const arr = [];
+ emptyMessage: "No assertions configured",
+ items: assertions.flatMap((assertion) => {
+ const arr = [];
- arr.push({
- label: "Type",
- value: assertion.schema.type,
- });
+ arr.push({
+ label: "Type",
+ value: assertion.schema.type,
+ });
- arr.push({
- label: "Compare",
- value: assertion.schema.compare,
- isNested: true,
- });
+ arr.push({
+ label: "Compare",
+ value: assertion.schema.compare,
+ isNested: true,
+ });
- if (
- (assertion.schema.type === "header" ||
- assertion.schema.type === "dnsRecord") &&
- assertion.schema.key
- ) {
- arr.push({
- label: "Key",
- value: assertion.schema.key,
- isNested: true,
- });
- }
+ if (
+ (assertion.schema.type === "header" ||
+ assertion.schema.type === "dnsRecord") &&
+ assertion.schema.key
+ ) {
+ arr.push({
+ label: "Key",
+ value: assertion.schema.key,
+ isNested: true,
+ });
+ }
- arr.push({
- label: "Value",
- value: assertion.schema.target,
- isNested: true,
- });
+ arr.push({
+ label: "Value",
+ value: assertion.schema.target,
+ isNested: true,
+ });
- return arr;
- })
- : [],
+ return arr;
+ }),
},
// {
// label: "Last Logs",
diff --git a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/sidebar.tsx b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/sidebar.tsx
index 6024bd473..f58bab63f 100644
--- a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/sidebar.tsx
+++ b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/sidebar.tsx
@@ -111,6 +111,7 @@ export function Sidebar() {
},
{
label: "Monitors",
+ emptyMessage: "No monitors attached",
items: statusPage.pageComponents.flatMap((component) => {
const arr = [];
arr.push({
diff --git a/apps/dashboard/src/components/chart/chart-area-latency.tsx b/apps/dashboard/src/components/chart/chart-area-latency.tsx
index 75dee7385..8ca92fd9e 100644
--- a/apps/dashboard/src/components/chart/chart-area-latency.tsx
+++ b/apps/dashboard/src/components/chart/chart-area-latency.tsx
@@ -10,7 +10,11 @@ import {
YAxis,
} from "recharts";
-import { type PERCENTILES, mapLatency } from "@/data/metrics.client";
+import {
+ type PERCENTILES,
+ type PERIODS,
+ mapLatency,
+} from "@/data/metrics.client";
import { periodToFromDate } from "@/data/metrics.client";
import { useTRPC } from "@/lib/trpc/client";
import {
@@ -45,7 +49,7 @@ export function ChartAreaLatency({
monitorId: string;
degradedAfter: number | null;
percentile: (typeof PERCENTILES)[number];
- period: "1d" | "7d" | "14d";
+ period: (typeof PERIODS)[number];
type: "http" | "tcp";
regions: string[] | undefined;
}) {
diff --git a/apps/dashboard/src/components/chart/chart-area-timing-phases.tsx b/apps/dashboard/src/components/chart/chart-area-timing-phases.tsx
index ae9bac090..1b039f383 100644
--- a/apps/dashboard/src/components/chart/chart-area-timing-phases.tsx
+++ b/apps/dashboard/src/components/chart/chart-area-timing-phases.tsx
@@ -13,6 +13,7 @@ import {
import {
type INTERVALS,
type PERCENTILES,
+ type PERIODS,
mapTimingPhases,
} from "@/data/metrics.client";
import { useTRPC } from "@/lib/trpc/client";
@@ -66,7 +67,7 @@ export function ChartAreaTimingPhases({
}: {
monitorId: string;
degradedAfter: number | null;
- period: "1d" | "7d" | "14d";
+ period: (typeof PERIODS)[number];
percentile: (typeof PERCENTILES)[number];
interval: (typeof INTERVALS)[number];
regions: string[] | undefined;
diff --git a/apps/dashboard/src/components/chart/chart-bar-uptime.tsx b/apps/dashboard/src/components/chart/chart-bar-uptime.tsx
index 0bccf5717..cc421991d 100644
--- a/apps/dashboard/src/components/chart/chart-bar-uptime.tsx
+++ b/apps/dashboard/src/components/chart/chart-bar-uptime.tsx
@@ -61,6 +61,8 @@ export function ChartBarUptime({
regions,
interval,
type,
+ // 30d MV only retains 30 days; the 90d window needs the 90d uptime pipe
+ period: period === "90d" ? "90d" : "30d",
}),
);
diff --git a/apps/dashboard/src/components/controls-search/dropdown-interval.tsx b/apps/dashboard/src/components/controls-search/dropdown-interval.tsx
index 95b789853..e16b1b80a 100644
--- a/apps/dashboard/src/components/controls-search/dropdown-interval.tsx
+++ b/apps/dashboard/src/components/controls-search/dropdown-interval.tsx
@@ -1,6 +1,6 @@
"use client";
-import { INTERVALS } from "@/data/metrics.client";
+import { INTERVALS, PERIODS, periodToMinInterval } from "@/data/metrics.client";
import { Button } from "@openstatus/ui/components/ui/button";
import {
DropdownMenu,
@@ -11,7 +11,12 @@ import {
DropdownMenuTrigger,
} from "@openstatus/ui/components/ui/dropdown-menu";
import { Check } from "lucide-react";
-import { parseAsNumberLiteral, useQueryState } from "nuqs";
+import {
+ parseAsNumberLiteral,
+ parseAsStringLiteral,
+ useQueryState,
+} from "nuqs";
+import { useEffect } from "react";
const MAPPING = {
5: "5 minutes",
@@ -25,15 +30,28 @@ const MAPPING = {
} as const;
const parseInterval = parseAsNumberLiteral(INTERVALS).withDefault(30);
+const parsePeriod = parseAsStringLiteral(PERIODS).withDefault("1d");
export function DropdownInterval() {
const [interval, setInterval] = useQueryState("interval", parseInterval);
+ const [period] = useQueryState("period", parsePeriod);
+
+ const min = periodToMinInterval[period];
+ const options = INTERVALS.filter((item) => item >= min);
+
+ // snap a now-too-fine selection up to the period's floor so the dropdown,
+ // URL, and charts agree (e.g. 5min carried over into the 90d view)
+ useEffect(() => {
+ if (interval < min) setInterval(min);
+ }, [interval, min, setInterval]);
+
+ const selected = Math.max(interval, min) as (typeof INTERVALS)[number];
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" size="sm">
- {MAPPING[interval]}
+ {MAPPING[selected]}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
@@ -41,10 +59,10 @@ export function DropdownInterval() {
<DropdownMenuLabel className="font-medium text-muted-foreground text-xs">
Resolution
</DropdownMenuLabel>
- {INTERVALS.map((item) => (
+ {options.map((item) => (
<DropdownMenuItem key={item} onSelect={() => setInterval(item)}>
{MAPPING[item]}
- {interval === item ? (
+ {selected === item ? (
<Check className="ml-auto shrink-0" />
) : null}
</DropdownMenuItem>
diff --git a/apps/dashboard/src/components/controls-search/dropdown-period.tsx b/apps/dashboard/src/components/controls-search/dropdown-period.tsx
index 7dd6a8086..a14e2d6c8 100644
--- a/apps/dashboard/src/components/controls-search/dropdown-period.tsx
+++ b/apps/dashboard/src/components/controls-search/dropdown-period.tsx
@@ -1,6 +1,8 @@
"use client";
-import { PERIODS } from "@/data/metrics.client";
+import { UpgradeDialog } from "@/components/dialogs/upgrade";
+import { PERIODS, isPaidPeriod } from "@/data/metrics.client";
+import { useTRPC } from "@/lib/trpc/client";
import { Button } from "@openstatus/ui/components/ui/button";
import {
DropdownMenu,
@@ -10,8 +12,10 @@ import {
DropdownMenuLabel,
DropdownMenuTrigger,
} from "@openstatus/ui/components/ui/dropdown-menu";
-import { Check } from "lucide-react";
+import { useQuery } from "@tanstack/react-query";
+import { Check, Lock } from "lucide-react";
import { parseAsStringLiteral, useQueryState } from "nuqs";
+import { useState } from "react";
// TODO: where to move it?
export const PERIOD_VALUES = [
@@ -27,33 +31,66 @@ export const PERIOD_VALUES = [
value: "14d",
label: "Last 14 days",
},
+ {
+ value: "30d",
+ label: "Last 30 days",
+ },
+ {
+ value: "90d",
+ label: "Last 90 days",
+ },
] satisfies { value: (typeof PERIODS)[number]; label: string }[];
const parsePeriod = parseAsStringLiteral(PERIODS).withDefault("1d");
export function DropdownPeriod() {
const [period, setPeriod] = useQueryState("period", parsePeriod);
+ const [upgradeOpen, setUpgradeOpen] = useState(false);
+ const trpc = useTRPC();
+ const { data: workspace } = useQuery(trpc.workspace.get.queryOptions());
+ const isFree = workspace?.plan === "free";
return (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="outline" size="sm">
- {PERIOD_VALUES.find(({ value }) => value === period)?.label}
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start">
- <DropdownMenuGroup>
- <DropdownMenuLabel className="font-medium text-muted-foreground text-xs">
- Period
- </DropdownMenuLabel>
- {PERIOD_VALUES.map(({ value, label }) => (
- <DropdownMenuItem key={value} onSelect={() => setPeriod(value)}>
- {label}
- {period === value ? <Check className="ml-auto shrink-0" /> : null}
- </DropdownMenuItem>
- ))}
- </DropdownMenuGroup>
- </DropdownMenuContent>
- </DropdownMenu>
+ <>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline" size="sm">
+ {PERIOD_VALUES.find(({ value }) => value === period)?.label}
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start">
+ <DropdownMenuGroup>
+ <DropdownMenuLabel className="font-medium text-muted-foreground text-xs">
+ Period
+ </DropdownMenuLabel>
+ {PERIOD_VALUES.map(({ value, label }) => {
+ const locked = isFree && isPaidPeriod(value);
+ return (
+ <DropdownMenuItem
+ key={value}
+ data-locked={locked}
+ onSelect={() =>
+ locked ? setUpgradeOpen(true) : setPeriod(value)
+ }
+ className={"data-[locked=true]:opacity-70"}
+ >
+ {label}
+ {locked ? (
+ <Lock className="ml-auto shrink-0" />
+ ) : period === value ? (
+ <Check className="ml-auto shrink-0" />
+ ) : null}
+ </DropdownMenuItem>
+ );
+ })}
+ </DropdownMenuGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <UpgradeDialog
+ open={upgradeOpen}
+ onOpenChange={setUpgradeOpen}
+ limit="data-retention"
+ />
+ </>
);
}
diff --git a/apps/dashboard/src/components/metric/global-uptime/section.tsx b/apps/dashboard/src/components/metric/global-uptime/section.tsx
index c7d863631..567780d99 100644
--- a/apps/dashboard/src/components/metric/global-uptime/section.tsx
+++ b/apps/dashboard/src/components/metric/global-uptime/section.tsx
@@ -12,7 +12,7 @@ import {
import { useTRPC } from "@/lib/trpc/client";
import { useQuery } from "@tanstack/react-query";
-import { mapMetrics, metricsCards } from "@/data/metrics.client";
+import { type PERIODS, mapMetrics, metricsCards } from "@/data/metrics.client";
import {
formatMilliseconds,
formatNumber,
@@ -38,7 +38,7 @@ export function GlobalUptimeSection({
}: {
monitorId: string;
jobType: "http" | "tcp";
- period: "1d" | "7d" | "14d";
+ period: (typeof PERIODS)[number];
regions: string[] | undefined;
}) {
const trpc = useTRPC();
@@ -80,11 +80,13 @@ export function GlobalUptimeSection({
})();
if (k in acc) {
+ // no prior-period baseline (raw === 0) → no trend, so we don't
+ // render a misleading "0%" badge (e.g. the empty 90d previous window)
const trend = acc[k]?.raw
? k === "uptime"
? acc[k]?.raw / (value ?? 0)
: (value ?? 0) / acc[k]?.raw
- : 1;
+ : Number.NaN;
const hasTrend =
!Number.isNaN(trend) &&
trend !== Number.POSITIVE_INFINITY &&
diff --git a/apps/dashboard/src/components/nav/sidebar-metadata.tsx b/apps/dashboard/src/components/nav/sidebar-metadata.tsx
index 917b612d8..a3c58342d 100644
--- a/apps/dashboard/src/components/nav/sidebar-metadata.tsx
+++ b/apps/dashboard/src/components/nav/sidebar-metadata.tsx
@@ -79,15 +79,19 @@ export type SidebarMetadataProps =
label: string;
type?: "table";
items?: SidebarMetadataItem[];
+ /** Shown when `items` is empty. Defaults to "None". */
+ emptyMessage?: string;
}
| {
label: string;
type: "list";
items?: SidebarMetadataListItem[];
+ /** Shown when `items` is empty. Defaults to "None". */
+ emptyMessage?: string;
};
export function SidebarMetadata(props: SidebarMetadataProps) {
- const { label } = props;
+ const { label, emptyMessage = "None" } = props;
return (
<SidebarGroup className="p-0">
<Collapsible defaultOpen className="group/collapsible border-b">
@@ -103,9 +107,15 @@ export function SidebarMetadata(props: SidebarMetadataProps) {
<CollapsibleContent>
<SidebarGroupContent className="border-t">
{props.type === "list" ? (
- <SidebarMetadataList items={props.items ?? []} />
+ <SidebarMetadataList
+ items={props.items ?? []}
+ emptyMessage={emptyMessage}
+ />
) : (
- <SidebarMetadataTable items={props.items ?? []} />
+ <SidebarMetadataTable
+ items={props.items ?? []}
+ emptyMessage={emptyMessage}
+ />
)}
</SidebarGroupContent>
</CollapsibleContent>
@@ -114,8 +124,13 @@ export function SidebarMetadata(props: SidebarMetadataProps) {
);
}
+function SidebarMetadataEmpty({ message }: { message: string }) {
+ return <p className="px-2 py-2 text-muted-foreground text-sm">{message}</p>;
+}
+
function SidebarMetadataTable({
items,
+ emptyMessage,
}: {
items: {
label: string;
@@ -123,7 +138,11 @@ function SidebarMetadataTable({
isNested?: boolean;
tooltip?: string;
}[];
+ emptyMessage: string;
}) {
+ if (items.length === 0) {
+ return <SidebarMetadataEmpty message={emptyMessage} />;
+ }
return (
<Table>
<TableHeader className="sr-only">
@@ -151,7 +170,16 @@ function SidebarMetadataTable({
);
}
-function SidebarMetadataList({ items }: { items: SidebarMetadataListItem[] }) {
+function SidebarMetadataList({
+ items,
+ emptyMessage,
+}: {
+ items: SidebarMetadataListItem[];
+ emptyMessage: string;
+}) {
+ if (items.length === 0) {
+ return <SidebarMetadataEmpty message={emptyMessage} />;
+ }
return (
<SidebarGroup className="p-0">
<SidebarMenu className="gap-0">
diff --git a/apps/dashboard/src/data/metrics.client.ts b/apps/dashboard/src/data/metrics.client.ts
index 5c0ddc3e7..252c33aa0 100644
--- a/apps/dashboard/src/data/metrics.client.ts
+++ b/apps/dashboard/src/data/metrics.client.ts
@@ -8,7 +8,20 @@ import { startOfDay, subDays } from "date-fns";
import type { RegionMetric } from "./region-metrics";
export const STATUS = ["success", "error", "degraded"] as const;
-export const PERIODS = ["1d", "7d", "14d"] as const;
+export const PERIODS = ["1d", "7d", "14d", "30d", "90d"] as const;
+// 30d/90d require a paid plan; the dropdown gates them for free workspaces.
+export const PAID_PERIODS = ["30d", "90d"] as const;
+
+// longest window a free workspace may view; paid periods snap back to this.
+export const FREE_MAX_PERIOD = "14d" as const;
+
+export type Period = (typeof PERIODS)[number];
+export type PaidPeriod = (typeof PAID_PERIODS)[number];
+
+// widen to string[] so any Period can be tested, not just the paid literals
+export function isPaidPeriod(period: string): period is PaidPeriod {
+ return (PAID_PERIODS as readonly string[]).includes(period);
+}
export const REGIONS =
monitorRegions as unknown as (typeof monitorRegions)[number][];
export const PERCENTILES = ["p50", "p75", "p90", "p95", "p99"] as const;
@@ -329,10 +342,25 @@ export const periodToInterval = {
"1d": 60,
"7d": 240,
"14d": 480,
+ "30d": 1440,
+ "90d": 1440,
} satisfies Record<(typeof PERIODS)[number], number>;
export const periodToFromDate = {
"1d": startOfDay(subDays(new Date(), 1)),
"7d": startOfDay(subDays(new Date(), 7)),
"14d": startOfDay(subDays(new Date(), 14)),
+ "30d": startOfDay(subDays(new Date(), 30)),
+ "90d": startOfDay(subDays(new Date(), 90)),
} satisfies Record<(typeof PERIODS)[number], Date>;
+
+// Minimum selectable resolution (minutes) per period. Long windows floor the
+// interval so charts stay readable and queries bounded. Mirrors the server-side
+// clamp in `@openstatus/api` tinybird router — keep the two in sync.
+export const periodToMinInterval = {
+ "1d": 5,
+ "7d": 5,
+ "14d": 5,
+ "30d": 240,
+ "90d": 1440,
+} satisfies Record<(typeof PERIODS)[number], (typeof INTERVALS)[number]>;
diff --git a/apps/workflows/src/scripts/tinybird.ts b/apps/workflows/src/scripts/tinybird.ts
index fed54814c..ca9da0ad1 100644
--- a/apps/workflows/src/scripts/tinybird.ts
+++ b/apps/workflows/src/scripts/tinybird.ts
@@ -95,19 +95,27 @@ async function main() {
const lastTwoWeeks = calculatePastTimestamp(14);
const lastThreeMonths = calculatePastTimestamp(90);
const lastYear = calculatePastTimestamp(365);
- // const _lastTwoYears = calculatePastTimestamp(730);
+ const lastTwoYears = calculatePastTimestamp(730);
const starters = await getWorkspaceIdsByPlan("starter");
const teams = await getWorkspaceIdsByPlan("team");
- // const pros = await getWorkspaceIdsByPlan("pro");
+ const scales = await getWorkspaceIdsByPlan("scale");
// all other workspaces, we need to 'reverse' the deletion here to NOT include those workspaces
- const rest = [...starters, ...teams];
+ const rest = [...starters, ...teams, ...scales];
- deleteLogs(lastTwoWeeks, rest, true);
- deleteLogs(lastThreeMonths, starters);
- deleteLogs(lastYear, teams);
- // deleteLogs(lastYear, pros);
+ if (rest.length > 0) {
+ await deleteLogs(lastTwoWeeks, rest, true);
+ }
+ if (starters.length > 0) {
+ await deleteLogs(lastThreeMonths, starters);
+ }
+ if (teams.length > 0) {
+ await deleteLogs(lastYear, teams);
+ }
+ if (scales.length > 0) {
+ await deleteLogs(lastTwoYears, scales);
+ }
}
/**
diff --git a/packages/api/src/router/tinybird/index.ts b/packages/api/src/router/tinybird/index.ts
index 55897d022..64ba101a8 100644
--- a/packages/api/src/router/tinybird/index.ts
+++ b/packages/api/src/router/tinybird/index.ts
@@ -12,18 +12,44 @@ import { calculatePeriod } from "./utils";
const tb = new OSTinybird(env.TINY_BIRD_API_KEY);
-const periods = ["1d", "7d", "14d"] as const;
+const periods = ["1d", "7d", "14d", "30d", "90d"] as const;
const types = ["http", "tcp", "dns"] as const;
type Period = (typeof periods)[number];
type Type = (typeof types)[number];
+// 30d/90d windows are paid-only; free workspaces are blocked server-side.
+function assertPaidPeriod(plan: string, period: Period) {
+ if (plan === "free" && (period === "30d" || period === "90d")) {
+ throw new TRPCError({
+ code: "FORBIDDEN",
+ message: "Upgrade to a paid plan to access 30d and 90d data",
+ });
+ }
+}
+
+// Minimum bucket size (minutes) per period. Floors a client-supplied `interval`
+// so long windows can't be forced into pathological point counts (e.g. 5min over
+// 90d = ~26k buckets). Short windows keep a low floor so the interval picker still
+// works. Only applied when an interval is provided; otherwise the pipe default wins.
+const periodToMinInterval: Record<Period, number> = {
+ "1d": 5,
+ "7d": 5,
+ "14d": 5,
+ "30d": 240,
+ "90d": 1440,
+};
+
+function clampInterval(period: Period, interval?: number) {
+ if (interval == null) return interval;
+ return Math.max(interval, periodToMinInterval[period]);
+}
+
// NEW: workspace-level counters helper
export function getWorkspace30dProcedure(type: Type) {
return type === "http" ? tb.httpWorkspace30d : tb.tcpWorkspace30d;
}
// Helper functions to get the right procedure based on period and type
export function getListProcedure(period: Period, type: Type) {
- console.log({ period, type });
switch (period) {
case "1d":
if (type === "http") return tb.httpListDaily;
@@ -65,6 +91,16 @@ export function getMetricsProcedure(period: Period, type: Type) {
if (type === "http") return tb.httpMetricsBiweekly;
if (type === "tcp") return tb.tcpMetricsBiweekly;
throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
+ case "30d":
+ if (type === "dns") return tb.dnsMetrics30d;
+ if (type === "http") return tb.httpMetrics30d;
+ if (type === "tcp") return tb.tcpMetrics30d;
+ throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
+ case "90d":
+ if (type === "dns") return tb.dnsMetrics90d;
+ if (type === "http") return tb.httpMetrics90d;
+ if (type === "tcp") return tb.tcpMetrics90d;
+ throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
default:
if (type === "dns") return tb.dnsMetricsDaily;
if (type === "http") return tb.httpMetricsDaily;
@@ -91,6 +127,16 @@ export function getMetricsRegionsProcedure(period: Period, type: Type) {
if (type === "http") return tb.httpMetricsRegionsBiweekly;
if (type === "tcp") return tb.tcpMetricsByIntervalBiweekly;
throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
+ case "30d":
+ if (type === "dns") return tb.dnsMetricsRegions30d;
+ if (type === "http") return tb.httpMetricsRegions30d;
+ if (type === "tcp") return tb.tcpMetricsByInterval30d;
+ throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
+ case "90d":
+ if (type === "dns") return tb.dnsMetricsRegions90d;
+ if (type === "http") return tb.httpMetricsRegions90d;
+ if (type === "tcp") return tb.tcpMetricsByInterval90d;
+ throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
default:
if (type === "dns") return tb.dnsMetricsRegionsBiweekly;
if (type === "http") return tb.httpMetricsRegionsDaily;
@@ -125,9 +171,10 @@ export function getGlobalMetricsProcedure(type: Type) {
return type === "http" ? tb.httpGlobalMetricsDaily : tb.tcpGlobalMetricsDaily;
}
-export function getUptimeProcedure(period: "7d" | "30d", type: Type) {
+export function getUptimeProcedure(period: "7d" | "30d" | "90d", type: Type) {
switch (period) {
case "7d":
+ // no 7d DNS uptime pipe; the 30d MV is filtered down by the client window
if (type === "dns") return tb.dnsUptime30d;
if (type === "http") return tb.httpUptimeWeekly;
if (type === "tcp") return tb.tcpUptimeWeekly;
@@ -137,6 +184,11 @@ export function getUptimeProcedure(period: "7d" | "30d", type: Type) {
if (type === "http") return tb.httpUptime30d;
if (type === "tcp") return tb.tcpUptime30d;
throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
+ case "90d":
+ if (type === "dns") return tb.dnsUptime90d;
+ if (type === "http") return tb.httpUptime90d;
+ if (type === "tcp") return tb.tcpUptime90d;
+ throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
default:
if (type === "dns") return tb.dnsUptime30d;
if (type === "http") return tb.httpUptime30d;
@@ -158,6 +210,18 @@ export function getMetricsLatencyProcedure(_period: Period, type: Type) {
if (type === "http") return tb.httpMetricsLatency7d;
if (type === "tcp") return tb.tcpMetricsLatency7d;
throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
+ // no dedicated 14d latency pipe; 30d MV is the smallest window covering 14d
+ case "14d":
+ case "30d":
+ if (type === "dns") return tb.dnsMetricsLatency30d;
+ if (type === "http") return tb.httpMetricsLatency30d;
+ if (type === "tcp") return tb.tcpMetricsLatency30d;
+ throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
+ case "90d":
+ if (type === "dns") return tb.dnsMetricsLatency90d;
+ if (type === "http") return tb.httpMetricsLatency90d;
+ if (type === "tcp") return tb.tcpMetricsLatency90d;
+ throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
default:
if (type === "dns") return tb.dnsMetricsLatency7d;
if (type === "http") return tb.httpMetricsLatency1d;
@@ -173,8 +237,16 @@ export function getMetricsLatencyMultiProcedure(_period: Period, type: Type) {
throw new TRPCError({ code: "NOT_FOUND", message: "Invalid type" });
}
-export function getTimingPhasesProcedure(type: Type) {
- return type === "http" ? tb.httpTimingPhases14d : null;
+export function getTimingPhasesProcedure(period: Period, type: Type) {
+ if (type !== "http") return null;
+ switch (period) {
+ case "30d":
+ return tb.httpTimingPhases30d;
+ case "90d":
+ return tb.httpTimingPhases90d;
+ default:
+ return tb.httpTimingPhases14d;
+ }
}
export const tinybirdRouter = createTRPCRouter({
@@ -227,7 +299,7 @@ export const tinybirdRouter = createTRPCRouter({
interval: z.int().optional(), // in minutes, default 30
regions: z.enum(monitorRegions).or(z.string()).array().optional(),
type: z.enum(types).prefault("http"),
- period: z.enum(["7d", "30d"]).prefault("30d"),
+ period: z.enum(["7d", "30d", "90d"]).prefault("30d"),
}),
)
.query(async (opts) => {
@@ -247,6 +319,14 @@ export const tinybirdRouter = createTRPCRouter({
});
}
+ // only 90d is gated here; 30d is the default uptime MV used by all windows
+ if (opts.ctx.workspace.plan === "free" && opts.input.period === "90d") {
+ throw new TRPCError({
+ code: "FORBIDDEN",
+ message: "Upgrade to a paid plan to access 90d data",
+ });
+ }
+
const procedure = getUptimeProcedure(opts.input.period, opts.input.type);
return await procedure(opts.input);
}),
@@ -312,6 +392,8 @@ export const tinybirdRouter = createTRPCRouter({
});
}
+ assertPaidPeriod(opts.ctx.workspace.plan, opts.input.period);
+
const procedure = getMetricsProcedure(opts.input.period, opts.input.type);
return await procedure(opts.input);
}),
@@ -351,6 +433,13 @@ export const tinybirdRouter = createTRPCRouter({
opts.input.regions = undefined;
}
+ assertPaidPeriod(opts.ctx.workspace.plan, opts.input.period);
+
+ opts.input.interval = clampInterval(
+ opts.input.period,
+ opts.input.interval,
+ );
+
const procedure = getMetricsRegionsProcedure(
opts.input.period,
opts.input.type,
@@ -450,6 +539,8 @@ export const tinybirdRouter = createTRPCRouter({
opts.input.regions = undefined;
}
+ assertPaidPeriod(opts.ctx.workspace.plan, opts.input.period);
+
const procedure = getMetricsLatencyProcedure(
opts.input.period,
opts.input.type,
@@ -488,7 +579,17 @@ export const tinybirdRouter = createTRPCRouter({
opts.input.regions = undefined;
}
- const procedure = getTimingPhasesProcedure(opts.input.type);
+ assertPaidPeriod(opts.ctx.workspace.plan, opts.input.period);
+
+ opts.input.interval = clampInterval(
+ opts.input.period,
+ opts.input.interval,
+ );
+
+ const procedure = getTimingPhasesProcedure(
+ opts.input.period,
+ opts.input.type,
+ );
if (!procedure) {
throw new TRPCError({
diff --git a/packages/api/src/router/tinybird/utils.ts b/packages/api/src/router/tinybird/utils.ts
index 479f5704b..b73bc2992 100644
--- a/packages/api/src/router/tinybird/utils.ts
+++ b/packages/api/src/router/tinybird/utils.ts
@@ -2,7 +2,6 @@ export function calculatePeriod(from: Date | undefined, _to: Date | undefined) {
const today = new Date();
const diffTime = Math.abs(today.getTime() - (from?.getTime() ?? 0));
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
- console.log({ diffDays });
if (diffDays <= 1) return "1d";
if (diffDays <= 7) return "7d";
if (diffDays <= 14) return "14d";
diff --git a/packages/tinybird/datasources/mv__http_90d__v1.datasource b/packages/tinybird/datasources/mv__http_90d__v1.datasource
new file mode 100644
index 000000000..aa806bc4d
--- /dev/null
+++ b/packages/tinybird/datasources/mv__http_90d__v1.datasource
@@ -0,0 +1,19 @@
+# Data Source created from Pipe 'aggregate__http_90d__v1'
+
+SCHEMA >
+ `time` DateTime,
+ `id` Nullable(String),
+ `latency` Int64,
+ `region` LowCardinality(String),
+ `trigger` Nullable(String),
+ `statusCode` Nullable(Int16),
+ `timestamp` Int64,
+ `cronTimestamp` Int64,
+ `monitorId` String,
+ `requestStatus` Nullable(String),
+ `timing` Nullable(String)
+
+ENGINE "MergeTree"
+ENGINE_PARTITION_KEY "toYYYYMM(time)"
+ENGINE_SORTING_KEY "monitorId, time"
+ENGINE_TTL "time + toIntervalDay(90)"
diff --git a/packages/tinybird/datasources/mv__http_timing_phases_90d__v1.datasource b/packages/tinybird/datasources/mv__http_timing_phases_90d__v1.datasource
new file mode 100644
index 000000000..77c04cc61
--- /dev/null
+++ b/packages/tinybird/datasources/mv__http_timing_phases_90d__v1.datasource
@@ -0,0 +1,21 @@
+# Data Source created from Pipe 'aggregate__http_timing_phases_90d__v1'
+
+SCHEMA >
+ `time` DateTime,
+ `latency` Int64,
+ `region` LowCardinality(String),
+ `trigger` Nullable(String),
+ `statusCode` Nullable(Int16),
+ `monitorId` String,
+ `workspaceId` String,
+ `requestStatus` Nullable(String),
+ `dns` Nullable(Int64),
+ `connect` Nullable(Int64),
+ `tls` Nullable(Int64),
+ `firstByte` Nullable(Int64),
+ `transfer` Nullable(Int64)
+
+ENGINE "MergeTree"
+ENGINE_PARTITION_KEY "toYYYYMM(time)"
+ENGINE_SORTING_KEY "monitorId, time"
+ENGINE_TTL "time + toIntervalDay(90)"
diff --git a/packages/tinybird/datasources/mv__http_uptime_90d__v1.datasource b/packages/tinybird/datasources/mv__http_uptime_90d__v1.datasource
new file mode 100644
index 000000000..f519333af
--- /dev/null
+++ b/packages/tinybird/datasources/mv__http_uptime_90d__v1.datasource
@@ -0,0 +1,13 @@
+# Data Source created from Pipe 'aggregate__http_uptime_90d__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(90)"
diff --git a/packages/tinybird/datasources/mv__tcp_90d__v1.datasource b/packages/tinybird/datasources/mv__tcp_90d__v1.datasource
new file mode 100644
index 000000000..99a910119
--- /dev/null
+++ b/packages/tinybird/datasources/mv__tcp_90d__v1.datasource
@@ -0,0 +1,18 @@
+# Data Source created from Pipe 'aggregate__tcp_90d__v1'
+
+SCHEMA >
+ `time` DateTime,
+ `latency` Int64,
+ `error` Int16,
+ `region` String,
+ `trigger` Nullable(String),
+ `timestamp` Int64,
+ `cronTimestamp` Int64,
+ `monitorId` Int32,
+ `requestStatus` Nullable(String),
+ `id` Nullable(String)
+
+ENGINE "MergeTree"
+ENGINE_PARTITION_KEY "toYYYYMM(time)"
+ENGINE_SORTING_KEY "monitorId, time"
+ENGINE_TTL "time + toIntervalDay(90)"
diff --git a/packages/tinybird/datasources/mv__tcp_uptime_90d__v1.datasource b/packages/tinybird/datasources/mv__tcp_uptime_90d__v1.datasource
new file mode 100644
index 000000000..7697f67ac
--- /dev/null
+++ b/packages/tinybird/datasources/mv__tcp_uptime_90d__v1.datasource
@@ -0,0 +1,13 @@
+# Data Source created from Pipe 'aggregate__tcp_uptime_90d__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(90)"
diff --git a/packages/tinybird/endpoints/endpoint__dns_metrics_30d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_metrics_30d__v0.pipe
new file mode 100644
index 000000000..368a32afc
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__dns_metrics_30d__v0.pipe
@@ -0,0 +1,42 @@
+TAGS "dns"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ max(cronTimestamp) AS lastTimestamp
+ FROM dns_response__v0
+ WHERE
+ monitorId = {{ 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 %}
+ UNION ALL
+ SELECT
+ round(quantile(0.50)(latency)) AS p50Latency,
+ round(quantile(0.75)(latency)) AS p75Latency,
+ round(quantile(0.90)(latency)) AS p90Latency,
+ round(quantile(0.95)(latency)) AS p95Latency,
+ round(quantile(0.99)(latency)) AS p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ NULL as lastTimestamp
+ FROM dns_response__v0
+ WHERE
+ monitorId = {{ String(monitorId, '7417', required=True) }}
+ AND timestamp >= toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 60 DAY, 3))
+ AND timestamp < toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 30 DAY, 3))
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__dns_metrics_90d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_metrics_90d__v0.pipe
new file mode 100644
index 000000000..67c81382f
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__dns_metrics_90d__v0.pipe
@@ -0,0 +1,43 @@
+TAGS "dns"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ max(cronTimestamp) AS lastTimestamp
+ FROM dns_response__v0
+ WHERE
+ monitorId = {{ 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 %}
+ UNION ALL
+ -- dns_response has no TTL, so the previous 90d window is real data: dns gets a true 90d trend
+ SELECT
+ round(quantile(0.50)(latency)) AS p50Latency,
+ round(quantile(0.75)(latency)) AS p75Latency,
+ round(quantile(0.90)(latency)) AS p90Latency,
+ round(quantile(0.95)(latency)) AS p95Latency,
+ round(quantile(0.99)(latency)) AS p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ NULL as lastTimestamp
+ FROM dns_response__v0
+ WHERE
+ monitorId = {{ String(monitorId, '7417', required=True) }}
+ AND timestamp >= toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 180 DAY, 3))
+ AND timestamp < toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 90 DAY, 3))
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__dns_metrics_latency_30d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_metrics_latency_30d__v0.pipe
new file mode 100644
index 000000000..94718c840
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__dns_metrics_latency_30d__v0.pipe
@@ -0,0 +1,24 @@
+TAGS "dns"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM dns_response__v0
+ WHERE
+ monitorId = {{ String(monitorId, '7417', required=True) }}
+ AND timestamp >= toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 30 DAY, 3))
+ GROUP BY h
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__dns_metrics_latency_90d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_metrics_latency_90d__v0.pipe
new file mode 100644
index 000000000..7f481e995
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__dns_metrics_latency_90d__v0.pipe
@@ -0,0 +1,24 @@
+TAGS "dns"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM dns_response__v0
+ WHERE
+ monitorId = {{ String(monitorId, '7417', required=True) }}
+ AND timestamp >= toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 90 DAY, 3))
+ GROUP BY h
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__dns_metrics_regions_30d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_metrics_regions_30d__v0.pipe
new file mode 100644
index 000000000..51e02a67e
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__dns_metrics_regions_30d__v0.pipe
@@ -0,0 +1,26 @@
+TAGS "dns"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ region,
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM dns_response__v0
+ WHERE
+ monitorId = {{ String(monitorId, '7417', required=True) }}
+ AND timestamp >= toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 30 DAY, 3))
+ {% if defined(regions) %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ GROUP BY h, region
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__dns_metrics_regions_90d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_metrics_regions_90d__v0.pipe
new file mode 100644
index 000000000..49bb57f82
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__dns_metrics_regions_90d__v0.pipe
@@ -0,0 +1,26 @@
+TAGS "dns"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ region,
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM dns_response__v0
+ WHERE
+ monitorId = {{ String(monitorId, '7417', required=True) }}
+ AND timestamp >= toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 90 DAY, 3))
+ {% if defined(regions) %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ GROUP BY h, region
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__dns_uptime_30d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_uptime_30d__v0.pipe
index 183e244ab..1a7b9fc61 100644
--- a/packages/tinybird/endpoints/endpoint__dns_uptime_30d__v0.pipe
+++ b/packages/tinybird/endpoints/endpoint__dns_uptime_30d__v0.pipe
@@ -14,6 +14,8 @@ SQL >
FROM dns_response__v0
WHERE
monitorId = {{ String(monitorId, '7417', required=True) }}
+ -- dns_response__v0 has no TTL; cap the window like the TTL-bound http/tcp uptime MVs
+ AND toDateTime(timestamp / 1000) >= now() - INTERVAL 30 DAY
{% if defined(fromDate) %}
AND toDateTime(timestamp / 1000) >= parseDateTimeBestEffortOrNull({{ String(fromDate) }})
{% end %}
diff --git a/packages/tinybird/endpoints/endpoint__dns_uptime_90d__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_uptime_90d__v0.pipe
new file mode 100644
index 000000000..8ea04645d
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__dns_uptime_90d__v0.pipe
@@ -0,0 +1,29 @@
+TAGS "dns"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(
+ toDateTime(timestamp / 1000), INTERVAL {{ String(interval, '1440', required=True) }} minute
+ ) AS interval,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error
+ FROM dns_response__v0
+ WHERE
+ monitorId = {{ String(monitorId, '7417', required=True) }}
+ -- dns_response__v0 has no TTL; cap the window like the TTL-bound http/tcp uptime MVs
+ AND toDateTime(timestamp / 1000) >= now() - INTERVAL 90 DAY
+ {% if defined(fromDate) %}
+ AND toDateTime(timestamp / 1000) >= parseDateTimeBestEffortOrNull({{ String(fromDate) }})
+ {% end %}
+ {% if defined(toDate) %}
+ AND toDateTime(timestamp / 1000) <= parseDateTimeBestEffortOrNull({{ String(toDate) }})
+ {% end %}
+ {% if defined(regions) %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ GROUP BY interval
+ ORDER BY interval DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__http_metrics_30d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_metrics_30d__v1.pipe
new file mode 100644
index 000000000..5e1b67d1f
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__http_metrics_30d__v1.pipe
@@ -0,0 +1,42 @@
+TAGS "http"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ max(cronTimestamp) AS lastTimestamp
+ FROM mv__http_30d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '1', required=True) }}
+ AND time >= toDateTime64(now() - INTERVAL 30 DAY, 3)
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ UNION ALL
+ SELECT
+ round(quantile(0.50)(latency)) AS p50Latency,
+ round(quantile(0.75)(latency)) AS p75Latency,
+ round(quantile(0.90)(latency)) AS p90Latency,
+ round(quantile(0.95)(latency)) AS p95Latency,
+ round(quantile(0.99)(latency)) AS p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ NULL as lastTimestamp -- no need to query the `lastTimestamp` as not relevant
+ FROM mv__http_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '1', required=True) }}
+ AND time >= toDateTime64(now() - INTERVAL 60 DAY, 3)
+ AND time < toDateTime64(now() - INTERVAL 30 DAY, 3)
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__http_metrics_90d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_metrics_90d__v1.pipe
new file mode 100644
index 000000000..87d67b58e
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__http_metrics_90d__v1.pipe
@@ -0,0 +1,44 @@
+TAGS "http"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ max(cronTimestamp) AS lastTimestamp
+ FROM mv__http_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '1', required=True) }}
+ AND time >= toDateTime64(now() - INTERVAL 90 DAY, 3)
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ UNION ALL
+ -- previous 90d window is beyond the 90d TTL, so this row is empty and the
+ -- client suppresses the trend badge (NaN). keeps the 2-row contract intact.
+ SELECT
+ round(quantile(0.50)(latency)) AS p50Latency,
+ round(quantile(0.75)(latency)) AS p75Latency,
+ round(quantile(0.90)(latency)) AS p90Latency,
+ round(quantile(0.95)(latency)) AS p95Latency,
+ round(quantile(0.99)(latency)) AS p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ NULL as lastTimestamp
+ FROM mv__http_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '1', required=True) }}
+ AND time >= toDateTime64(now() - INTERVAL 180 DAY, 3)
+ AND time < toDateTime64(now() - INTERVAL 90 DAY, 3)
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__http_metrics_latency_30d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_metrics_latency_30d__v1.pipe
new file mode 100644
index 000000000..7159a465a
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__http_metrics_latency_30d__v1.pipe
@@ -0,0 +1,24 @@
+TAGS "http"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM mv__http_30d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '1', required=True) }}
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ GROUP BY h
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__http_metrics_latency_90d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_metrics_latency_90d__v1.pipe
new file mode 100644
index 000000000..b7651b8f4
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__http_metrics_latency_90d__v1.pipe
@@ -0,0 +1,24 @@
+TAGS "http"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM mv__http_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '1', required=True) }}
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ GROUP BY h
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__http_metrics_regions_30d__v0.pipe b/packages/tinybird/endpoints/endpoint__http_metrics_regions_30d__v0.pipe
new file mode 100644
index 000000000..2bcf3d7c6
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__http_metrics_regions_30d__v0.pipe
@@ -0,0 +1,25 @@
+TAGS "http"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ region,
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM mv__http_30d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '1', required=True) }}
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ GROUP BY h, region
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__http_metrics_regions_90d__v0.pipe b/packages/tinybird/endpoints/endpoint__http_metrics_regions_90d__v0.pipe
new file mode 100644
index 000000000..891fe3184
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__http_metrics_regions_90d__v0.pipe
@@ -0,0 +1,25 @@
+TAGS "http"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ region,
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM mv__http_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '1', required=True) }}
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ GROUP BY h, region
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__http_timing_phases_30d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_timing_phases_30d__v1.pipe
new file mode 100644
index 000000000..b44386cd5
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__http_timing_phases_30d__v1.pipe
@@ -0,0 +1,40 @@
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(time, INTERVAL {{ Int64(interval, 1440) }} MINUTE) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.5)(dns)) as p50Dns,
+ round(quantile(0.5)(firstByte)) as p50Ttfb,
+ round(quantile(0.5)(transfer)) as p50Transfer,
+ round(quantile(0.5)(connect)) as p50Connect,
+ round(quantile(0.5)(tls)) as p50Tls,
+ round(quantile(0.75)(dns)) as p75Dns,
+ round(quantile(0.75)(firstByte)) as p75Ttfb,
+ round(quantile(0.75)(transfer)) as p75Transfer,
+ round(quantile(0.75)(connect)) as p75Connect,
+ round(quantile(0.75)(tls)) as p75Tls,
+ round(quantile(0.90)(dns)) as p90Dns,
+ round(quantile(0.90)(firstByte)) as p90Ttfb,
+ round(quantile(0.90)(transfer)) as p90Transfer,
+ round(quantile(0.90)(connect)) as p90Connect,
+ round(quantile(0.90)(tls)) as p90Tls,
+ round(quantile(0.95)(dns)) as p95Dns,
+ round(quantile(0.95)(firstByte)) as p95Ttfb,
+ round(quantile(0.95)(transfer)) as p95Transfer,
+ round(quantile(0.95)(connect)) as p95Connect,
+ round(quantile(0.95)(tls)) as p95Tls,
+ round(quantile(0.99)(dns)) as p99Dns,
+ round(quantile(0.99)(firstByte)) as p99Ttfb,
+ round(quantile(0.99)(transfer)) as p99Transfer,
+ round(quantile(0.99)(connect)) as p99Connect,
+ round(quantile(0.99)(tls)) as p99Tls
+ FROM mv__http_timing_phases_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '141', required=True) }}
+ AND time >= toDateTime64(now() - INTERVAL 30 DAY, 3)
+ GROUP BY h
+ ORDER BY h ASC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__http_timing_phases_90d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_timing_phases_90d__v1.pipe
new file mode 100644
index 000000000..e6209ffff
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__http_timing_phases_90d__v1.pipe
@@ -0,0 +1,38 @@
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(time, INTERVAL {{ Int64(interval, 1440) }} MINUTE) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.5)(dns)) as p50Dns,
+ round(quantile(0.5)(firstByte)) as p50Ttfb,
+ round(quantile(0.5)(transfer)) as p50Transfer,
+ round(quantile(0.5)(connect)) as p50Connect,
+ round(quantile(0.5)(tls)) as p50Tls,
+ round(quantile(0.75)(dns)) as p75Dns,
+ round(quantile(0.75)(firstByte)) as p75Ttfb,
+ round(quantile(0.75)(transfer)) as p75Transfer,
+ round(quantile(0.75)(connect)) as p75Connect,
+ round(quantile(0.75)(tls)) as p75Tls,
+ round(quantile(0.90)(dns)) as p90Dns,
+ round(quantile(0.90)(firstByte)) as p90Ttfb,
+ round(quantile(0.90)(transfer)) as p90Transfer,
+ round(quantile(0.90)(connect)) as p90Connect,
+ round(quantile(0.90)(tls)) as p90Tls,
+ round(quantile(0.95)(dns)) as p95Dns,
+ round(quantile(0.95)(firstByte)) as p95Ttfb,
+ round(quantile(0.95)(transfer)) as p95Transfer,
+ round(quantile(0.95)(connect)) as p95Connect,
+ round(quantile(0.95)(tls)) as p95Tls,
+ round(quantile(0.99)(dns)) as p99Dns,
+ round(quantile(0.99)(firstByte)) as p99Ttfb,
+ round(quantile(0.99)(transfer)) as p99Transfer,
+ round(quantile(0.99)(connect)) as p99Connect,
+ round(quantile(0.99)(tls)) as p99Tls
+ FROM mv__http_timing_phases_90d__v1
+ WHERE monitorId = {{ String(monitorId, '141', required=True) }}
+ GROUP BY h
+ ORDER BY h ASC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__http_uptime_90d__v1.pipe b/packages/tinybird/endpoints/endpoint__http_uptime_90d__v1.pipe
new file mode 100644
index 000000000..fec0e098e
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__http_uptime_90d__v1.pipe
@@ -0,0 +1,21 @@
+TAGS "http"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(time, INTERVAL {{ String(interval, '1440', required=True) }} minute) AS interval,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error
+ FROM mv__http_uptime_90d__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
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_30d__v1.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_30d__v1.pipe
new file mode 100644
index 000000000..7c74e8199
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_30d__v1.pipe
@@ -0,0 +1,42 @@
+TAGS "tcp"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ max(cronTimestamp) AS lastTimestamp
+ FROM mv__tcp_30d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '4433', required=True) }}
+ AND time >= toDateTime64(now() - INTERVAL 30 DAY, 3)
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ UNION ALL
+ SELECT
+ round(quantile(0.50)(latency)) AS p50Latency,
+ round(quantile(0.75)(latency)) AS p75Latency,
+ round(quantile(0.90)(latency)) AS p90Latency,
+ round(quantile(0.95)(latency)) AS p95Latency,
+ round(quantile(0.99)(latency)) AS p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ NULL as lastTimestamp
+ FROM mv__tcp_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '4433', required=True) }}
+ AND time >= toDateTime64(now() - INTERVAL 60 DAY, 3)
+ AND time < toDateTime64(now() - INTERVAL 30 DAY, 3)
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_90d__v1.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_90d__v1.pipe
new file mode 100644
index 000000000..7c21a27fa
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_90d__v1.pipe
@@ -0,0 +1,43 @@
+TAGS "tcp"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ max(cronTimestamp) AS lastTimestamp
+ FROM mv__tcp_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '4433', required=True) }}
+ AND time >= toDateTime64(now() - INTERVAL 90 DAY, 3)
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+ UNION ALL
+ -- previous 90d window is beyond the 90d TTL: empty row, trend suppressed client-side
+ SELECT
+ round(quantile(0.50)(latency)) AS p50Latency,
+ round(quantile(0.75)(latency)) AS p75Latency,
+ round(quantile(0.90)(latency)) AS p90Latency,
+ round(quantile(0.95)(latency)) AS p95Latency,
+ round(quantile(0.99)(latency)) AS p99Latency,
+ count() as count,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error,
+ NULL as lastTimestamp
+ FROM mv__tcp_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '4433', required=True) }}
+ AND time >= toDateTime64(now() - INTERVAL 180 DAY, 3)
+ AND time < toDateTime64(now() - INTERVAL 90 DAY, 3)
+ {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_14d.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_14d.pipe
index 6bb2d8bc3..a49a2629d 100644
--- a/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_14d.pipe
+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_14d.pipe
@@ -20,7 +20,7 @@ SQL >
round(quantile(0.99)(latency)) as p99Latency
FROM mv__tcp_14d__v0
WHERE
- monitorId = {{ String(monitorId, '1', required=True) }}
+ monitorId = {{ String(monitorId, '4433', required=True) }}
GROUP BY h, region
ORDER BY h DESC
diff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_1d.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_1d.pipe
index 9e1ecdc2b..11e8771bc 100644
--- a/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_1d.pipe
+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_1d.pipe
@@ -20,7 +20,7 @@ SQL >
round(quantile(0.99)(latency)) as p99Latency
FROM mv__tcp_1d__v0
WHERE
- monitorId = {{ String(monitorId, '1', required=True) }}
+ monitorId = {{ String(monitorId, '4433', required=True) }}
GROUP BY h, region
ORDER BY h DESC
diff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_30d.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_30d.pipe
new file mode 100644
index 000000000..637d31844
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_30d.pipe
@@ -0,0 +1,26 @@
+VERSION 0
+
+TAGS tcp
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ region,
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM mv__tcp_30d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '4433', required=True) }}
+ GROUP BY h, region
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_7d.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_7d.pipe
index 8affe8df4..77e3011a0 100644
--- a/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_7d.pipe
+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_7d.pipe
@@ -20,7 +20,7 @@ SQL >
round(quantile(0.99)(latency)) as p99Latency
FROM mv__tcp_7d__v0
WHERE
- monitorId = {{ String(monitorId, '1', required=True) }}
+ monitorId = {{ String(monitorId, '4433', required=True) }}
GROUP BY h, region
ORDER BY h DESC
diff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_90d.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_90d.pipe
new file mode 100644
index 000000000..b5882f9a1
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_by_interval_90d.pipe
@@ -0,0 +1,26 @@
+VERSION 0
+
+TAGS tcp
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ region,
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM mv__tcp_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '4433', required=True) }}
+ GROUP BY h, region
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_30d__v1.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_30d__v1.pipe
new file mode 100644
index 000000000..84430f4fd
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_30d__v1.pipe
@@ -0,0 +1,23 @@
+TAGS "tcp"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM mv__tcp_30d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '4433', required=True) }}
+ GROUP BY h
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_90d__v1.pipe b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_90d__v1.pipe
new file mode 100644
index 000000000..912d4f498
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__tcp_metrics_latency_90d__v1.pipe
@@ -0,0 +1,23 @@
+TAGS "tcp"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(
+ toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 1440) }} MINUTE
+ ) as h,
+ toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
+ round(quantile(0.50)(latency)) as p50Latency,
+ round(quantile(0.75)(latency)) as p75Latency,
+ round(quantile(0.90)(latency)) as p90Latency,
+ round(quantile(0.95)(latency)) as p95Latency,
+ round(quantile(0.99)(latency)) as p99Latency
+ FROM mv__tcp_90d__v1
+ WHERE
+ monitorId = {{ String(monitorId, '4433', required=True) }}
+ GROUP BY h
+ ORDER BY h DESC
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/endpoints/endpoint__tcp_uptime_90d__v1.pipe b/packages/tinybird/endpoints/endpoint__tcp_uptime_90d__v1.pipe
new file mode 100644
index 000000000..3eb0e49a1
--- /dev/null
+++ b/packages/tinybird/endpoints/endpoint__tcp_uptime_90d__v1.pipe
@@ -0,0 +1,21 @@
+TAGS "tcp"
+
+NODE endpoint
+SQL >
+
+ %
+ SELECT
+ toStartOfInterval(time, INTERVAL {{ String(interval, '1440', required=True) }} minute) AS interval,
+ countIf(requestStatus = 'success') AS success,
+ countIf(requestStatus = 'degraded') AS degraded,
+ countIf(requestStatus = 'error') AS error
+ FROM mv__tcp_uptime_90d__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
+
+TYPE ENDPOINT
diff --git a/packages/tinybird/pipes/aggregate__http_90d__v1.pipe b/packages/tinybird/pipes/aggregate__http_90d__v1.pipe
new file mode 100644
index 000000000..a184aed13
--- /dev/null
+++ b/packages/tinybird/pipes/aggregate__http_90d__v1.pipe
@@ -0,0 +1,19 @@
+NODE aggregate
+SQL >
+
+ SELECT
+ toDateTime(fromUnixTimestamp64Milli(cronTimestamp)) AS time,
+ id,
+ latency,
+ region,
+ trigger,
+ statusCode,
+ timestamp,
+ cronTimestamp,
+ monitorId,
+ requestStatus,
+ timing
+ FROM ping_response__v8
+
+TYPE materialized
+DATASOURCE mv__http_90d__v1
diff --git a/packages/tinybird/pipes/aggregate__http_timing_phases_90d__v1.pipe b/packages/tinybird/pipes/aggregate__http_timing_phases_90d__v1.pipe
new file mode 100644
index 000000000..f2d58c3cd
--- /dev/null
+++ b/packages/tinybird/pipes/aggregate__http_timing_phases_90d__v1.pipe
@@ -0,0 +1,33 @@
+NODE aggregate
+SQL >
+
+ SELECT
+ toDateTime(fromUnixTimestamp64Milli(cronTimestamp)) AS time,
+ latency,
+ region,
+ trigger,
+ statusCode,
+ monitorId,
+ workspaceId,
+ requestStatus,
+
+ -- Compute actual durations from timing phases
+ if(isNull(JSONExtractInt(timing, 'dnsStart')) OR isNull(JSONExtractInt(timing, 'dnsDone')), NULL,
+ JSONExtractInt(timing, 'dnsDone') - JSONExtractInt(timing, 'dnsStart')) AS dns,
+
+ if(isNull(JSONExtractInt(timing, 'connectStart')) OR isNull(JSONExtractInt(timing, 'connectDone')), NULL,
+ JSONExtractInt(timing, 'connectDone') - JSONExtractInt(timing, 'connectStart')) AS connect,
+
+ if(isNull(JSONExtractInt(timing, 'tlsHandshakeStart')) OR isNull(JSONExtractInt(timing, 'tlsHandshakeDone')), NULL,
+ JSONExtractInt(timing, 'tlsHandshakeDone') - JSONExtractInt(timing, 'tlsHandshakeStart')) AS tls,
+
+ if(isNull(JSONExtractInt(timing, 'firstByteStart')) OR isNull(JSONExtractInt(timing, 'firstByteDone')), NULL,
+ JSONExtractInt(timing, 'firstByteDone') - JSONExtractInt(timing, 'firstByteStart')) AS firstByte,
+
+ if(isNull(JSONExtractInt(timing, 'transferStart')) OR isNull(JSONExtractInt(timing, 'transferDone')), NULL,
+ JSONExtractInt(timing, 'transferDone') - JSONExtractInt(timing, 'transferStart')) AS transfer
+
+ FROM ping_response__v8
+
+TYPE materialized
+DATASOURCE mv__http_timing_phases_90d__v1
diff --git a/packages/tinybird/pipes/aggregate__http_uptime_90d__v1.pipe b/packages/tinybird/pipes/aggregate__http_uptime_90d__v1.pipe
new file mode 100644
index 000000000..10e064a6e
--- /dev/null
+++ b/packages/tinybird/pipes/aggregate__http_uptime_90d__v1.pipe
@@ -0,0 +1,17 @@
+VERSION 1
+
+TAGS http
+
+NODE aggregate
+SQL >
+
+ SELECT
+ toDateTime(fromUnixTimestamp64Milli(cronTimestamp)) AS time,
+ region,
+ requestStatus,
+ monitorId,
+ workspaceId
+ FROM ping_response__v8
+
+TYPE materialized
+DATASOURCE mv__http_uptime_90d__v1
diff --git a/packages/tinybird/pipes/aggregate__tcp_90d__v1.pipe b/packages/tinybird/pipes/aggregate__tcp_90d__v1.pipe
new file mode 100644
index 000000000..4a0a126e1
--- /dev/null
+++ b/packages/tinybird/pipes/aggregate__tcp_90d__v1.pipe
@@ -0,0 +1,20 @@
+TAGS "tcp"
+
+NODE aggregate
+SQL >
+
+ SELECT
+ toDateTime(fromUnixTimestamp64Milli(cronTimestamp)) AS time,
+ latency,
+ error,
+ region,
+ trigger,
+ timestamp,
+ cronTimestamp,
+ monitorId,
+ requestStatus,
+ id
+ FROM tcp_response__v0
+
+TYPE materialized
+DATASOURCE mv__tcp_90d__v1
diff --git a/packages/tinybird/pipes/aggregate__tcp_uptime_90d__v1.pipe b/packages/tinybird/pipes/aggregate__tcp_uptime_90d__v1.pipe
new file mode 100644
index 000000000..71676f326
--- /dev/null
+++ b/packages/tinybird/pipes/aggregate__tcp_uptime_90d__v1.pipe
@@ -0,0 +1,13 @@
+NODE aggregate
+SQL >
+
+ SELECT
+ toDateTime(fromUnixTimestamp64Milli(cronTimestamp)) AS time,
+ region,
+ requestStatus,
+ monitorId,
+ workspaceId
+ FROM tcp_response__v0
+
+TYPE materialized
+DATASOURCE mv__tcp_uptime_90d__v1
diff --git a/packages/tinybird/src/client.ts b/packages/tinybird/src/client.ts
index 5589a03f6..6a07e4c46 100644
--- a/packages/tinybird/src/client.ts
+++ b/packages/tinybird/src/client.ts
@@ -1733,6 +1733,531 @@ export class OSTinybird {
});
}
+ public get httpMetrics30d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__http_metrics_30d__v1",
+ parameters: z.object({
+ interval: z.int().optional(),
+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),
+ monitorId: z.string(),
+ }),
+ data: z.object({
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ count: z.int().prefault(0),
+ success: z.int().prefault(0),
+ degraded: z.int().prefault(0),
+ error: z.int().prefault(0),
+ lastTimestamp: z.int().nullable(),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get httpMetrics90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__http_metrics_90d__v1",
+ parameters: z.object({
+ interval: z.int().optional(),
+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),
+ monitorId: z.string(),
+ }),
+ data: z.object({
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ count: z.int().prefault(0),
+ success: z.int().prefault(0),
+ degraded: z.int().prefault(0),
+ error: z.int().prefault(0),
+ lastTimestamp: z.int().nullable(),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get tcpMetrics30d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__tcp_metrics_30d__v1",
+ parameters: z.object({
+ interval: z.int().optional(),
+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),
+ monitorId: z.string(),
+ }),
+ data: z.object({
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ count: z.int().prefault(0),
+ success: z.int().prefault(0),
+ degraded: z.int().prefault(0),
+ error: z.int().prefault(0),
+ lastTimestamp: z.int().nullable(),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get tcpMetrics90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__tcp_metrics_90d__v1",
+ parameters: z.object({
+ interval: z.int().optional(),
+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),
+ monitorId: z.string(),
+ }),
+ data: z.object({
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ count: z.int().prefault(0),
+ success: z.int().prefault(0),
+ degraded: z.int().prefault(0),
+ error: z.int().prefault(0),
+ lastTimestamp: z.int().nullable(),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get dnsMetrics30d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__dns_metrics_30d__v0",
+ parameters: z.object({
+ interval: z.int().optional(),
+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),
+ monitorId: z.string(),
+ }),
+ data: z.object({
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ count: z.int().prefault(0),
+ success: z.int().prefault(0),
+ degraded: z.int().prefault(0),
+ error: z.int().prefault(0),
+ lastTimestamp: z.int().nullable(),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get dnsMetrics90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__dns_metrics_90d__v0",
+ parameters: z.object({
+ interval: z.int().optional(),
+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),
+ monitorId: z.string(),
+ }),
+ data: z.object({
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ count: z.int().prefault(0),
+ success: z.int().prefault(0),
+ degraded: z.int().prefault(0),
+ error: z.int().prefault(0),
+ lastTimestamp: z.int().nullable(),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get httpUptime90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__http_uptime_90d__v1",
+ parameters: z.object({
+ monitorId: z.string(),
+ fromDate: z.string().optional(),
+ toDate: z.string().optional(),
+ regions: z.enum(monitorRegions).or(z.string()).array().optional(),
+ interval: z.int().optional(),
+ }),
+ data: z.object({
+ interval: z.coerce.date(),
+ success: z.int(),
+ degraded: z.int(),
+ error: z.int(),
+ }),
+ });
+ }
+
+ public get tcpUptime90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__tcp_uptime_90d__v1",
+ parameters: z.object({
+ monitorId: z.string(),
+ fromDate: z.string().optional(),
+ toDate: z.string().optional(),
+ regions: z.enum(monitorRegions).or(z.string()).array().optional(),
+ interval: z.int().optional(),
+ }),
+ data: z.object({
+ interval: z.coerce.date(),
+ success: z.int(),
+ degraded: z.int(),
+ error: z.int(),
+ }),
+ });
+ }
+
+ public get dnsUptime90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__dns_uptime_90d__v0",
+ parameters: z.object({
+ monitorId: z.string(),
+ fromDate: z.string().optional(),
+ toDate: z.string().optional(),
+ regions: z.enum(monitorRegions).or(z.string()).array().optional(),
+ interval: z.int().optional(),
+ }),
+ data: z.object({
+ interval: z.coerce.date(),
+ success: z.int(),
+ degraded: z.int(),
+ error: z.int(),
+ }),
+ });
+ }
+
+ public get httpMetricsRegions30d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__http_metrics_regions_30d__v0",
+ parameters: z.object({
+ monitorId: z.string(),
+ interval: z.int().optional(),
+ regions: z.string().array().optional(),
+ }),
+ data: z.object({
+ region: z.enum(monitorRegions).or(z.string()),
+ timestamp: z.int(),
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get httpMetricsRegions90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__http_metrics_regions_90d__v0",
+ parameters: z.object({
+ monitorId: z.string(),
+ interval: z.int().optional(),
+ regions: z.string().array().optional(),
+ }),
+ data: z.object({
+ region: z.enum(monitorRegions).or(z.string()),
+ timestamp: z.int(),
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get tcpMetricsByInterval30d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__tcp_metrics_by_interval_30d__v0",
+ parameters: z.object({
+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),
+ interval: z.int().optional(),
+ monitorId: z.string(),
+ }),
+ data: z.object({
+ region: z.enum(monitorRegions).or(z.string()),
+ timestamp: z.int(),
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get tcpMetricsByInterval90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__tcp_metrics_by_interval_90d__v0",
+ parameters: z.object({
+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),
+ interval: z.int().optional(),
+ monitorId: z.string(),
+ }),
+ data: z.object({
+ region: z.enum(monitorRegions).or(z.string()),
+ timestamp: z.int(),
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get dnsMetricsRegions30d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__dns_metrics_regions_30d__v0",
+ parameters: z.object({
+ monitorId: z.string(),
+ interval: z.int().optional(),
+ regions: z.string().array().optional(),
+ fromDate: z.string().optional(),
+ toDate: z.string().optional(),
+ }),
+ data: z.object({
+ region: z.enum(monitorRegions).or(z.string()),
+ timestamp: z.int(),
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get dnsMetricsRegions90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__dns_metrics_regions_90d__v0",
+ parameters: z.object({
+ monitorId: z.string(),
+ interval: z.int().optional(),
+ regions: z.string().array().optional(),
+ fromDate: z.string().optional(),
+ toDate: z.string().optional(),
+ }),
+ data: z.object({
+ region: z.enum(monitorRegions).or(z.string()),
+ timestamp: z.int(),
+ p50Latency: z.number().nullable().prefault(0),
+ p75Latency: z.number().nullable().prefault(0),
+ p90Latency: z.number().nullable().prefault(0),
+ p95Latency: z.number().nullable().prefault(0),
+ p99Latency: z.number().nullable().prefault(0),
+ }),
+ opts: { next: { revalidate: REVALIDATE } },
+ });
+ }
+
+ public get httpMetricsLatency30d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__http_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(),
+ }),
+ data: z.object({
+ timestamp: z.int(),
+ p50Latency: z.int(),
+ p75Latency: z.int(),
+ p90Latency: z.int(),
+ p95Latency: z.int(),
+ p99Latency: z.int(),
+ }),
+ });
+ }
+
+ public get httpMetricsLatency90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__http_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(),
+ }),
+ data: z.object({
+ timestamp: z.int(),
+ p50Latency: z.int(),
+ p75Latency: z.int(),
+ p90Latency: z.int(),
+ p95Latency: z.int(),
+ p99Latency: z.int(),
+ }),
+ });
+ }
+
+ public get tcpMetricsLatency30d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__tcp_metrics_latency_30d__v1",
+ parameters: z.object({
+ monitorId: z.string(),
+ fromDate: z.string().optional(),
+ toDate: z.string().optional(),
+ }),
+ data: z.object({
+ timestamp: z.int(),
+ p50Latency: z.int(),
+ p75Latency: z.int(),
+ p90Latency: z.int(),
+ p95Latency: z.int(),
+ p99Latency: z.int(),
+ }),
+ });
+ }
+
+ public get tcpMetricsLatency90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__tcp_metrics_latency_90d__v1",
+ parameters: z.object({
+ monitorId: z.string(),
+ fromDate: z.string().optional(),
+ toDate: z.string().optional(),
+ }),
+ data: z.object({
+ timestamp: z.int(),
+ p50Latency: z.int(),
+ p75Latency: z.int(),
+ p90Latency: z.int(),
+ p95Latency: z.int(),
+ p99Latency: z.int(),
+ }),
+ });
+ }
+
+ public get dnsMetricsLatency30d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__dns_metrics_latency_30d__v0",
+ parameters: z.object({
+ monitorId: z.string(),
+ fromDate: z.string().optional(),
+ toDate: z.string().optional(),
+ }),
+ data: z.object({
+ timestamp: z.int(),
+ p50Latency: z.int(),
+ p75Latency: z.int(),
+ p90Latency: z.int(),
+ p95Latency: z.int(),
+ p99Latency: z.int(),
+ }),
+ });
+ }
+
+ public get dnsMetricsLatency90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__dns_metrics_latency_90d__v0",
+ parameters: z.object({
+ monitorId: z.string(),
+ fromDate: z.string().optional(),
+ toDate: z.string().optional(),
+ }),
+ data: z.object({
+ timestamp: z.int(),
+ p50Latency: z.int(),
+ p75Latency: z.int(),
+ p90Latency: z.int(),
+ p95Latency: z.int(),
+ p99Latency: z.int(),
+ }),
+ });
+ }
+
+ public get httpTimingPhases30d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__http_timing_phases_30d__v1",
+ parameters: z.object({
+ monitorId: z.string(),
+ interval: z.int().optional(),
+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),
+ }),
+ data: z.object({
+ timestamp: z.int(),
+ p50Dns: z.int().nullable().prefault(0),
+ p50Ttfb: z.int().nullable().prefault(0),
+ p50Transfer: z.int().nullable().prefault(0),
+ p50Connect: z.int().nullable().prefault(0),
+ p50Tls: z.int().nullable().prefault(0),
+ p75Dns: z.int().nullable().prefault(0),
+ p75Ttfb: z.int().nullable().prefault(0),
+ p75Transfer: z.int().nullable().prefault(0),
+ p75Connect: z.int().nullable().prefault(0),
+ p75Tls: z.int().nullable().prefault(0),
+ p90Dns: z.int().nullable().prefault(0),
+ p90Ttfb: z.int().nullable().prefault(0),
+ p90Transfer: z.int().nullable().prefault(0),
+ p90Connect: z.int().nullable().prefault(0),
+ p90Tls: z.int().nullable().prefault(0),
+ p95Dns: z.int().nullable().prefault(0),
+ p95Ttfb: z.int().nullable().prefault(0),
+ p95Transfer: z.int().nullable().prefault(0),
+ p95Connect: z.int().nullable().prefault(0),
+ p95Tls: z.int().nullable().prefault(0),
+ p99Dns: z.int().nullable().prefault(0),
+ p99Ttfb: z.int().nullable().prefault(0),
+ p99Transfer: z.int().nullable().prefault(0),
+ p99Connect: z.int().nullable().prefault(0),
+ p99Tls: z.int().nullable().prefault(0),
+ }),
+ });
+ }
+
+ public get httpTimingPhases90d() {
+ return this.tb.buildPipe({
+ pipe: "endpoint__http_timing_phases_90d__v1",
+ parameters: z.object({
+ monitorId: z.string(),
+ interval: z.int().optional(),
+ regions: z.array(z.enum(monitorRegions).or(z.string())).optional(),
+ }),
+ data: z.object({
+ timestamp: z.int(),
+ p50Dns: z.int().nullable().prefault(0),
+ p50Ttfb: z.int().nullable().prefault(0),
+ p50Transfer: z.int().nullable().prefault(0),
+ p50Connect: z.int().nullable().prefault(0),
+ p50Tls: z.int().nullable().prefault(0),
+ p75Dns: z.int().nullable().prefault(0),
+ p75Ttfb: z.int().nullable().prefault(0),
+ p75Transfer: z.int().nullable().prefault(0),
+ p75Connect: z.int().nullable().prefault(0),
+ p75Tls: z.int().nullable().prefault(0),
+ p90Dns: z.int().nullable().prefault(0),
+ p90Ttfb: z.int().nullable().prefault(0),
+ p90Transfer: z.int().nullable().prefault(0),
+ p90Connect: z.int().nullable().prefault(0),
+ p90Tls: z.int().nullable().prefault(0),
+ p95Dns: z.int().nullable().prefault(0),
+ p95Ttfb: z.int().nullable().prefault(0),
+ p95Transfer: z.int().nullable().prefault(0),
+ p95Connect: z.int().nullable().prefault(0),
+ p95Tls: z.int().nullable().prefault(0),
+ p99Dns: z.int().nullable().prefault(0),
+ p99Ttfb: z.int().nullable().prefault(0),
+ p99Transfer: z.int().nullable().prefault(0),
+ p99Connect: z.int().nullable().prefault(0),
+ p99Tls: z.int().nullable().prefault(0),
+ }),
+ });
+ }
+
public get dnsStatus45d() {
return this.tb.buildPipe({
pipe: "endpoint__dns_status_45d__v0",