Prometheus Cheat Sheet
Reference for PromQL query syntax, scrape configuration, alerting rules, and common metric types used in Prometheus monitoring.
2 PagesIntermediateFeb 18, 2026
Scrape Configuration
prometheus.yml defining targets to scrape.
yaml
global: scrape_interval: 15sscrape_configs: - job_name: 'node' static_configs: - targets: ['localhost:9100'] - job_name: 'api' metrics_path: /metrics static_configs: - targets: ['api1:8080', 'api2:8080']
PromQL Basics
Common PromQL query patterns.
sql
# Current value of a metricup# Rate of increase over 5 minutes (for counters)rate(http_requests_total[5m])# Sum across all instances, grouped by jobsum by (job) (rate(http_requests_total[5m]))# 95th percentile latency from a histogramhistogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m]))# Alert-style comparisonnode_filesystem_free_bytes / node_filesystem_size_bytes < 0.1
Alerting Rule
A rule that fires when error rate exceeds a threshold.
yaml
groups: - name: api-alerts rules: - alert: HighErrorRate expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.05 for: 10m labels: severity: critical annotations: summary: "High 5xx error rate on {{ $labels.instance }}"
Metric Types
The four core Prometheus metric types.
- Counter- Monotonically increasing value (e.g. total requests); use rate() to analyze
- Gauge- A value that can go up or down (e.g. memory usage, queue length)
- Histogram- Samples observations into configurable buckets; supports histogram_quantile()
- Summary- Similar to histogram but calculates quantiles client-side over a sliding window
Pro Tip
Never take rate() of a gauge or irate()/rate() of raw counter values without a range vector — always apply rate() before aggregating with sum(), otherwise counter resets from restarts will produce misleading spikes.
Was this cheat sheet helpful?
Explore Topics
#Prometheus#PrometheusCheatSheet#DevOps#Intermediate#ScrapeConfiguration#PromQLBasics#AlertingRule#MetricTypes#Databases#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance