Skip to content

Alert Triage (local)

The alert-triage example is the capstone (L5) of the getting-started golden example. It is a Temporal-driven incident-triage app: an alert comes in, a phased workflow classifies it, gathers context, proposes a remediation, pauses for human approval when the change is risky, applies it (a clearly-stubbed step), then notifies. chant synthesizes the Kubernetes manifests; the triage workflow itself is hand-written Temporal — the “Raw Temporal + chant” split.

This tutorial runs the whole thing locally with no cloud and no cluster — just a Temporal dev server.

  • Node.js and npm.
  • The Temporal CLI (temporal) for the dev server.
Terminal window
cd examples/alert-triage
npm install
npm run dev

npm run dev starts a Temporal dev server, the triage worker, and the webhook receiver, then sends one demo alert. Open the Temporal UI at http://localhost:8233 — you’ll see an alertTriage workflow. The demo alert is high-severity, so it’s risky and pauses at the approval gate.

Approve it:

Terminal window
temporal workflow signal -n default \
--query "WorkflowType='alertTriage'" --name approve-remediation

The workflow completes, and the worker logs the outcome (… — applied after approval). A low-severity alert skips the gate and applies directly.

Both feed the same triage workflow:

Terminal window
npm run alert # external alert via the webhook (POST /alert)
npm run drift -- --demo # a drift event (the WatchOp/lifecycle counterpart)

The webhook is the receiver the WebApp manifest deploys. The drift source runs chant lifecycle plan --json and triages each drifted resource — out-of-band cluster changes go through the same triage as external alerts. --demo injects a sample drift so you can see the pipeline without making a real change.

proposeRemediation is a deterministic stub by default — no key, runs offline. Set ANTHROPIC_API_KEY (and npm i @anthropic-ai/sdk) to have it call Claude; override the model with ANTHROPIC_MODEL (default claude-sonnet-4-6). The first run shows chant, not an LLM.

The app’s Kubernetes surface is typed chant in src/:

Terminal window
npm run build # → k8s.yaml (plain Kubernetes)
npm run lint
kubectl apply -f k8s.yaml # e.g. to a local k3d cluster
PieceWhat it is
src/chant manifests — webhook (WebApp) and worker (WorkerPool)
activities/triage.tsthe triage activities (the agent — stub + Claude opt-in)
activities/workflow.tsthe Temporal workflow (classify → context → propose → gate → apply → notify)
activities/worker.tsthe worker that registers them
app/the event sources (webhook, drift) and the demo alert

A time-skipping test (activities/workflow.test.ts) covers the gate behaviour in CI. See the example README for the full layout.