Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
Make status page history configurable per-page (#2307)
Maximilian Kaske760b4bb570fb
diff --git a/.env.docker.example b/.env.docker.exampleindex 938f6029b..c7340aa44 100644--- a/.env.docker.example+++ b/.env.docker.example@@ -153,5 +153,4 @@ TURBO_ENV_MODE=loosePLAYGROUND_UNKEY_API_KEY=# Workspace settings (optional)-WORKSPACES_LOOKBACK_30=WORKSPACES_HIDE_URL=diff --git a/COOLIFY_ENVIRONMENT_GUIDE.md b/COOLIFY_ENVIRONMENT_GUIDE.mdindex d57fd5a2b..017d5dee8 100644--- a/COOLIFY_ENVIRONMENT_GUIDE.md+++ b/COOLIFY_ENVIRONMENT_GUIDE.md@@ -118,7 +118,6 @@ SCREENSHOT_SERVICE_URL=your_screenshot_service_url```bashTURBO_ENV_MODE=loosePLAYGROUND_UNKEY_API_KEY=your_playground_key-WORKSPACES_LOOKBACK_30=trueWORKSPACES_HIDE_URL=false```diff --git a/apps/dashboard/.env.example b/apps/dashboard/.env.exampleindex a6432d3a9..30af12a12 100644--- a/apps/dashboard/.env.example+++ b/apps/dashboard/.env.example@@ -70,7 +70,6 @@ PAGERDUTY_APP_ID=SLACK_SUPPORT_WEBHOOK_URL=-WORKSPACES_LOOKBACK_30=WORKSPACES_HIDE_URL=# https://turbo.build/repo/docs/crafting-your-repository/using-environment-variables#loose-modediff --git a/apps/dashboard/src/components/forms/components/update.tsx b/apps/dashboard/src/components/forms/components/update.tsxindex ffd66522d..bea15cffb 100644--- a/apps/dashboard/src/components/forms/components/update.tsx+++ b/apps/dashboard/src/components/forms/components/update.tsx@@ -122,6 +122,7 @@ export function FormComponentsUpdate() {}}/><FormConfiguration+ hasMonitorComponents={pageComponents.some((c) => c.type === "monitor")}defaultValues={{configuration: statusPage.configuration ?? {},}}@@ -144,6 +145,9 @@ export function FormComponentsUpdate() {"absolute") as PageConfiguration["type"],theme: (values.configuration.theme ??undefined) as PageConfiguration["theme"],+ days: (values.configuration.days+ ? Number(values.configuration.days)+ : undefined) as PageConfiguration["days"],},});}}diff --git a/apps/dashboard/src/components/forms/status-page/form-configuration.tsx b/apps/dashboard/src/components/forms/status-page/form-configuration.tsxindex ac6c5e5f9..a16a43993 100644--- a/apps/dashboard/src/components/forms/status-page/form-configuration.tsx+++ b/apps/dashboard/src/components/forms/status-page/form-configuration.tsx@@ -25,6 +25,7 @@ import {SelectTrigger,SelectValue,} from "@openstatus/ui/components/ui/select";+import { cn } from "@openstatus/ui/lib/utils";import { isTRPCClientError } from "@trpc/client";import { ArrowUpRight } from "lucide-react";import { parseAsStringLiteral, useQueryStates } from "nuqs";@@ -49,7 +50,7 @@ import {const schema = z.object({configuration: z.record(z.string(),- z.string().or(z.boolean().nullish()).optional(),+ z.string().or(z.boolean()).or(z.number()).nullish().optional(),),});@@ -59,6 +60,10 @@ const configurationSchema = zvalue: z.enum(["duration", "requests", "manual"]).nullish(),uptime: z.boolean().or(z.literal("true").or(z.literal("false"))),theme: z.enum(THEME_KEYS as [string, ...string[]]),+ days: z+ .union([z.literal(30), z.literal(45)])+ .or(z.literal("30").or(z.literal("45")))+ .nullish(),}).refine((data) => {@@ -78,10 +83,12 @@ export function FormConfiguration({defaultValues,onSubmit,configLink,+ hasMonitorComponents = true,}: {defaultValues?: FormValues;onSubmit: (values: FormValues) => Promise<void>;configLink: string;+ hasMonitorComponents?: boolean;}) {const [isPending, startTransition] = useTransition();const form = useForm<FormValues>({@@ -99,6 +106,7 @@ export function FormConfiguration({const watchConfigurationUptime = form.watch("configuration.uptime") as| "true"| "false";+ const watchConfigurationDays = form.watch("configuration.days") ?? 45;useEffect(() => {if (watchConfigurationType === "manual") {@@ -147,16 +155,22 @@ export function FormConfiguration({</FormCardDescription></FormCardHeader><FormCardSeparator />- <FormCardContent className="grid gap-4 sm:grid-cols-3">+ <FormCardContent+ className={cn(+ "grid gap-4 sm:grid-cols-2",+ !hasMonitorComponents && "pointer-events-none opacity-50",+ )}+ ><FormFieldcontrol={form.control}name="configuration.type"render={({ field }) => (<FormItem>- <FormLabel>Bar Type*</FormLabel>+ <FormLabel>Bar Type</FormLabel><SelectonValueChange={field.onChange}defaultValue={String(field.value) ?? "absolute"}+ disabled={!hasMonitorComponents}><FormControl><SelectTrigger className="w-full capitalize">@@ -184,11 +198,14 @@ export function FormConfiguration({name="configuration.value"render={({ field }) => (<FormItem>- <FormLabel>Card Value*</FormLabel>+ <FormLabel>Card Value</FormLabel><SelectonValueChange={field.onChange}defaultValue={String(field.value) ?? "duration"}- disabled={watchConfigurationType === "manual"}+ disabled={+ !hasMonitorComponents ||+ watchConfigurationType === "manual"+ }><FormControl><SelectTrigger className="w-full capitalize">@@ -211,6 +228,38 @@ export function FormConfiguration({</FormItem>)}/>+ <Note className="col-span-full">+ {hasMonitorComponents ? (+ <ul className="list-inside list-disc">+ <li>+ <span>Bar Type </span>+ <span className="font-medium">+ {watchConfigurationType}+ </span>+ : <span>{message.type[watchConfigurationType]}</span>+ </li>+ <li>+ <span>Card Value </span>+ <span className="font-medium">+ {watchConfigurationValue}+ </span>+ :{" "}+ <span>+ {message.value[watchConfigurationValue] ??+ message.value.default}+ </span>+ </li>+ </ul>+ ) : (+ <span>+ Add a monitor component to your status page to configure how+ its bars and cards display data.+ </span>+ )}+ </Note>+ </FormCardContent>+ <FormCardSeparator />+ <FormCardContent className="grid gap-4 sm:grid-cols-2"><FormFieldcontrol={form.control}name="configuration.uptime"@@ -242,36 +291,53 @@ export function FormConfiguration({</FormItem>)}/>- <p className="text-foreground/70 col-span-full text-sm">- *Configuration settings only apply to monitor components.- </p>+ <FormField+ control={form.control}+ name="configuration.days"+ render={({ field }) => (+ <FormItem>+ <FormLabel>History</FormLabel>+ <Select+ onValueChange={field.onChange}+ defaultValue={String(field.value ?? 45)}+ >+ <FormControl>+ <SelectTrigger className="w-full">+ <SelectValue placeholder="Select a range" />+ </SelectTrigger>+ </FormControl>+ <SelectContent>+ {["30", "45"].map((days) => (+ <SelectItem key={days} value={days}>+ {days} days+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <FormMessage />+ </FormItem>+ )}+ /><Note className="col-span-full"><ul className="list-inside list-disc"><li>- <span>Bar Type </span>- <span className="font-medium">- {watchConfigurationType}+ <span>Show Uptime </span>+ <span className="font-medium capitalize">+ {String(watchConfigurationUptime)}</span>- : <span>{message.type[watchConfigurationType]}</span>+ : <span>{message.uptime[watchConfigurationUptime]}</span></li><li>- <span>Card Value </span>+ <span>History </span><span className="font-medium">- {watchConfigurationValue}+ {String(watchConfigurationDays)} days</span>:{" "}<span>- {message.value[watchConfigurationValue] ??- message.value.default}+ shows the last {String(watchConfigurationDays)} days of+ component history.</span></li>- <li>- <span>Show Uptime </span>- <span className="font-medium capitalize">- {String(watchConfigurationUptime)}- </span>- : <span>{message.uptime[watchConfigurationUptime]}</span>- </li></ul></Note></FormCardContent>@@ -324,7 +390,7 @@ export function FormConfiguration({const message = {type: {manual:- "only shares the duration of reports and maintenaces you are setting up - nothing else.",+ "only shares the duration of reports and maintenances you are setting up - nothing else.",absolute:"shares the status of your endpoint for the duration of the different statuses.",},@@ -340,13 +406,14 @@ const message = {},} as const;-// ?type=manual&value=manual&uptime=true&theme=default+// ?type=manual&value=manual&uptime=true&theme=default&days=45const searchParams = {type: parseAsStringLiteral(["manual", "absolute"]),value: parseAsStringLiteral(["duration", "requests", "manual"]),uptime: parseAsStringLiteral(["true", "false"]),theme: parseAsStringLiteral(Object.keys(THEMES)),+ days: parseAsStringLiteral(["30", "45"]),};function FormConfigurationDialog({@@ -359,7 +426,7 @@ function FormConfigurationDialog({}) {const [open, setOpen] = useState(false);const [isPending, startTransition] = useTransition();- const [{ type, value, uptime, theme }, setSearchParams] =+ const [{ type, value, uptime, theme, days }, setSearchParams] =useQueryStates(searchParams);useEffect(() => {@@ -394,6 +461,7 @@ function FormConfigurationDialog({value: null,uptime: null,theme: null,+ days: null,});setOpen(false);} catch (error) {@@ -418,7 +486,7 @@ function FormConfigurationDialog({</DialogHeader><div className="flex flex-col gap-2"><pre className="bg-muted/50 font-commit-mono rounded-md border px-3 py-2 text-sm">- {JSON.stringify({ type, value, uptime, theme }, null, 2)}+ {JSON.stringify({ type, value, uptime, theme, days }, null, 2)}</pre></div><DialogFooter>@@ -435,6 +503,9 @@ function FormConfigurationDialog({value: value ?? undefined,uptime: uptime ?? undefined,theme: theme ?? undefined,+ // fall back to the page's stored value when the URL omits+ // `days` (e.g. links generated before it was added).+ days: days ?? defaultValues?.configuration?.days ?? undefined,},})}diff --git a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsx b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsxindex 920c095df..f650dcf94 100644--- a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsx+++ b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsx@@ -58,7 +58,7 @@ import { useTRPC } from "@/lib/trpc/client";export function Client() {const prefix = usePathnamePrefix();const { domain } = useParams<{ domain: string }>();- const { cardType, barType, showUptime } = useStatusPage();+ const { cardType, barType, showUptime, numberOfDays } = useStatusPage();const embed = useEmbed();const trpc = useTRPC();@@ -111,6 +111,7 @@ export function Client() {),cardType,barType,+ days: numberOfDays,}: skipToken,),diff --git a/apps/status-page/src/app/(status-page)/[domain]/layout.tsx b/apps/status-page/src/app/(status-page)/[domain]/layout.tsxindex 79acbe4c5..3b6b86fff 100644--- a/apps/status-page/src/app/(status-page)/[domain]/layout.tsx+++ b/apps/status-page/src/app/(status-page)/[domain]/layout.tsx@@ -60,6 +60,7 @@ export default async function Layout({defaultBarType={cfg.type}defaultCardType={cfg.value}defaultShowUptime={cfg.uptime}+ defaultNumberOfDays={cfg.days}defaultCommunityTheme={cfg.theme}>{children}diff --git a/apps/status-page/src/components/status-page/floating-button.tsx b/apps/status-page/src/components/status-page/floating-button.tsxindex bb4316e82..c19e8a756 100644--- a/apps/status-page/src/components/status-page/floating-button.tsx+++ b/apps/status-page/src/components/status-page/floating-button.tsx@@ -51,6 +51,9 @@ export type BarType = (typeof BAR_TYPE)[number];export const COMMUNITY_THEME = THEME_KEYS;export type CommunityTheme = (typeof COMMUNITY_THEME)[number];+export const NUMBER_OF_DAYS = [30, 45] as const;+export type NumberOfDays = (typeof NUMBER_OF_DAYS)[number];+interface StatusPageContextType {cardType: CardType;setCardType: (cardType: CardType) => void;@@ -58,6 +61,8 @@ interface StatusPageContextType {setBarType: (barType: BarType) => void;showUptime: boolean;setShowUptime: (showUptime: boolean) => void;+ numberOfDays: NumberOfDays;+ setNumberOfDays: (numberOfDays: NumberOfDays) => void;communityTheme: CommunityTheme;setCommunityTheme: (communityTheme: CommunityTheme) => void;}@@ -77,17 +82,21 @@ export function StatusPageProvider({defaultCardType = "duration",defaultBarType = "absolute",defaultShowUptime = true,+ defaultNumberOfDays = 45,defaultCommunityTheme = "default",}: {children: React.ReactNode;defaultCardType?: CardType;defaultBarType?: BarType;defaultShowUptime?: boolean;+ defaultNumberOfDays?: NumberOfDays;defaultCommunityTheme?: CommunityTheme;}) {const [cardType, setCardType] = useState<CardType>(defaultCardType);const [barType, setBarType] = useState<BarType>(defaultBarType);const [showUptime, setShowUptime] = useState<boolean>(defaultShowUptime);+ const [numberOfDays, setNumberOfDays] =+ useState<NumberOfDays>(defaultNumberOfDays);const [communityTheme, setCommunityTheme] = useState<CommunityTheme>(defaultCommunityTheme,);@@ -112,6 +121,8 @@ export function StatusPageProvider({setBarType,showUptime,setShowUptime,+ numberOfDays,+ setNumberOfDays,communityTheme,setCommunityTheme,}}@@ -137,6 +148,8 @@ export function FloatingButton({setBarType,showUptime,setShowUptime,+ numberOfDays,+ setNumberOfDays,communityTheme,setCommunityTheme,} = useStatusPage();@@ -258,6 +271,26 @@ export function FloatingButton({</SelectContent></Select></div>+ <div className="space-y-2">+ <Label htmlFor="number-of-days">History</Label>+ <Select+ value={String(numberOfDays)}+ onValueChange={(v) =>+ setNumberOfDays(Number(v) as NumberOfDays)+ }+ >+ <SelectTrigger id="number-of-days" className="w-full">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {NUMBER_OF_DAYS.map((v) => (+ <SelectItem key={v} value={String(v)}>+ {v} days+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div><div className="space-y-2"><Label htmlFor="theme">Theme</Label><ThemeSelect id="theme" className="max-w-full" />@@ -325,7 +358,7 @@ export function FloatingButton({<ahref={pageId- ? `https://app.openstatus.dev/status-pages/${pageId}/components?type=${barType}&value=${cardType}&uptime=${showUptime}&theme=${communityTheme}`+ ? `https://app.openstatus.dev/status-pages/${pageId}/components?type=${barType}&value=${cardType}&uptime=${showUptime}&theme=${communityTheme}&days=${numberOfDays}`: "https://app.openstatus.dev/status-pages"}target="_blank"diff --git a/apps/web/.env.example b/apps/web/.env.exampleindex 67626ddf1..5e77a5dc7 100644--- a/apps/web/.env.example+++ b/apps/web/.env.example@@ -71,7 +71,6 @@ PAGERDUTY_APP_ID=SLACK_FEEDBACK_WEBHOOK_URL=-WORKSPACES_LOOKBACK_30=WORKSPACES_HIDE_URL=# https://turbo.build/repo/docs/crafting-your-repository/using-environment-variables#loose-modediff --git a/apps/web/public/assets/changelog/status-page-history-days-selector.png b/apps/web/public/assets/changelog/status-page-history-days-selector.pngnew file mode 100644index 000000000..a3f00e70fBinary files /dev/null and b/apps/web/public/assets/changelog/status-page-history-days-selector.png differdiff --git a/apps/web/src/content/pages/changelog/status-page-history-days-selector.mdx b/apps/web/src/content/pages/changelog/status-page-history-days-selector.mdxnew file mode 100644index 000000000..826dc4f93--- /dev/null+++ b/apps/web/src/content/pages/changelog/status-page-history-days-selector.mdx@@ -0,0 +1,16 @@+---+title: "Configurable status page history"+description: "Choose how many days of uptime history your status page shows — 30 or 45."+publishedAt: "2026-06-24"+image: "/assets/changelog/status-page-history-days-selector.png"+category: "statuspage"+author: "openstatus"+---++The uptime bars on your status page can now show **30 or 45 days** of history — pick whichever fits your page from the status page configuration form.++Previously the number of bars was fixed and applied account-wide. It's now a per-page setting stored on the page itself, so different status pages can show different history windows.++The selector lives under **History** in the status page configuration. The default stays at 45 days, so existing pages are untouched.++Check out the [how to configure your status page](https://www.openstatus.dev/docs/guides/how-to-configure-status-page/) guide for more details.diff --git a/apps/web/src/content/pages/docs/guides/how-to-configure-status-page.mdx b/apps/web/src/content/pages/docs/guides/how-to-configure-status-page.mdxindex e4e1aad28..be0739cd7 100644--- a/apps/web/src/content/pages/docs/guides/how-to-configure-status-page.mdx+++ b/apps/web/src/content/pages/docs/guides/how-to-configure-status-page.mdx@@ -45,14 +45,22 @@ Before choosing to enable the new page, you can check the configuration first. C### 1. Tracker configuration-Three status tracker configurations give you flexibility in how collected data is displayed.+The tracker configuration is split into two groups: how each component's **bars and cards** display its data, and the page-wide **uptime and history** view. They live in separate containers because they answer two different questions.++#### Bars and cards++These settings only apply to **monitor components** — the container is disabled until your status page has at least one.**Bar type** — how every day is displayed in a status tracker. Either **absolute** or **manual**.-**Card type** — only configurable if the bar type is **absolute**. Choose between **duration**, which shows the duration of "success", "error", "degraded", or "maintenance" reports, or **requests**, which shares the number of request statuses themselves. If **manual** bar type is chosen, only the most significant status of the day is shown.+**Card value** — only configurable if the bar type is **absolute**. Choose between **duration**, which shows the duration of "success", "error", "degraded", or "maintenance" reports, or **requests**, which shares the number of request statuses themselves. If **manual** bar type is chosen, only the most significant status of the day is shown.++#### Uptime and history**Show uptime** — uptime is calculated by either the **duration** of the different reports _or_ the **request** values depending on what you've chosen for the **absolute** value (including incidents). If you've chosen **manual**, it's calculated only from the duration of your status reports.+**History** — the number of days of history rendered on the bars. Choose between **30** or **45** days (defaults to **45**).+A few examples to understand it:Example of **absolute bar** with **duration card** and **showing uptime**diff --git a/coolify-deployment.yaml b/coolify-deployment.yamlindex b4dc1a1ed..f430ab19d 100644--- a/coolify-deployment.yaml+++ b/coolify-deployment.yaml@@ -86,7 +86,6 @@ x-common-variables: &common-env # Database Configuration# Development & TestingTURBO_ENV_MODE: ${TURBO_ENV_MODE:-loose}PLAYGROUND_UNKEY_API_KEY: ${PLAYGROUND_UNKEY_API_KEY:-}- WORKSPACES_LOOKBACK_30: ${WORKSPACES_LOOKBACK_30:-}WORKSPACES_HIDE_URL: ${WORKSPACES_HIDE_URL:-}# Common Settingsdiff --git a/packages/api/src/router/statusPage.ts b/packages/api/src/router/statusPage.tsindex cceff91e2..3d415a8b2 100644--- a/packages/api/src/router/statusPage.ts+++ b/packages/api/src/router/statusPage.ts@@ -55,13 +55,6 @@ import {// NOTE: this router is used on status pages only - do not confuse with the page router which is used in the dashboard for the config-/**- * Right now, we do not allow workspaces to have a custom lookback period.- * If we decide to allow this in the future, we should move this to the database.- */-const WORKSPACES =- process.env.WORKSPACES_LOOKBACK_30?.split(",").map(Number) || [];-// Length-independent comparison so a wrong guess can't be timed by length or// character. Pure JS (no node:crypto) keeps it usable from the Edge runtime.function constantTimeEqual(@@ -603,6 +596,9 @@ export const statusPageRouter = createTRPCRouter({barType: z.enum(["absolute", "dominant", "manual"]).prefault("dominant"),+ // preview override for the floating-button config; falls back to the+ // page's stored `configuration.days` when omitted+ days: z.union([z.literal(30), z.literal(45)]).optional(),}),).query(async (opts) => {@@ -695,9 +691,12 @@ export const statusPageRouter = createTRPCRouter({}}- const lookbackPeriod = WORKSPACES.includes(_page.workspaceId ?? 0)- ? 30- : 45;+ const parsedConfiguration = pageConfigurationSchema.safeParse(+ _page.configuration ?? {},+ );+ const lookbackPeriod =+ input.days ??+ (parsedConfiguration.success ? parsedConfiguration.data.days : 45);return pageComponents.map((c) => {const events = getEvents({diff --git a/packages/api/src/router/statusPage.utils.test.ts b/packages/api/src/router/statusPage.utils.test.tsindex f2e9c515d..15baf7202 100644--- a/packages/api/src/router/statusPage.utils.test.ts+++ b/packages/api/src/router/statusPage.utils.test.ts@@ -801,6 +801,12 @@ describe("fillStatusDataFor45Days", () => {expect(result).toHaveLength(45);});+ it("should fill exactly 30 days when lookbackPeriod is 30", () => {+ const result = fillStatusDataFor45Days([], "1", 30);++ expect(result).toHaveLength(30);+ });+it("should sort data by day oldest first", () => {const data: StatusData[] = [];const result = fillStatusDataFor45Days(data, "1");diff --git a/packages/db/src/schema/pages/validation.ts b/packages/db/src/schema/pages/validation.tsindex ff49349d0..ff778e4a0 100644--- a/packages/db/src/schema/pages/validation.ts+++ b/packages/db/src/schema/pages/validation.ts@@ -104,6 +104,11 @@ export const pageConfigurationSchema = z.object({.enum(THEME_KEYS as [ThemeKey, ...ThemeKey[]]).nullish().transform((v) => v ?? "default"),+ // number of uptime bars rendered on the status page; only 30 or 45 supported+ days: z+ .union([z.literal(30), z.literal(45)])+ .nullish()+ .transform((v) => v ?? 45),});export type PageConfiguration = z.infer<typeof pageConfigurationSchema>;