← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Prometheus Concepts

observability Intermediate

TL;DR

Prometheus is a pull-based metrics system — services expose /metrics in text format, Prometheus scrapes them, stores as time series, and evaluates alerting rules via PromQL.

Explanation

Metric types: Counter (monotonically increasing, e.g. requests total), Gauge (up/down, e.g. memory), Histogram (bucketed distribution, e.g. latency), Summary (client-side quantiles). Labels: dimensions for filtering (method='GET', status='200'). Cardinality: high-cardinality labels (user_id) cause performance issues — use sparingly. PromQL: sum(rate(http_requests_total[5m])) by (route). Scrape: Prometheus pulls /metrics every 15-60s. Alertmanager: evaluates rules, routes alerts. PHP: promphp/prometheus_client_php, default Laravel integration. Push gateway: for short-lived jobs that don't live long enough to be scraped.

Common Misconception

Prometheus stores high-cardinality data efficiently — labels with unbounded values (user_id, request_id) create millions of time series and crash Prometheus.

Why It Matters

Prometheus is the de facto standard for infrastructure and application metrics — PromQL knowledge is essential for modern SRE and platform engineering.

Common Mistakes

  • High-cardinality labels — user_id, request_id in labels = millions of time series.
  • Not using histograms for latency — use Histogram, not Gauge, for percentile queries.
  • Scraping too frequently — default 15s is fine; 1s creates unnecessary load.

Code Examples

✗ Vulnerable
// High cardinality — one series per user:
$counter->labels(['user_id' => $userId])->inc(); // Millions of series
✓ Fixed
// Low cardinality — aggregate labels:
$counter->labels(['route' => $route, 'method' => $method, 'status' => $statusCode])->inc();

// Histogram for latency:
$histogram = new Histogram($registry, 'http_duration_seconds', 'Request duration',
    ['route'], [.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5]);
$histogram->labels([$route])->observe($duration);

Added 23 Mar 2026
Views 30
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 2 pings S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 2 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 1 ping F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T
No pings yet today
No pings yesterday
Amazonbot 8 Perplexity 7 Google 4 Unknown AI 3 Ahrefs 2 ChatGPT 1
crawler 24 pre-tracking 1
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Use Counter for totals, Histogram for latency, Gauge for current values. Keep label cardinality low (<1000 series per metric). Use rate() for counter queries, histogram_quantile() for percentiles.
📦 Applies To
web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
prometheus|/metrics
Auto-detectable: ✗ No prometheus
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Medium Context: File

✓ schema.org compliant