Status pages
A StatusPage shows your users the health
of your services: current status, incident history, maintenance, and
subscriptions. What it shows is laid out in
StatusPageSections, and each
section lists StatusPageResources:
a monitor, a heartbeat, a group, or a manually tracked item, under a public
name.
- Public APIshows →api
- Backupsshows →backup
Create a page
Section titled “Create a page”A page needs a company name and a time zone. subdomain defaults to a
generated unique name:
const page = yield* BetterStack.Incidents.StatusPage("status", { companyName: "Acme Cloud", companyUrl: "https://acme.example.com", subdomain: "acme-cloud-status", timezone: "UTC", subscribable: true,});customDomain puts it on your own domain. Every prop updates in place except
organizationId and teamId, which replace the page.
Add a section
Section titled “Add a section”const core = yield* BetterStack.Incidents.StatusPageSection("core", { statusPageId: page.id, name: "Core services", position: 0,});position counts from 0. Inserting at a position shifts the sections at or
after it. Deleting a section also deletes the resources placed in it.
Show a monitor
Section titled “Show a monitor”A resource names what it shows by resourceType and resourceId, and how:
widgetType picks the widget, such as history or response_times.
const api = yield* BetterStack.Incidents.Monitor("api", { url: "https://api.acme.example.com/health", monitorType: "status",});yield* BetterStack.Incidents.StatusPageResource("api-item", { statusPageId: page.id, statusPageSectionId: core.id, resourceType: "Monitor", resourceId: api.id, publicName: "Public API", widgetType: "response_times",});Show a heartbeat
Section titled “Show a heartbeat”Without statusPageSectionId, a resource goes into the page’s first section:
const backup = yield* BetterStack.Incidents.Heartbeat("backup", { name: "Nightly backup", period: 86400, grace: 3600,});yield* BetterStack.Incidents.StatusPageResource("backup-item", { statusPageId: page.id, resourceType: "Heartbeat", resourceId: backup.id, publicName: "Backups",});Subscribe an address
Section titled “Subscribe an address”A StatusPageSubscriber
subscribes an e-mail address to the page’s updates, or, with
statusPageResourceIds, only to some of its resources:
yield* BetterStack.Incidents.StatusPageSubscriber("oncall", { statusPageId: page.id, email: "oncall@acme.example.com",});Better Stack e-mails that address whenever the page posts a status report
or update, and a subscriber created through the API is confirmed at once,
with no confirmation round trip. Subscribe only addresses that expect it.
Destroying the subscriber unsubscribes the address. email can’t change, and
a different statusPageId replaces the subscriber.
Group pages
Section titled “Group pages”A StatusPageGroup keeps a product’s
pages together. Groups belong to the organization rather than to one team:
const pages = yield* BetterStack.Incidents.StatusPageGroup("acme", { name: "Acme Cloud" });yield* BetterStack.Incidents.StatusPage("docs-status", { companyName: "Acme Docs", subdomain: "acme-docs-status", timezone: "UTC", statusPageGroupId: pages.id,});Post a report from running code
Section titled “Post a report from running code”Incidents.CreateStatusReport publishes an incident or maintenance report on
a page from a running Service. It needs an API token: Better Stack has no
narrower credential for it. You pass the token explicitly, read from the
deploying process’s environment, never the deployer’s own:
const IncidentsToken = BetterStack.apiTokenFromConfig("BETTERSTACK_INCIDENTS_TOKEN");Then bind it to the page and call it:
import * as BetterStack from "betterstack-alchemy";import * as Effect from "effect/Effect";import * as HttpServerResponse from "effect/http/HttpServerResponse";import { Box } from "./shared.ts";
export const PublicStatus = BetterStack.Incidents.StatusPage("PublicStatus", { companyName: "Acme Cloud", timezone: "UTC",});
const IncidentsToken = BetterStack.apiTokenFromConfig("BETTERSTACK_INCIDENTS_TOKEN");
export default class Api extends BetterStack.Cloud.Service<Api>()( "Api", { server: Box, main: import.meta.url, port: 3000 }, Effect.gen(function* () { const report = yield* BetterStack.Incidents.CreateStatusReport(PublicStatus, IncidentsToken); return { fetch: Effect.gen(function* () { const created = yield* report({ title: "Degraded checkout", message: "We are looking into slow payments.", reportType: "manual", affectedResources: [{ statusPageResourceId: "456", status: "degraded" }], notifySubscribers: false, }); return yield* HttpServerResponse.json({ id: created.id }); }).pipe(Effect.orDie), }; }).pipe(Effect.provide(BetterStack.Incidents.CreateStatusReportHttp)),) {}The report is public at once. With notifySubscribers: true, every subscriber
is e-mailed. Use a team-scoped Uptime API token rather than a global one.
Incidents.CreateStatusUpdate adds an update to an existing report the same
way. Both bindings are tested against the offline mock only; see
Compatibility.
Where next
Section titled “Where next”- Monitors and Heartbeats: what a page shows.
- Teams, tokens & zones: which token reaches the Uptime API.
- Reference:
StatusPage,StatusPageSection,StatusPageResource,StatusPageGroup. - Better Stack: Create a status page (API).