Pcornel
Observability · Metrics

Counters, Gauges and Histograms

Cheat sheet · https://pcornel.dk/topic.php?topic=6204

Back to the Topic

Answer

Metric types: counters only increase (reset on restart), gauges go up and down, histograms count observations in buckets (for quantiles), summaries compute quantiles client-side.

Remember

Always use rate()/increase() on counters, never raw values. Histograms can be aggregated across instances; summaries cannot. Choose buckets around your SLO thresholds.

First checks

  • curl -s localhost:9090/api/v1/metadata?metric=<name> — first check for this topic
  • curl -s localhost:9090/-/ready — Prometheus ready
  • curl -s 'localhost:9090/api/v1/query?query=up' — scrape targets up/down
  • promtool check config prometheus.yml — config valid

Verify in this order

observation → typed metric → correct query function

Where it usually breaks

Using a gauge for request counts loses data between scrapes.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6204

Confirmation

Confirm action

Continue?