PrometheusCheatSheet2026|CompletePromQLQueries+MetricsGuide
Prometheus beginner complete: PromQL queries production-ready, metrics tutorial, scraping resolved, alerting & monitoring best practices. Encyclopedic reference for developers and DevOps engineers.
Last Update: 2025-12-03 - Created: 2025-12-03
On This Page
Quick Start with Prometheus beginner
Production-ready compilation flags and build commands
PromQL Queries: QUICK START (5s)
Copy ā Paste ā Live
Prometheus web UI running at http://localhost:9090 with metrics scraping active. Learn more in PromQL syntax queries section below
When to Use Prometheus beginner
Decision matrix per scegliere la tecnologia giusta
IDEAL USE CASES
Monitoring containerized applications in Kubernetes clusters with time-series data collection
Building real-time dashboards with PromQL queries for system metrics and application performance
Setting up alerting and notification systems for infrastructure monitoring with Alertmanager integration
AVOID FOR
Real-time push-based monitoring requirements (Prometheus uses pull model exclusively)
Cardinality explosion scenarios with unbounded label combinations causing memory issues
Short-lived jobs without using Prometheus Pushgateway, leading to missed metrics collection
Core Concepts of Prometheus beginner
Production-ready compilation flags and build commands
PromQL Queries: Time-Series Selection & Filtering
PromQL is the functional query language for Prometheus time-series data. Instant queries select current metric values at specific timestamps; range queries select data over time intervals. Label matchers (=, !=, =~, !~) filter metrics by key-value pairs. Understanding metric selection is foundational for all PromQL queries and alerting rules.
Using wildcard selectors without regex syntax (e.g., job='*server' instead of job=~'.*server')
Use regex matchers =~ and !~ for pattern matching. Anchor patterns correctly with .* and $ for exact boundariesMetrics Types: Counter, Gauge, Histogram, Summary
Prometheus defines four metric types with different characteristics. Counters increase monotonically (request totals). Gauges represent point-in-time values (memory usage). Histograms track distribution of observations (request latency). Summaries compute quantiles server-side. Choosing correct metric types prevents calculation errors.
rate() Function: Calculate Per-Second Rates from Counters
The rate() function calculates the per-second increase rate over specified time windows. Critical for converting counter metrics into meaningful rates (requests/sec, bytes/sec). Window must be at least 2x scrape interval to avoid empty results from incomplete data points.
Using window smaller than scrape interval (e.g., rate(metric[10s]) with 15s scrape interval)
Use windows ā„ 4x scrape interval: rate(http_requests_total[5m]) for 15s scrape intervalsScraping Configuration: targets, intervals, timeout settings
Prometheus scrapes targets via HTTP at configured intervals (default 15s). Scrape timeout (default 10s) must be less than scrape interval. Service discovery can dynamically populate targets from Kubernetes, EC2, DNS. Incorrect configuration causes missed metrics or scrape failures.
scrape_timeout > scrape_interval causing cascading timeout failures
Set scrape_timeout to 80% of scrape_interval: timeout: 12s for 15s intervalLabels & Label Matchers: Organize and Query Multi-Dimensional Data
Labels are key-value pairs that identify and organize time series. Every metric has implicit __name__ label. Label matchers enable filtering: = (exact), != (not equal), =~ (regex), !~ (not regex). Proper labeling strategy prevents cardinality explosion and improves query performance.