Skip to content
betterstack-alchemyUnofficial

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.

acme-cloud-statusstatus page
Core servicessection
Public APIresource · response_times
Backgroundsection
Backupsresource
apimonitor
backupheartbeat
  • Public APIshows →api
  • Backupsshows →backup
A page holds sections, sections hold resources, and each resource shows one monitor or heartbeat under a public name. Deleting a resource never touches the monitor it shows.

A page needs a company name and a time zone. subdomain defaults to a generated unique name:

alchemy.run.ts
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.

alchemy.run.ts
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.

A resource names what it shows by resourceType and resourceId, and how: widgetType picks the widget, such as history or response_times.

alchemy.run.ts
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",
});

Without statusPageSectionId, a resource goes into the page’s first section:

alchemy.run.ts
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",
});

A StatusPageSubscriber subscribes an e-mail address to the page’s updates, or, with statusPageResourceIds, only to some of its resources:

alchemy.run.ts
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.

A StatusPageGroup keeps a product’s pages together. Groups belong to the organization rather than to one team:

alchemy.run.ts
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,
});

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:

src/api.ts
const IncidentsToken = BetterStack.apiTokenFromConfig("BETTERSTACK_INCIDENTS_TOKEN");

Then bind it to the page and call it:

src/api.ts
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.