Monitoring (Prometheus, Grafana) Tutorial
Learn Monitoring (Prometheus, Grafana) step by step: 27 lessons in 9 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Monitoring Fundamentals
- What Monitoring Is and Why It Matters Learn what monitoring and observability are, how metrics, logs and traces differ, why alert on symptoms, and where Prometheus and Grafana fit in.
- RED, USE and the Golden Signals Choose what to measure: the RED method, the USE method, the four golden signals, plus SLIs, SLOs and error budgets, with runnable examples.
Prometheus Basics
- How Prometheus Works Understand the Prometheus architecture: the pull model, scrape targets, exporters, the time series database, retention, service discovery and Alertmanager.
- Installing Prometheus and Your First Scrape Install Prometheus from a binary or Docker, write prometheus.yml with scrape_configs, open the web UI and Targets page, and read the up metric.
- Metrics, Labels and Time Series Learn the Prometheus data model: metric names, labels, samples, time series, cardinality, naming conventions and the text exposition format.
- Counters, Gauges, Histograms and Summaries Learn the four Prometheus metric types, when to use each, how counter resets and histogram buckets work, and how quantiles are estimated.
Instrumenting Applications
- Instrumenting Your Code Add Prometheus metrics to your own code with client libraries for Python, Go, Java and Node.js, expose /metrics, and avoid label and naming mistakes.
- Exporters: Node, Blackbox and Friends Monitor servers, containers, websites and databases you cannot modify with Prometheus exporters, use the textfile collector, and know when Pushgateway is wrong.
- Service Discovery and Relabeling Let Prometheus find its targets automatically with file_sd, DNS, Kubernetes and cloud discovery, then rewrite labels with relabel_configs and metric_relabel_configs.
PromQL
- PromQL Basics Learn PromQL from the ground up: instant and range vectors, label matchers, offset, subqueries, and how staleness and the lookback window decide results.
- rate, increase and Counter Math Understand how rate, irate and increase work on counters: resets, window size, extrapolation and the common mistakes that give wrong graphs and alerts.
- Aggregation, Joins and Vector Matching Combine time series in PromQL: sum, avg, topk and count with by and without, binary operators, on and ignoring, group_left joins, and absent().
- Quantiles, Histograms and SLI Queries Turn histogram buckets into latency percentiles with histogram_quantile, write error-rate and availability queries, and learn how accurate the estimates really are.
Recording Rules and Alerting
- Recording Rules and Query Performance Precompute expensive PromQL with recording rules: rule groups, the level:metric:operations naming scheme, when to use them and how to spot slow queries.
- Alerting Rules and Alertmanager Write Prometheus alert rules with for durations, labels and annotations, then route, group, inhibit and silence them with Alertmanager receivers.
Grafana
- Grafana: Data Sources and Dashboards Install Grafana, connect it to Prometheus, build panels with PromQL queries, add variables and time ranges, and provision everything from files.
- Designing Dashboards That Help Design Grafana dashboards people can act on: layout, RED and USE patterns, units and thresholds, templating, annotations, dashboards as code and common mistakes.
Production Practice
- Scaling, Retention and Long-Term Storage Size a Prometheus server, set retention, use federation and remote write, run HA pairs and compare Thanos, Mimir and VictoriaMetrics for long-term storage.
- Monitoring Kubernetes and Containers Monitor a Kubernetes cluster with Prometheus: kube-state-metrics, cAdvisor, pod discovery, ServiceMonitor and the Prometheus Operator, plus resource queries.
- Security, Cardinality and Common Pitfalls Secure Prometheus endpoints with TLS and auth, keep /metrics private, avoid label explosions and alert fatigue, and test rules with promtool before production.
Projects
- Project: Instrument a Web Service and Build Its Dashboard Add request rate, error and duration metrics to a web service, scrape it with Prometheus, write the PromQL and Grafana panels, and track an availability SLO.
- Project: Alerts with Burn Rates and Routing Build SLO alerts that page only when the error budget burns fast: multi-window burn-rate rules, severity routing in Alertmanager and runbook annotations.
- Project: Monitor a Fleet of Servers Monitor a fleet of Linux servers: install node_exporter, discover hosts with file_sd, write host queries, predict full disks with predict_linear and build a dashboard.
- Project: A Complete Monitoring Stack with Docker Compose Run Prometheus, Grafana, Alertmanager, node_exporter and cAdvisor with Docker Compose, provision the data source and dashboards as files, and validate it all.
Practice and Review
- Exercises with Solutions Twelve graded Prometheus exercises on PromQL, instrumentation, alert rules and relabeling, each with a worked answer and runnable stand-ins for the math.
- Interview Questions Prepare for monitoring interviews with short model answers on Prometheus concepts, PromQL, alerting, architecture, scaling and Grafana, plus runnable stand-ins.
- Prometheus and Grafana Cheat Sheet One-page Prometheus and Grafana cheat sheet: config snippets, metric types, label matchers, common PromQL, recording and alert rules, burn rates and promtool commands.