Module 02: Metrics and Prometheus¶
← Module 01: Introduction | Topic Home | Next → Module 03: Dashboards and Grafana
Stub module — Content to be generated. See the topic README for the full module map.
Table of Contents¶
Overview¶
This module covers the Prometheus metrics ecosystem in depth: the four metric types (counter, gauge, histogram, summary), the Prometheus data model with labels, PromQL query language basics, the exporter ecosystem for instrumenting third-party systems, and recording rules for query performance optimization.
By the end of this module, you will be able to instrument any Python or Node.js application with Prometheus metrics, write PromQL queries to compute rates, percentiles, and error budgets, and configure a Prometheus server to scrape and store your metrics.
Difficulty: Beginner–Intermediate | Estimated time: 6 hours
Prerequisites¶
- Module 01: Introduction to Observability — specifically: understanding what metrics are and why they're needed
- Basic Python or JavaScript programming
- Familiarity with HTTP (you should be able to explain what a GET request is)
Objectives¶
By the end of this module, you will be able to:
- Explain the four Prometheus metric types (counter, gauge, histogram, summary) and choose the correct type for a given measurement
- Instrument a Python or JavaScript application using the
prometheus_clientorprom-clientSDK - Write PromQL queries using
rate(),sum(),histogram_quantile(), and label selectors - Configure a
prometheus.ymlscrape config to collect metrics from your application - Explain the Prometheus pull-based collection model and why it differs from push-based systems
- Use recording rules to pre-compute expensive queries for dashboard performance
Theory¶
[!NOTE] This module is a stub. Full theory content will be generated when this module is expanded. The following outline describes what the theory section will cover.
Planned Sections¶
- The Prometheus Data Model — time series, labels, the pull-based scrape model, metric naming conventions
- Counter — monotonically increasing;
rate()function; when to use; common mistakes (using counter for decreasing values) - Gauge — current state;
set(),inc(),dec(); use cases (queue depth, memory usage, active connections) - Histogram — value distribution; buckets;
histogram_quantile(); choosing bucket boundaries - Summary — pre-computed quantiles; when to use vs. histogram; limitations
- PromQL Language — selectors, matchers, rate(), increase(), functions, aggregation operators
- The Exporter Ecosystem — node_exporter, blackbox_exporter, postgres_exporter, redis_exporter
- Recording Rules — pre-computing expensive queries; performance optimization
Key Concepts¶
To be filled in when module is fully generated.
Examples¶
To be filled in when module is fully generated.
Common Pitfalls¶
To be filled in when module is fully generated.
Cross-Links¶
- [[feature-flags-monitoring/modules/01_introduction]] — Introduces the metrics pillar; this module expands on it in depth
- [[feature-flags-monitoring/modules/03_dashboards-and-grafana]] — Grafana queries Prometheus using the PromQL learned in this module
- [[devops-platform-engineering]] — Kubernetes environments typically use kube-state-metrics and node_exporter alongside application metrics
Summary¶
To be filled in when module is fully generated.
Further Reading¶
- Prometheus Documentation — Complete reference
- PromQL Cheat Sheet — Quick reference for PromQL operators
- Prometheus: Up & Running — [Verify: O'Reilly book by Brian Brazil — confirm availability]