Incidents.ReportHeartbeat
Report a job’s result on an Heartbeat with its exit code and
output (<url>/<exit code>), like curl -d "$output" "$URL/$?" at the end
of a cron script. Exit code 0 counts as a ping; any other exit code opens
an incident at once, with the output attached to it.
Notifies. A non-zero exit code opens an incident and notifies whoever the heartbeat’s alert settings and escalation policy name.
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 ReportHeartbeatHttp on the host’s implementation. The
heartbeatJob helper wraps a whole job with it.
Reporting a job’s exit code
Section titled “Reporting a job’s exit code”Report the result of a nightly job
export default class Nightly extends BetterStack.Cloud.Service<Nightly>()( "Nightly", { server: Box, main: import.meta.url }, Effect.gen(function* () { const report = yield* BetterStack.Incidents.ReportHeartbeat(NightlyDone); const inHost = yield* BetterStack.withHostRuntime; const host = yield* ServerHost; yield* host.run(inHost(report(0, "42 rows exported").pipe(Effect.ignore))); }).pipe(Effect.provide(BetterStack.Incidents.ReportHeartbeatHttp)),) {}Works the same on any Alchemy host (Worker, Lambda, container).