Skip to content
betterstack-alchemyUnofficial

Escalation policies

An EscalationPolicy decides who is notified about an incident, in what order, and how long Better Stack waits between steps. Monitors, heartbeats and incoming integrations use a policy through their escalationPolicyId.

Escalation policies need a paid plan: on a plan without them every create fails with a typed Forbidden. The live test is gated for that reason; see Compatibility.

checkoutmonitor
on-callescalation policy
step 1 · after 0 scurrent_on_call · High
step 2 · after 600 sentire_team · High
Primary on-callon-call schedule
  • checkoutescalates via →on-call
  • on-callsteps page →Primary on-call
A failing monitor hands its incident to the policy. Step 1 pages whoever the schedule has on call; if nobody acknowledges within 10 minutes, step 2 pages the whole team.

steps is an ordered list. An escalation step notifies its stepMembers with the alert channels of its severity, after waitBefore seconds:

alchemy.run.ts
const schedule = yield* BetterStack.Incidents.OnCallSchedule("primary", {
name: "Primary on-call",
});
const high = yield* BetterStack.Incidents.Severity("high", {
name: "High",
call: true,
push: true,
});
const onCall = yield* BetterStack.Incidents.EscalationPolicy("on-call", {
name: "On-call, then the whole team",
repeatCount: 3,
repeatDelay: 300,
steps: [
{
type: "escalation",
waitBefore: 0,
severityId: high.id,
stepMembers: [{ type: "current_on_call", id: schedule.id }],
},
{
type: "escalation",
waitBefore: 600,
severityId: high.id,
stepMembers: [{ type: "entire_team" }],
},
],
});

A step member is current_on_call (with an on-call schedule’s id), entire_team, a user, another policy, or an integration. Other step types act only in a time window (time_branching), only for matching incident metadata (metadata_branching), post a note into the incident timeline (instructions), or resolve, remove or hand over the incident (resolve_remove).

alchemy.run.ts
yield* BetterStack.Incidents.Monitor("checkout", {
url: "https://checkout.example.com/health",
monitorType: "status",
escalationPolicyId: onCall.id,
});

An EscalationPolicyGroup keeps related policies together:

alchemy.run.ts
const payments = yield* BetterStack.Incidents.EscalationPolicyGroup("payments", {
name: "Payments",
});
yield* BetterStack.Incidents.EscalationPolicy("payments-on-call", {
name: "Payments on-call",
escalationPolicyGroupId: payments.id,
steps: [{ type: "escalation", waitBefore: 0, stepMembers: [{ type: "current_on_call" }] }],
});

Every prop updates in place; teamId replaces the policy. steps sent on update replaces every step, and removing steps from the config keeps the current ones. A severity a step uses can’t be deleted while the step uses it, so Alchemy deletes the policy first when it references severity.id.