Learn Prometheus

Pull-based metrics monitoring with a time-series database and PromQL

34 lessons · 7 hours · 4 levels · covers Prometheus 3.x

Prometheus collects numeric metrics by scraping HTTP endpoints, stores them as labelled time series and lets you query them with PromQL. It powers dashboards, alerting rules and capacity analysis, and is the standard metrics system in cloud-native and Kubernetes environments. Learning it means learning how to instrument services, write queries and alert on what matters.

Before you start

Prometheus builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics9 lessons · 1 hour in total
2. PracticalUse it productively at work, with the usual idioms20 lessons · 4 hours in total
3. AdvancedThe less common features, performance and trade-offs29 lessons · 6 hours in total
4. ExpertInternals and the edge cases experts know34 lessons · 7 hours in total

The Prometheus tree

PrometheusWhat Prometheus is and how it worksWhat Prometheus isand how it worksThe data model: metrics, labels and seriesThe data model:metrics, labels and…Counters, gauges, histograms and summariesCounters, gauges,histograms and su…Metric and label naming conventionsMetric and labelnaming conventionsCounters vs gauges in practiceCounters vs gaugesin practiceRunning Prometheus and scraping targetsRunning Prometheusand scraping targetsPromQL basics: selectors and vectorsPromQL basics:selectors and vectorsLabel matchers and selectors in depthLabel matchers andselectors in depthThe expression browser and HTTP APIThe expressionbrowser and HTTP…rate, irate and increase for countersrate, irate andincrease for countersAggregation and vector matchingAggregation andvector matchingoffset and @ modifiersoffset and @modifiersEveryday functions: absent, changes, predictEveryday functions:absent, changes, p…Scrape configuration and stalenessScrape configurationand stalenessExporters: node, blackbox and friendsExporters: node,blackbox and friendsHost and container metrics: node, cAdvisorHost and containermetrics: node, cAd…Instrumenting a Python appInstrumenting aPython appInstrumenting a Go serviceInstrumenting a GoservicePushgateway: batch jobs and when not to pushPushgateway: batchjobs and when not t…Securing Prometheus: TLS and basic authSecuringPrometheus: TLS a…
Essentials and Practical shown (20 of 34 lessons); the full list is below. Click a lesson to read it.

All 34 lessons, in order

Metrics basics

  1. What Prometheus is and how it works · Essentials · 6 min

    Prometheus scrapes metrics from targets over HTTP, stores them as time series and evaluates queries and alerts on them.

  2. The data model: metrics, labels and series · Essentials · 10 min

    A time series is a metric name plus a set of labels; each holds timestamped float samples. Learn naming and why labels matter.

  3. Counters, gauges, histograms and summaries · Essentials · 12 min

    The four metric types, what each is for, and why you almost never look at a counter's raw value.

  4. Metric and label naming conventions · Essentials · 8 min

    Name metrics with a domain prefix, base units and the right suffix (_total, _seconds, _bytes, _info) so queries stay predictable.

  5. Counters vs gauges in practice · Essentials · 10 min

    Why a counter's absolute value is meaningless, how resets look, when a gauge is the right choice, and which functions fit each.

Collecting metrics

  1. Running Prometheus and scraping targets · Essentials · 12 min

    Start Prometheus, write prometheus.yml with scrape_configs, and check target health with the up metric.

  2. Scrape configuration and staleness · Practical · 12 min

    Tune scrape_interval and scrape_timeout, understand honor_labels and honor_timestamps, limits, scrape protocols and how stale series disappear.

  3. Exporters: node, blackbox and friends · Practical · 10 min

    Monitor hosts, endpoints and third-party software with exporters such as node_exporter and blackbox_exporter.

  4. Host and container metrics: node, cAdvisor · Practical · 12 min

    Get CPU, memory, disk and network for hosts from node_exporter and for containers from cAdvisor, and write the standard queries for each.

  5. Pushgateway: batch jobs and when not to push · Practical · 9 min

    Push final metrics from short-lived jobs to the Pushgateway, scrape it with honor_labels, and understand why it is not a general push endpoint.

