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, scrapingnode_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_exportercollectors,blackbox_exporterprobing, writing a custom exporter, and the Pushgateway (and when not to use it).
Service discovery & Kubernetes
-
Service Discovery & Relabeling — static, file, HTTP, Consul, EC2 and Kubernetes service discovery,
relabel_configsvs.metric_relabel_configs, andhonor_labels. -
Containers & Kubernetes Monitoring — cAdvisor container metrics, Kubernetes service-discovery roles, and kube-state-metrics.
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 withpromtool. -
Alertmanager — the notification pipeline, the routing tree, grouping and throttling, receivers and templates, inhibition, silences, and HA clustering.
Storage & operations
-
Storage, Federation & Remote Write — the local TSDB, federation, the
remote_read/remote_writeAPIs, and long-term storage systems (Thanos, Cortex, Mimir). -
Security & Production Operations — server-side TLS and basic auth, capacity planning, sharding, HA, meta-monitoring,
promtool, and the management API.
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:
-
What monitoring is and how to choose signals (monitoring theory, SLOs) — see Observability Fundamentals, RED, USE and Golden Signals and SLIs, SLOs and Error Budgets.
-
Per-language client deep dives (Go, Java, Ruby, Rust) beyond the shared model — intentionally not covered; the Python client carries the running example in Instrumenting Applications, and the Spring Boot and axum integrations are in Metrics & Observability and Axum: Metrics & SLOs.
-
Database and service exporters (
mysqld_exporter,consul_exporterand the Consul telemetry walkthrough) — intentionally not covered; they follow the pattern in Exporters & the Pushgateway, and the Redis exporter is covered from the database side in Administration, Monitoring & Troubleshooting. -
Log-to-metric conversion with the grok exporter — intentionally not covered; log pipelines are discussed in Telemetry Collection Pipelines.
-
Bridging other monitoring systems (StatsD, InfluxDB, Graphite) — intentionally not covered beyond the bridge and OpenTelemetry notes in Instrumenting Applications.
-
The full
scrape_configoption reference (per-job timeouts, sample limits, scrape-time authentication and TLS) — see the official configuration reference linked in the bibliography; server-side TLS and authentication are in Security & Production Operations. -
Docker running and image options — see Running Containers.
-
Prometheus Operator (ServiceMonitor, PodMonitor, PrometheusRule) — intentionally not covered; mentioned as an alternative packaging in Containers & Kubernetes Monitoring.
-
Thanos, Cortex and Mimir internals and remote write 2.0 details — linked only; see Storage, Federation & Remote Write.
-
Alertmanager receivers other than webhook and Slack, gossip internals — configured by name only; see Alertmanager.
-
Grafana Enterprise and Cloud features, multi-window burn-rate SLO alerting — intentionally not covered; see Grafana Alerting and Recording & Alerting Rules.
Bibliography
-
Overview and Overview — Architecture, and First steps — Prometheus & Monitoring, Installing & running Prometheus, Prometheus architecture & ecosystem.
-
Getting started and Installation, the downloads page — Installing & running Prometheus.
-
Data model, Metric types, Jobs & instances and Native histograms — Data model & metric types.
-
Client libraries, Writing client libraries, Exposition formats, Content negotiation, Metric & label naming, Instrumentation and Histograms & summaries, plus OpenMetrics — Instrumenting applications.
-
Exporters & integrations, Writing exporters and Pushing metrics — Exporters & the Pushgateway.
-
Configuration and HTTP-based service discovery — Service discovery & relabeling.
-
Monitoring Docker container metrics using cAdvisor — Containers & Kubernetes monitoring.
-
Querying basics and the HTTP API — PromQL: Basics & selectors.
-
Recording rules, Alerting rules, Template reference and Unit testing rules — Recording & alerting rules.
-
Alerting overview, Configuration, Alertmanager and High availability — Alertmanager.
-
Storage, Federation and Remote read API, plus Thanos, Cortex and Mimir (linked, not documented in depth) — Storage, federation & remote write.
-
Security, TLS encryption, Management API and promtool — Security & production operations.
-
node_exporter and blackbox_exporter (linked, not documented in depth) — Exporters & the Pushgateway.
-
kube-state-metrics (linked, not documented in depth) — Containers & Kubernetes monitoring.
-
Install Grafana, Prometheus data source, Dashboards, Panels & visualizations and Variables, plus Grafana’s public dashboard library — Grafana: Dashboards & visualization.
-
Pivotto, Julien; Brazil, Brian. Prometheus: Up & Running, 2nd ed. O’Reilly Media, 2023. ISBN 978-1-098-13108-3 — official page: https://oreil.ly/prometheus-up-running-2e. Consulted as part of the bibliography for this section; not the primary or main reference — the official Prometheus and Grafana documentation above is authoritative on any discrepancy.