Use it to measure rates, latencies, saturation and resource usage.
Metrics
Metrics are numeric time series identified by a name and labels, sampled or aggregated over time — cheap to store and ideal for trends, dashboards and alerts.
1. List series for a metric: count by (__name__)({__name__=~"http_.*"}).
2. Counter? use rate(metric[5m]).
3. Latency via histogram quantiles.
4. Check label cardinality.
5. Graph and compare with expectations.
code/exporter exposes metric → scraped/pushed → TSDB → query → dashboard/alert
Typical mistakes are taking a raw counter as a rate, averaging ratios incorrectly, resetting counters across restarts, using unbounded labels, aggregating away instance errors and interpreting missing data as zero without checking scrape state. Preserve the first divergent observation and repeat the same bounded verification after remediation.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Observability owns metric semantics and query/collection behavior. The producing Domain owns what the underlying system state means.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification workflow Verify boundary
Confirm metric type, unit, label set and scrape/collection interval before writing a query. For counters use rate/increase over an appropriate window; for distributions preserve bucket/quantile semantics. Compare raw series with aggregated dashboard values when diagnosing a narrow failure.
Step 2 Failure signatures and limits Narrow the fault
Typical mistakes are taking a raw counter as a rate, averaging ratios incorrectly, resetting counters across restarts, using unbounded labels, aggregating away instance errors and interpreting missing data as zero without checking scrape state.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Subtopics
Go one level deeper into this subject.
Counters only increase, gauges go up and down, and histograms count observations in buckets so percentiles can be estimated.
Subtopic PromQL BasicsPromQL selects time series by name and labels and transforms them with functions and aggregations such as rate(), sum by () and topk().
Subtopic ExportersExporters translate metrics from systems that do not speak Prometheus format (Linux hosts, databases, network devices) into a /metrics endpoint.
Subtopic ExemplarsExemplars attach a trace ID to a metric sample, so you can jump from a latency spike on a graph straight to an example trace.
Pick the right type (counter, gauge, histogram). Apply rate() to counters. Keep label cardinality bounded — never put user IDs or URLs with IDs into labels.
count by (__name__)({__name__=~"http_.*"})— first check for this topiccurl -s localhost:9090/-/ready— Prometheus readycurl -s 'localhost:9090/api/v1/query?query=up'— scrape targets up/downpromtool check config prometheus.yml— config valid
ReferenceWhat it is1 section · depth on demand
Operating model
Metrics are numeric time-series observations. Counters accumulate events, gauges represent values that can rise/fall, and histogram/summary structures describe distributions with different aggregation trade-offs. Labels make series useful but create a multiplicative cardinality cost.
ReferenceHow it works1 section · depth on demand
In depth
Metrics are numeric measurements collected over time — CPU usage, request rate, error count, latency percentiles, interface throughput. They are cheap to store, fast to query and the basis for dashboards and alerting.
| Metric type | Example |
|---|---|
| Counter | Total requests, bytes sent (only increases; use rate) |
| Gauge | Current memory, queue length, temperature |
| Histogram | Request durations in buckets → percentiles |
| Summary | Pre-computed quantiles |
Useful frameworks for choosing metrics:
| Method | Metrics |
|---|---|
| RED (services) | Rate, Errors, Duration |
| USE (resources) | Utilisation, Saturation, Errors |
| Four golden signals | Latency, traffic, errors, saturation |
Watch cardinality: every unique label combination is a separate time series, so labels like user ID or full URL can overwhelm the metrics system.
ReferenceImportant terms & boundaries1 section · depth on demand
Scope map
- Counters
- Gauges
- Histograms
- Summaries
- Labels
- Rate/increase
- Aggregation
- Time-series concepts
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Configuration & expected output
Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.
Configuration example
Assumptions: The service exposes http_requests_total with a code label.
# recording rules
groups:
- name: http
rules:
- record: job:http_requests:rate5m
expr: sum by (job) (rate(http_requests_total[5m]))
- record: job:http_errors:ratio5m
expr: sum by (job) (rate(http_requests_total{code=~"5.."}[5m])) / sum by (job) (rate(http_requests_total[5m]))Expected output
promtool query instant http://prometheus:9090 'job:http_errors:ratio5m{job="checkout"}'Expected state: The error ratio is a small fraction between 0 and 1.
job:http_errors:ratio5m{job="checkout"} => 0.0021 @[1761379200]Always apply rate() to counters; the raw counter only grows and resets on restart. Illustrative authored output: field layout matches the tool, values will differ in your environment.Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Documentation verification: confirms the upstream model used by the Topic. It does not assert local production behavior.
Basis: https://opentelemetry.io/docs/specs/otel/metrics/ · confidence 92%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Metrics verification boundary matrix
A compact lookup separating intent, owning component state, effective state and consumer-visible outcome for Metrics.
| Boundary | Inspect | Healthy interpretation | Do not infer |
|---|---|---|---|
| Intent | Counters | Intended object/scope is explicit and versioned where relevant | Intent is already effective |
| Owning runtime/control plane | Gauges / Histograms | Owner accepts and reports the expected object state | Downstream dependencies are healthy |
| Effective state | Summaries | Independent read-back matches the intended state | Every client sees the same result |
| Consumer outcome | Labels | The original bounded check succeeds in the same time window | Production correctness outside this scope |
Deep reference
Design & tradeoffs
Scope
Observability owns metric semantics and query/collection behavior. The producing Domain owns what the underlying system state means.