← Course Index

Uptime Monitoring & Alerting

~20 min · Monitoring

Ref
Primary Source
Better Stack — Uptime Monitoring Guide

Practical guide to setting up uptime monitoring with realistic alerting thresholds. Read →

Why Uptime Monitoring?

Sentry catches errors in running code. Uptime monitoring catches when your app stops running entirely. A monitor pings your /health endpoint every 30–60 seconds. If it doesn't respond, you get alerted. You know before your users do.

The /health Endpoint

app.get('/health', async (req, res) => {
  const health = { status: 'healthy', uptime: process.uptime() };
  try {
    await db.query('SELECT 1');
    health.database = 'ok';
  } catch {
    health.database = 'down';
    health.status = 'degraded';
  }
  try {
    await redis.ping();
    health.redis = 'ok';
  } catch {
    health.redis = 'down';
    health.status = 'degraded';
  }
  res.status(health.status === 'healthy' ? 200 : 503).json(health);
});

Free Uptime Tools

ToolFree tierBest for
UptimeRobot50 monitors, 5-min checksGetting started
Better Stack10 monitors, 3-min checksStartups — great integrations
Freshping50 monitors, 1-min checksFastest free checks

Alerting Best Practices

Incident Response

  1. Acknowledge — confirm someone is looking
  2. Assessdocker compose ps, docker compose logs -f api
  3. Mitigate — restart service or rollback deploy
  4. Communicate — update status page
  5. Postmortem — write what happened, why, prevention
💡

Write a runbook before you need it: "if alert X fires, do steps 1-5." At 3am you want a checklist, not a problem-solving session.

Check Your Understanding

1. /health returns 200 but doesn't check the database. What problem does this cause?
2. You get 3 false alarm alerts weekly because your server hiccups for 30 seconds. Fix?
3. Your SSL cert expired. A user found out and emailed you. What monitoring would have prevented this?