All Modules Why Monitor Health Checks Logs & Metrics Alerts عربي

Monitoring & Observability

Make the app tell you when it's healthy — and shout when it's not.

Module 11 · Health checks, logs, metrics, and alerts.

Advanced Observability Includes Lab ~50 min

What You'll Learn

  • Why "it deployed" isn't "it's working" — and how observability closes that gap
  • Add a health check endpoint so uptime tools can watch the app
  • Emit structured logs you can actually search
  • Expose metrics and visualize them (Prometheus + Grafana)
  • Set an alert so a problem finds you, not the other way around
  • Hands-on lab: instrument the vault with health, logs, and a metric

Prerequisites: Module 10 (a deployed vault). Deep dive: DevOps Lab: Monitoring & Logging.

Deployed ≠ Working

Your app is live — but is it up right now? Serving errors? Slow? Out of memory? Without observability, you find out when a user complains. That's the last of the six failure modes, at production scale: silent breakage nobody sees.

PillarAnswers
LogsWhat happened? (a searchable record of events)
MetricsHow much / how fast? (numbers over time: requests, errors, latency)
Health checksIs it up right now? (a simple yes/no endpoint)
AlertsShould a human care now? (automatic notifications)

Health Checks

The simplest, highest-value observability: a /health endpoint that returns OK when the app can serve requests. Uptime monitors and orchestrators ping it constantly — if it stops answering, they know instantly.

GET /health → 200 { "status": "ok", "uptime": 3812 }

Free uptime alerting

Point a free uptime service at /health and you'll get an email/SMS within a minute of your app going down — before most of your users even notice.

Logs & Metrics

Structured logs

Log as structured data (JSON), not random strings, so you can search and filter. Include request, status, and duration — and never log secrets or full personal data.

{ "level":"info", "method":"POST", "path":"/snippets", "status":201, "ms":14 }

Metrics with Prometheus + Grafana

Expose a /metrics endpoint of counters and timings; Prometheus scrapes it, Grafana graphs it. Request rate, error rate, and latency (the "RED" metrics) tell you the app's health at a glance.

The DevOps Lab has the full stack

The DevOps Lab Monitoring module ships a working Prometheus + Grafana setup and a dashboard JSON. Reuse it against the vault rather than wiring monitoring from scratch.

Alerts: Let Problems Find You

Dashboards only help if someone's looking. Alerts flip that: define a rule ("error rate > 5% for 5 minutes", "/health down") and get notified automatically. Good alerts are few, meaningful, and actionable — alert fatigue is real.

Alert on symptoms, not noise

Page a human for "users can't create snippets," not "CPU hit 70% for a second." Every alert should mean "a person needs to act." The rest belongs on a dashboard.

Practical Lab: Instrument the Vault

You'll add a health check, structured request logging, and at least one metric — then watch your own app report on itself.

What you need

Your deployed snippet-vault from Module 10.

1

Branch and add /health

git checkout -b feature/observability

Add a GET /health endpoint returning status and uptime. Add a test for it. Review, commit.

2

Add structured request logging

Add JSON request logging (method, path, status, duration) to the API. Never log request bodies, secrets, or personal data. Keep it lightweight.

Review the diff — confirm nothing sensitive is logged.

3

Expose a metric

Add a /metrics endpoint (Prometheus format) with at least a request counter. If you want the full picture, wire in the DevOps Lab's Prometheus + Grafana against it.

4

Watch it report

Hit the app a few times, then check /health, your logs, and /metrics. Point a free uptime monitor at /health for real alerting.

5

Merge and reflect

git add . git commit -m "Add health check, structured logs, and metrics" git checkout main && git merge feature/observability

In REFLECTION.md: what's the first thing you'd want an alert for, and why? Commit.

What to hand in

Your snippet-vault repo. Self-check:

  • /health returns status; it has a test
  • Requests are logged as structured data, with no secrets
  • A /metrics endpoint exposes at least one metric
  • REFLECTION.md names your first alert

Mini Glossary

TermPlain meaning
ObservabilityBeing able to understand what your running app is doing from outside.
Health checkAn endpoint that says whether the app is up.
Structured logA log entry as data (JSON) you can search and filter.
MetricA number tracked over time (requests, errors, latency).
AlertAn automatic notification when a rule is breached.

Recap & What's Next

You now have

A deployed app that reports its own health, logs what it does, exposes metrics, and can alert you when something's wrong. That's the full DevOps loop — and the last of the six failure modes, closed.

Next up: Module 12 — Capstone: Idea → Shipped. You'll take a brand-new idea through this entire lifecycle on your own — the portfolio piece that proves you can vibe-code and ship like a professional.

Monitoring & Observability

Objectives Why Monitor Health Checks Logs & Metrics Alerts Practical Lab Glossary Recap