With your consent, Google Analytics and Cloudflare Web Analytics count visits and how pages are used. Google Analytics sets cookies; the data goes to Google and Cloudflare in the United States. No advertising. Say no and neither is loaded. You can change this at any time in Cookie settings. Cookie Policy

SLO burn-rate alerts for an Express API

Alert when your API is spending its error budget too fast, not on every spike: the multi-window rules from the Google SRE Workbook, for an Express app, without running Prometheus.

Author
Buğra Ömer Aydemir
Updated
15 October 2026
Product

In short

  • An SLO of 99.9% leaves an error budget of 0.1% of requests. The burn rate is how fast you spend it: 1 spends it exactly over the SLO period.
  • Page when the budget burns at 14.4x over 1 hour, or 6x over 6 hours; open a ticket at 1x over 3 days. Each rule also needs a short window (5 minutes, 30 minutes, 6 hours) above the same rate, so the alert stops soon after the problem does.
  • Monitoring Tool applies these rules to an Express API after npm install @carchalabs/monitoring and one middleware line.

Error budget and burn rate

A service level objective (SLO) says what share of requests must be good, for example 99.9% of requests answer without a server error. What is left, 0.1%, is the error budget: the failures you can afford over the SLO period.

The burn rate is the share of bad requests divided by the budget. With a 99.9% objective, 1.44% of requests failing is a burn rate of 14.4: at that pace a 30-day budget is gone in about two days. Alerting on the burn rate instead of a fixed error percentage ties the alert to how much of your objective is at risk.

Multi-window, multi-burn-rate alerts

The Google SRE Workbook recommends three rules for a 30-day SLO. Each one fires only when both its long window and its short window burn at or above the rate; the short window makes the alert stop shortly after the problem ends.

SeverityLong windowShort windowBurn rateBudget spent when it fires
Page1 hour5 minutes14.42%
Page6 hours30 minutes65%
Ticket3 days6 hours110%

A fast, severe outage trips the 1-hour rule within minutes; a slow leak that would still exhaust the budget trips the 3-day rule and becomes a ticket rather than a page at night.

Set it up for Express

Create an application and an ingest token in the Monitoring dashboard, then add the middleware before your routes. It needs Node.js 22 or later and has no runtime dependencies. Routes come from Express, so /orders/1 and /orders/2 count as one endpoint, /orders/:id.

npm install @carchalabs/monitoring

// app.js
import express from 'express';
import { createMonitor } from '@carchalabs/monitoring';

const monitor = createMonitor({ token: process.env.CARCHALABS_MONITORING_TOKEN });
const app = express();
app.use(monitor.express());          // before your routes

app.get('/orders/:id', (req, res) => res.json({ id: req.params.id }));

const server = app.listen(3000);
process.on('SIGTERM', async () => {
  server.close();
  await monitor.shutdown();          // sends what is still queued
});

Records are sent in the background in batches of up to 100; the middleware never waits for the network. Response bodies are never sent, and authorization, cookie and token headers are replaced by [redacted] before they leave your server.

Create the SLO rule

In the dashboard, add an alert rule for the application, a route or all routes:

  • SLO availability: bad requests are those answered with a 5xx status. Set the objective between 90% and 99.99%.
  • SLO latency: bad requests are those slower than the latency you set, for example 300 ms.

The rule evaluates the three windows above every minute and fires at the most severe one that matches. It waits for at least 100 requests in the long window by default, so a quiet endpoint does not page on two failures. Threshold rules for latency and error rate, and a no-traffic rule, are there for the cases an SLO does not cover.

Verify the alert webhook

Alerts go by email or to a webhook. A webhook request carries X-LogBadger-Signature: sha256=<hex>, the HMAC-SHA256 of the raw body with the rule's secret. Check it on the raw bytes before parsing, and compare in constant time:

import crypto from 'node:crypto';
import express from 'express';

const app = express();
const secret = process.env.MONITORING_WEBHOOK_SECRET;   // the alert rule's secret

app.post('/hooks/monitoring', express.raw({ type: 'application/json' }), (req, res) => {
  const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(req.body).digest('hex');
  const given = req.get('X-LogBadger-Signature') ?? '';
  const ok = given.length === expected.length && crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected));
  if (!ok) return res.sendStatus(401);

  const alert = JSON.parse(req.body);   // event_id, state, severity, message, rule, application, details, created_at
  console.log(alert.state, alert.severity, alert.message);
  res.sendStatus(204);
});

Try it

The read-only demo shows a dashboard with sample traffic and alert rules, without an account. The product page lists what Monitoring Tool does and where it stops.

Sources