Prometheus & Monitoring

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Prometheus is an open-source, metrics-based monitoring and alerting toolkit: it pulls numeric time series from instrumented targets on a schedule, stores them in its own local time-series database, evaluates PromQL expressions against that data for dashboards and alerting rules, and hands firing alerts to the Alertmanager for deduplication, grouping and routing. That pull model, and its focus on numeric metrics rather than logs, distributed traces or profiles, is what sets it apart from adjacent observability signals: metrics answer "how much/how many, over time" cheaply at scale, where logs and traces answer "what exactly happened, in this one request". Grafana complements it as the visualization and dashboarding layer, and can also evaluate its own alerting rules against the same data.

Some capabilities (Grafana Enterprise-only features, Grafana Cloud-hosted services, and long-term-storage systems like Thanos/Cortex/Mimir) are linked, not documented in depth.

If you are new to this section, read Getting Started first to get a Prometheus instance scraping real targets, then Architecture & Ecosystem for how the pieces fit together, and Data Model & Metric Types for the vocabulary (time series, labels, the four metric types) every later page assumes. Everything after that builds on those foundations.

The pages share one running example, a small Python service called orders-api instrumented with the official client library and scraped by a Prometheus server in Docker next to node_exporter, the Pushgateway and blackbox_exporter. Its source and the lab configuration are on Getting Started and Instrumenting Applications, and the queries, exposition output and API responses shown throughout were captured from it.

For the application-side view of instrumenting a Spring Boot service and wiring it to Prometheus and Grafana, see Metrics & Observability; this section is the deeper, tool-focused reference that page links out to. For dashboards and alerts on LLM applications (token usage, latency, cost, quality scores), see LLMOps: Metrics, Dashboards & Alerting.

Version baseline

This section documents the current Prometheus 3.x line (latest 3.14.0) as published at the Prometheus documentation and the current Grafana 13.x line (latest 13.3) as published at the Grafana documentation, which are the references these pages are written and verified against. No specific patch version is pinned. The examples were run on Prometheus 3.5.0, Alertmanager 0.35 and Grafana 13.3.0.

What’s covered

Getting started

  • Getting Started — installing and running Prometheus (binary tarball, Docker), a first prometheus.yml, the expression browser, scraping node_exporter, and writing a first alerting rule.

  • Architecture & Ecosystem — the server, client libraries, exporters, service discovery, the Pushgateway, Alertmanager, remote storage, and why Prometheus pulls rather than pushes.

Data model & instrumentation

  • Data Model & Metric Types — time series, labels, jobs and instances, the four metric types (Counter, Gauge, Histogram, Summary), and native histograms.

  • Instrumenting Applications — client libraries, the exposition format and OpenMetrics, content negotiation, and metric/label naming conventions.

  • Exporters & the Pushgateway — node_exporter collectors, blackbox_exporter probing, writing a custom exporter, and the Pushgateway (and when not to use it).

Service discovery & Kubernetes

PromQL

  • PromQL: Basics & Selectors — instant vs. range vectors, label matchers, subqueries, offset, the @ modifier, and the HTTP query API.

  • PromQL: Operators & Aggregation — arithmetic/comparison/logical operators, vector matching (one-to-one, many-to-one, group_left/ group_right), and aggregation operators.

  • PromQL: Functions — rate/irate/increase, histogram_quantile, predict_linear, label_replace/label_join, and time/date functions.

Rules & alerting

  • Recording & Alerting Rules — recording rule naming and use cases, alerting rule for/labels/annotations/templates, and testing rules with promtool.

  • Alertmanager — the notification pipeline, the routing tree, grouping and throttling, receivers and templates, inhibition, silences, and HA clustering.

Storage & operations

Grafana

  • Grafana: Dashboards & Visualization — installing Grafana, adding the Prometheus data source, dashboards and panel types, and template variables.

  • Grafana Alerting — Grafana-managed alerting vs. Prometheus/Alertmanager alerting, and notification policies and contact points.

  • See also Monitoring & Alerting: Grafana — the full Grafana subsection (data sources, dashboards, variables, visualizations, alert rules, notification policies, provisioning).

Cheat sheet

  • Cheat Sheet (PDF) — a single-page, printable summary of everything in this section, with a downloadable PDF.

Deliberately out of scope. This section is about Prometheus and Grafana as the metrics layer: the data model, instrumentation, querying, rules and operations. The following topics appear in most books on the subject but live elsewhere on this site, or are intentionally not covered:

Bibliography