Lesson 1 of 9 · 24m
The Prometheus Data Model Is the Product
Model metrics as searchable time series, choose the right metric types, and avoid turning labels into an accidental schema migration.
The worst metrics outages I have inherited were not caused by Prometheus crashing. They were caused by a team treating metrics like unstructured logs with numbers attached. Prometheus is opinionated: a metric name plus a fixed set of labels identifies one time series. That design is why queries are fast, why storage can compress well, and why careless labels can bankrupt you.
A series is name plus label set
This exposition contains two different series, not two examples of one row in a table:
http_requests_total{service="checkout",method="GET",status="200"} 18421
http_requests_total{service="checkout",method="POST",status="500"} 73The metric name describes the thing measured. Labels describe dimensions you want to slice by. The sample value belongs to the exact label set. Change a label value and Prometheus stores a different series.
This mental model matters because labels are schema. Adding status is usually safe. Adding user_id is not a dimension; it is an unbounded identity column and often an availability incident.
Metric types are promises
Prometheus client types are small contracts:
counter monotonically increasing total; use rate() or increase()
gauge value that can rise and fall; use as-is or aggregate
histogram distribution of observations in cumulative buckets
summary client-side quantiles, usually less flexible in aggregationA counter can reset when the process restarts. Prometheus rate functions handle resets, but they do not make a decreasing gauge into a valid counter. If you export queue depth as a counter because it mostly increases, every downstream query becomes suspect.
Histograms are the workhorse for latency. Buckets are cumulative and cheap relative to storing every event:
requestLatency := prometheus.NewHistogramVec(prometheus.HistogramOpts{
Name: "http_request_duration_seconds",
Help: "HTTP request latency in seconds.",
Buckets: []float64{0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5},
}, []string{"service", "method", "route"})Pick buckets around the service objective, not around what looks mathematically tidy. If the SLO is 300 ms, you need resolution below and around 300 ms.
Instrument nouns, not procedures
Good metric names describe what is being measured, use base units, and stay stable:
process_cpu_seconds_total
node_memory_MemAvailable_bytes
http_requests_total
db_connections_open
queue_oldest_message_age_secondsBad names encode changing implementation detail: api_v2_new_latency_final_ms. Use seconds, bytes, and ratios where possible. Prometheus conventions feel fussy until you operate twenty services and need one dashboard language.
Labels are joins you cannot undo cheaply
Prometheus has no relational join table hiding behind the scenes. Labels are denormalized into every series. A label that changes frequently creates series churn; a label with unbounded values creates cardinality explosion. Before adding one, ask:
Can this label have more than a few hundred values?
Does it contain user, request, session, container, or pod identity?
Will it let operators answer a real incident question?
Can the same answer come from logs or traces instead?If the dimension is for forensic detail, it often belongs in a trace span or structured log. Metrics are for aggregate operational shape.
Field notes
- Never put raw IDs, emails, URLs, IP addresses, or timestamps in labels unless you enjoy pager duty.
statusshould be bounded and normalized; a full error message is not a status.- Counter names conventionally end in
_total; do not strip that suffix in instrumentation. - Histogram quantiles are estimates constrained by bucket placement. A sharp bucket boundary can hide a real tail.
- Treat metric renames as breaking API changes because dashboards, alerts, and recording rules depend on them.
Was this lesson helpful?