Lesson 7 of 9 · 26m
Monitoring, Logging, and Alerting That Tell the Truth
Collect useful health signals, centralize logs without hoarding noise, and alert only on conditions that require human action.
Monitoring fails in two directions. The first is no monitoring, where you discover the NAS died because family photos stopped loading. The second is surveillance maximalism, where every metric exists and nobody trusts any alert. Serious operations means answering three questions quickly: is it working, is it degrading, and what changed?
Start with user-visible checks
Internal metrics are useful, but begin with the service contract. A reverse proxy can be healthy while every upstream is broken. Use black-box checks for public services:
scrape_configs:
- job_name: blackbox-http
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- https://files.example.net/healthz
- https://photos.example.net/login
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: blackbox.lab.internal:9115Now the graph tells you what users experience, not merely what the process claims.
Metrics worth collecting first
Do not start with a thousand dashboards. Start with the failure indicators that repeatedly matter:
node: CPU steal/pressure, memory pressure, disk usage, disk latency, network errors
zfs: pool health, scrub age, checksum errors, free space
ups: input power, battery runtime, load, last transfer reason
hypervisor: VM state, host temperature, storage latency
services: HTTP status, latency, certificate expiry, backup job ageCertificate expiry is one of the highest-value alerts in a lab because the failure is certain, timed, and preventable.
Logs are evidence, not ambient noise
Centralize logs for systems you will need during incidents: firewall, reverse proxy, authentication, hypervisor, and core services. Journald can forward or be queried locally; for small labs, even structured journal retention plus remote syslog is enough:
# /etc/systemd/journald.conf
Storage=persistent
SystemMaxUse=2G
MaxRetentionSec=2monthDo not log secrets, session tokens, full authorization headers, or personal document contents. A log pipeline is sensitive infrastructure. Restrict access and retention deliberately.
Alerts must encode action
A good alert answers: who is affected, what is broken, how urgent is it, and what should the operator do first?
- alert: BackupTooOld
expr: time() - backup_last_success_timestamp_seconds > 36 * 3600
for: 15m
labels:
severity: warning
annotations:
summary: "Backup job has not succeeded in over 36 hours"
runbook: "Check restic repository reachability, credentials, and host disk space."If the correct response is "ignore it," tune or delete the alert. Alert fatigue is not a personal weakness; it is a system defect.
Dashboards tell stories, not numbers
A useful service dashboard has four layers: availability, latency, errors, and saturation. Add deployment markers or annotations when possible because "what changed?" is often the real question. Resist vanity graphs. A beautiful dashboard that cannot distinguish a dead service from a dead exporter is decoration.
Monitor the monitoring
Your monitoring stack needs independent health evidence. If Prometheus runs on the cluster it monitors, send a heartbeat to an external service or at least to a separate low-power host. Otherwise the failure mode is silence exactly when everything is down.
Field notes
- Time sync matters before log correlation. A five-minute clock skew can make causality impossible to reconstruct.
- Alert on symptoms for users and causes only when they are actionable. Disk space trending toward full is actionable; a momentary CPU spike often is not.
- Keep one static status or incident note path that does not depend on the full application stack.
- Retention is a tradeoff. Enough history to see weekly patterns is usually more useful than a year of data you cannot search.
Was this lesson helpful?