Monitoring
Track system health with metrics, dashboards, and tools like Prometheus and Grafana.
What you'll learn
- Why monitoring is critical for DevOps
- Metrics, logs, and traces — the three pillars
- Tools: Prometheus, Grafana, and Datadog
- Building effective dashboards
Concept
Why Monitor?
Monitoring is the eyes and ears of your production system. Without it, you are flying blind — you won't know about problems until users complain, and you'll have no data to diagnose them. Good monitoring tells you what is happening right now, alerts you when something goes wrong, and provides historical data to understand trends and plan capacity. In DevOps, monitoring is not optional — it is a core practice that enables fast, safe deployments.
The Three Pillars
Observability rests on three pillars. Metrics are numeric measurements sampled over time — CPU usage, request latency, error rate. Logs are timestamped records of discrete events — a user logged in, a payment failed, a connection was refused. Traces follow a single request through all the services it touches, showing you where time is spent and where errors occur. Together, they give you a complete picture of system behavior.
Tools
Prometheus is an open-source metrics database that scrapes metrics from your applications. Grafana is a visualization tool that creates dashboards from Prometheus and many other data sources. Datadog is a commercial all-in-one platform. Jaeger and Zipkin handle distributed tracing. The ELK stack (Elasticsearch, Logstash, Kibana) is popular for log management. Most teams use a combination of these tools.
Effective Dashboards
A good dashboard answers a specific question: "Is the checkout working?" or "Are we meeting our latency SLO?" Start with high-level service health, then drill down to details. Use golden signals: latency, traffic, errors, and saturation. Avoid dashboard overload — too many panels make it hard to find what matters. Color-code consistently: green for healthy, red for problems. Make dashboards that a tired on-call engineer can understand at 3 AM.
Synthetic Monitoring
Beyond real-user metrics, synthetic monitoring runs scripted checks against your service from external locations. A synthetic check simulates a user journey — log in, add to cart, checkout — and alerts if any step fails. This catches issues before real users are affected, even during low-traffic periods. Combine synthetic checks with real-user monitoring for comprehensive coverage: synthetics for early detection, real-user data for understanding actual impact and performance across different geographies and device types.
Example
# Prometheus scrape configuration
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'myapp'
static_configs:
- targets: ['app:9090']
metrics_path: /metrics
- job_name: 'node-exporter'
static_configs:
- targets: ['node-exporter:9100']
# Key metrics to track:
# http_requests_total - request count by route/code
# http_request_duration_seconds - latency histogram
# process_resident_memory_bytes - memory usage
# node_cpu_seconds_total - CPU usage
Prometheus scrapes metrics from your applications at regular intervals. The config defines which targets to scrape and how often. Grafana then visualizes this data.
Try it
- HTTP Status Codes
Reference for monitoring HTTP error rates.
- Cron Parser
Parse monitoring schedule expressions.
- Timestamp Converter
Convert metric timestamps for analysis.
Common mistakes
The mistake
Monitoring everything but alerting on nothing
The fix
Collecting metrics is useless if nobody looks at them. Define alerting rules for the metrics that matter — error rate, latency, saturation. A dashboard nobody checks is wasted effort.
The mistake
Alerting on symptoms instead of causes
The fix
Alert on user-facing symptoms (error rate, latency) rather than underlying causes (CPU at 80%). Symptom-based alerts are more stable and directly indicate user impact.
Practice Monitoring
2 exercises
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.