Metrics Collection, Golden Signals & Alerting
Real-time time-series instrumentation, statistical percentiles (p50/p95/p99), cardinality governance, and symptom-based alerting.
Metrics: Real-Time Numerical Pulses of System Health
Metrics are aggregated, numerical measurements recorded over regular time intervals. Unlike logs that record every discrete event, metrics aggregate events into counters, rates, and distributions. This makes metrics computationally lightweight to query, inexpensive to retain over multi-year horizons, and ideal for triggering real-time automated alerts before users notice service degradation.
The Four Standard Metric Types (Prometheus / OpenMetrics)
Every metric instrumented in modern software falls into one of four standard mathematical types:
1. Counter
Monotonically IncreasingA cumulative metric that only ever increases or resets to zero on restart. Use rate() to calculate per-second throughput.
2. Gauge
Fluctuates Up & DownRepresents a single numerical value that can go up and down at any moment (instantaneous snapshot).
3. Histogram
Configurable BucketsSamples observations (usually request durations or sizes) and counts them in configurable cumulative buckets for calculating percentiles.
4. Summary
Client-Side QuantilesSimilar to a histogram, but calculates configurable quantiles directly on the client instance over a sliding time window.
The Four Golden Signals (Google SRE Framework)
If you can only measure four metrics of a user-facing service, focus on these four signals. They provide complete high-level visibility into system health, user impact, and capacity limits.
Latency
Milliseconds (ms) / Seconds (s) tracked as histogram percentiles (p50, p90, p95, p99).The time it takes to service a user request, differentiating between successful request latency and failed request latency.
histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))Traffic
Requests per second (RPS), Transactions per second (TPS), or Network I/O throughput (Mbps).A measure of how much demand is being placed on your system, measured in high-level system-specific throughput units.
sum(rate(http_requests_total[1m])) by (service)Errors
Error percentage (%) of total traffic, or absolute failed requests per second.The rate of requests that fail, either explicitly (e.g., HTTP 500s, gRPC Internal), implicitly (e.g., HTTP 200 containing an error payload), or policy-based (e.g., response took >2s).
sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m]))Saturation
Percentage utilization (%) or queue backlog length (e.g., 85% DB pool utilized, 4,200 messages waiting in queue).A measure of how full your service is, emphasizing the resources that are most constrained (CPU, memory, database connection pool, queue depth).
sum(container_memory_working_set_bytes) / sum(container_spec_memory_limit_bytes) * 100High-Cardinality Explosion Hazards & Governance
Cardinality is the total number of unique time-series created by multiplying all possible values of every label key on a metric. Adding high-entropy fields as metric labels will crash Prometheus or cause astronomical cloud monitoring bills:
- User IDs / Patient UUIDs (millions of unique values)
- Raw Request URLs with query parameters
- Authentication tokens, IP addresses, or Session IDs
- HTTP Status Codes (e.g.,
200,400,500) - Parameterized Route Templates (e.g.,
/api/v2/prescriptions/:id) - HTTP Methods (
GET,POST,DELETE) - Environment & Region (
production,us-east-1)
Alert Policy Design: Symptom-Based vs. Cause-Based Alerts
To avoid on-call alert fatigue, alert policies must prioritize symptoms that impact users over noisy internal causes:
⚠️ Cause-Based Alerting (Noisy Anti-Pattern)
Paging an engineer every time a single server reaches 85% CPU. If the cluster is autoscaling smoothly and user latency is unaffected, this alert generates useless wake-up pages.
Outcome: Alert fatigue, ignored pages, missed outages.✅ Symptom-Based Alerting (Best Practice)
Paging only when user-facing SLOs are burning error budgets rapidly (e.g., 5xx error rate >1% or p95 latency >500ms for 5 consecutive minutes).
Outcome: High signal-to-noise, actionable incident response.Generate mathematically rigorous Prometheus alerting rules using multi-window error budget burn rates to eliminate false alerts.
Community Discussion & Feedback
Attributed peer feedback and official Netspective architecture notes.