PromQL

  1. PromQL basics: selectors and vectors · Essentials · 12 min

    Select series with label matchers, tell instant vectors from range vectors, and use offset and comparisons.

  2. Label matchers and selectors in depth · Essentials · 9 min

    Combine matchers, match on __name__, test for missing labels, use anchored regexes safely and the 3.x quoted-name syntax.

  3. The expression browser and HTTP API · Essentials · 10 min

    Explore queries in the built-in UI, then call the same engine over HTTP with /api/v1/query and query_range.

  4. rate, irate and increase for counters · Practical · 12 min

    Turn ever-growing counters into per-second rates and increases, handle counter resets, and pick a sensible range.

  5. Aggregation and vector matching · Practical · 14 min

    Aggregate with sum, avg, max, count and topk by labels, and combine vectors with on, ignoring and group_left.

  6. offset and @ modifiers · Practical · 9 min

    Shift a selector back in time with offset, pin it to a fixed moment with @, and combine both for week-over-week comparisons.

  7. Everyday functions: absent, changes, predict · Practical · 14 min

    The functions you reach for daily beyond rate: absent, changes and resets, delta, deriv and predict_linear, label_replace, clamp and the *_over_time family.

  8. Subqueries · Advanced · 10 min

    Turn any instant-vector expression into a range vector with [range:resolution] so you can apply *_over_time functions to computed values.

  9. Latency percentiles with histogram_quantile · Advanced · 14 min

    Compute percentiles from histogram buckets, aggregate them correctly, and understand their error and the native histogram alternative.

Instrumenting applications

  1. Instrumenting a Python app · Practical · 14 min

    Add counters, gauges and histograms to an application with a client library and expose a /metrics endpoint.

  2. Instrumenting a Go service · Practical · 14 min

    Use client_golang with promauto and promhttp to expose /metrics, instrument HTTP handlers and register custom collectors.

  3. Native histograms · Expert · 15 min

    Enable native histograms, expose them from client libraries over protobuf, and query them with histogram_quantile, histogram_fraction and friends.

Operating at scale

  1. Securing Prometheus: TLS and basic auth · Practical · 11 min

    Serve the UI and API over TLS with basic auth via the web config file, scrape targets securely, and understand that Prometheus has no authorization layer.

  2. Storage internals: head, WAL and compaction · Expert · 14 min

    How the TSDB stores samples in memory and on disk, what the WAL protects, how compaction and retention work, and how to size it.

  3. Cardinality, federation, HA and remote write · Expert · 15 min

    Find and fix cardinality explosions, run HA pairs, and scale beyond one server with sharding, federation, agent mode and remote write to Thanos or Mimir.

  4. Prometheus 3.x: UTF-8 names and OTLP · Expert · 14 min

    What changed in 3.x: UTF-8 metric names, the OTLP receiver, left-open range selectors, strict scrape protocols and the upgrade path from 2.x.

Rules and alerting

  1. Recording rules · Advanced · 10 min

    Precompute expensive or frequently used queries into new series with recording rules, and name them by convention.

  2. Alerting rules · Advanced · 12 min

    Write alerting rules with for, labels and templated annotations, and design alerts on symptoms rather than causes.

  3. Alert annotations, templates and runbooks · Advanced · 12 min

    Write annotations with Go templates, humanize values, link runbooks and dashboards, and shape Alertmanager notification templates.

  4. Alertmanager: routing, grouping and silences · Advanced · 14 min

    Route alerts to the right receivers, group and deduplicate them, inhibit noise, and silence alerts during maintenance.

  5. Unit-testing rules with promtool · Advanced · 12 min

    Feed synthetic series into recording and alerting rules with promtool test rules, and assert on outputs, labels and annotations in CI.

  6. SLOs and multi-window burn-rate alerts · Expert · 16 min

    Define an SLO and error budget in PromQL, then page on burn rate over paired long and short windows instead of raw thresholds.

Discovery and Kubernetes

  1. Service discovery and relabeling · Advanced · 15 min

    Discover targets dynamically from Kubernetes, clouds or files, and rewrite target and metric labels with relabel_configs.

  2. kube-prometheus-stack and ServiceMonitors · Advanced · 15 min

    Install the Prometheus Operator stack with Helm and declare scrape targets as ServiceMonitor, PodMonitor and PrometheusRule objects.