ArticleOperations

Monitoring without being woken for nothing

An alert that fires too often ends up ignored, and an ignored alert is worthless. How to choose what to watch, what deserves to wake somebody, and what can wait until Monday.

6 min readBy Valentin Flückiger

There are two ways to get monitoring wrong.

The first is to monitor nothing: you learn about outages from users, often long after. The second is to monitor too much: alerts everywhere, most requiring no action, which you end up ignoring reflexively. The second is more dangerous than the first, because it gives the illusion of being covered.

The rule that decides everything

Before adding an alert, one question:

If this alert fires at three in the morning, must somebody get up and do something?

If the answer is no, it is not an alert. It is a metric to look at on a dashboard, or a line in a weekly report. Both are useful; neither wakes anyone.

Applying that rule seriously eliminates the large majority of alerts people configure by default.

The four levels worth watching

1. Does it respond?

The most basic level, and the most important. An HTTP request from outside, checking a response code.

From outside is the essential part. A system monitoring itself will not report its own outage: if the machine is off, the monitoring agent running on it is off too. You need an independent vantage point, hosted elsewhere.

2. Does it respond correctly?

A 200 does not mean the service works. An application error page sometimes returns 200. So does an empty page.

Hence a health endpoint that actually checks dependencies:

{
  "status": "ok",
  "database": "ok",
  "uptime": 48213
}

And on the monitoring side, you check not only the HTTP code but the content: if database is not ok, it is an outage, even though the page responded.

One caution: a health endpoint that tests too much becomes a source of false alerts itself. Check what the service needs in order to work, not everything it touches.

3. Will it keep responding?

These are the alerts that warn before the outage. The most profitable:

  • Disk space. A full disk breaks everything at once: the database cannot write, neither can the logs, backups produce empty files. Alert at 80%, not 98%.
  • Certificate expiry. Alert thirty days ahead. Automatic renewal sometimes fails silently.
  • Domain expiry. Rare, catastrophic, trivial to watch.
  • Available memory, if the application tends to leak.

These alerts have a valuable quality: they fire during working hours, because they warn well in advance.

4. Are the background jobs running?

This is the most frequently forgotten point, and it deserves detail.

A backup that fails loudly, you see. A backup that stops running altogether produces no message at all. Silence is indistinguishable from normal operation.

The fix is to invert the logic: instead of waiting for a failure signal, wait for a success signal, and alert on its absence. The job reports its success to an external service, which alerts if the signal does not arrive within the expected window.

#!/bin/bash
set -euo pipefail   # fail loudly, not silently

sqlite3 /app/data/app.db ".backup '/backups/app-$(date +%F).db'"
tar czf "/backups/uploads-$(date +%F).tar.gz" -C /app public/uploads

# Report success. If this line is never reached,
# the monitoring service alerts on its own.
curl -fsS --retry 3 https://monitoring.example/ping/daily-backup

The set -euo pipefail matters: without it, a shell script carries on after a failed command and may well reach the final curl having achieved nothing.

What not to alert on

High CPU usage. A server doing work uses its processor. That is the point. Alert on consequences — response time, queue depth — not on raw usage.

Every individual 500. A bot probing non-existent URLs, a client sending a malformed request: it happens. Alert on an abnormal error rate over a window, not on each occurrence.

Short spikes. Require a condition to persist a few minutes before alerting. Many problems resolve themselves in less time than it takes to read about them.

Anything requiring no action. If the response to an alert is "oh, okay", it was not an alert.

Alert fatigue

This is the real risk, and it is measurable.

When an alert fires often without requiring action, the brain learns to ignore it. That is not a lack of discipline, it is normal functioning. The problem is that the learning does not discriminate: the day that alert signals a real incident, it is ignored like the others.

Two simple indicators:

  • What proportion of alerts led to an action? Below half, the configuration is too noisy.
  • Is there an alert the team closes without reading? It must be removed or fixed, not tolerated.

Deleting a useless alert improves monitoring. It is not giving up, it is maintenance.

Logs, metrics, traces

Three different things, often conflated.

Logs tell you what happened, event by event. Indispensable for understanding an incident afterwards. Remember rotation — unbounded logs eventually fill the disk, and you will have created the outage you were monitoring for.

Metrics are numbers over time: response time, request count, error rate. These are what you alert on, because they have thresholds.

Traces follow a request across several components. Very useful in a distributed architecture, often superfluous for a single application.

For a modest site or application, well-written logs and three or four metrics are plenty. Start there.

What must never enter a log

A reminder, because it is a frequent mistake with lasting consequences:

  • No passwords, not even failed ones — a typo in a password field is often a valid password for another service.
  • No session tokens or API keys.
  • No plain IP addresses if you do not need them: a keyed hash is enough to count and rate-limit, without retaining personal data in clear.
  • No message contents.

Logs get copied, archived, and sometimes shared during a diagnosis. What you write into them is far more durable than you think.

What to do when the alert fires

An alert with no procedure behind it is just a source of stress. Every alert should point at a written response, however short, saying three things: what it means, how to check, what to do.

ALERT: disk > 80% on web-server-01

What it means
  The disk is filling up. At 100%, the database cannot write
  and the site returns errors.

How to check
  df -h                              # which partition
  du -xh / --max-depth=2 | sort -rh | head -20   # what is using space

Usual causes, by frequency
  1. Unrotated logs        -> check /var/log, logrotate
  2. Local backups         -> check retention
  3. Normal growth         -> grow the volume

Do NOT
  Delete files under /var/lib without knowing what they are.

Ten lines, written once, read at three in the morning by someone tired — possibly you in six months, with no memory of having configured this alert.

After the incident

The most neglected part, and the one with the most long-term value.

When an incident is resolved, write three paragraphs while it is fresh: what happened, why, and what changes. Not a formal report — three paragraphs.

Two principles:

Look for the cause, not the culprit. "Someone made a mistake" is never a root cause. The useful question is: what allowed that mistake to reach production undetected? A system where one human error causes a major outage is a system to fix, not a person to blame.

Every corrective action must be verifiable. "We'll be more careful" is not an action. "An alert fires if the backup has not reported success by 4am" is one, and you can check it exists.

And the most useful question of all: how could we have detected this sooner? That is usually what produces the best next alert.

A minimal setup that holds

For a site or application of modest size:

  1. An external check every minute, against a health endpoint that tests the database.
  2. A disk space alert at 80%.
  3. A certificate alert thirty days before expiry.
  4. A heartbeat from backups, alerting on absence.
  5. An alert on abnormal error rate, with five minutes of persistence.
  6. One channel where these arrive, which you actually read.

Six things. Not twenty dashboards. And each, if it fires, requires an action — which is exactly the criterion we started from.

What to take away

Monitor from outside, because a system does not report its own outage. Alert on symptoms the user feels, not on possible causes. Watch for the absence of a signal as much as the presence of an error. And delete without regret any alert that never requires action: every ignored alert makes all the others slightly less credible.

Tags

  • Linux
  • Hosting
  • Automation
  • Security