Incidents.FailHeartbeat
Report an explicit failure on an Heartbeat (<url>/fail), so an
incident opens right away instead of after the missed period plus grace.
Notifies. Opening the incident notifies whoever the heartbeat’s alert
settings (call, sms, email, push, criticalAlert) and escalation
policy name — use it for failures a person should hear about.
Credential. The host receives only the heartbeat’s secret url
(Redacted, BETTERSTACK_HEARTBEAT_<HEARTBEAT>_URL): no API token, and
it can only report on that one heartbeat.
Provide FailHeartbeatHttp on the host’s implementation; to also
send the exit code and output, use ReportHeartbeat.
Failing a job explicitly
Section titled “Failing a job explicitly”Fail the heartbeat when the backup finds no data
export default class Backup extends BetterStack.Cloud.Service<Backup>()( "Backup", { server: Box, main: import.meta.url }, Effect.gen(function* () { const fail = yield* BetterStack.Incidents.FailHeartbeat(BackupDone); const inHost = yield* BetterStack.withHostRuntime; const host = yield* ServerHost; yield* host.run(inHost(fail().pipe(Effect.ignore))); }).pipe(Effect.provide(BetterStack.Incidents.FailHeartbeatHttp)),) {}Works the same on any Alchemy host (Worker, Lambda, container).