World map

 

BM: Baca dalam Bahasa Melayu

World O2: Counters

Counter, gauge, histogram, summary

You will learn: the four kinds of metrics, and why a counter can suddenly drop to 0.

Checked with Prometheus 3 on 1 Nov 2026

The problem

The Bangsar orders counter said 225. A minute later it says 0. Did customers cancel every order?

Pick one answer.

Watch

Tap the counter.

0 of 1 found

Every metric has a type. A counter: A number that only goes up, like orders served. It drops to 0 only when the app restarts. only goes up, like orders served. These lines are from a real Prometheus.

Try it

Show the customers waiting. Then slide the time.

Tap kedai_customers_waiting, then Run. Watch the graph go up and down.

Metrics in this data (tap to add):

Time 0 is when the data starts. The query looks back from the eval time.

A number that goes up and down is a gauge: A number that goes up and down, like customers waiting or free memory..

Try it

Counter or gauge? Sort each number.

Drag a card into a box. Or tap the card, then tap the box.

      Watch

      bash
      curl -s localhost:9090/metrics | grep -E '^prometheus_http_request_duration_seconds_(bucket|sum|count)\{handler="/metrics"'
      prometheus_http_request_duration_seconds_bucket{handler="/metrics",le="0.1"} 3
      prometheus_http_request_duration_seconds_bucket{handler="/metrics",le="0.2"} 3
      prometheus_http_request_duration_seconds_bucket{handler="/metrics",le="0.4"} 3
      prometheus_http_request_duration_seconds_bucket{handler="/metrics",le="1"} 3
      prometheus_http_request_duration_seconds_bucket{handler="/metrics",le="3"} 3
      prometheus_http_request_duration_seconds_bucket{handler="/metrics",le="8"} 3
      prometheus_http_request_duration_seconds_bucket{handler="/metrics",le="20"} 3
      prometheus_http_request_duration_seconds_bucket{handler="/metrics",le="60"} 3
      prometheus_http_request_duration_seconds_bucket{handler="/metrics",le="120"} 3
      prometheus_http_request_duration_seconds_bucket{handler="/metrics",le="+Inf"} 3
      prometheus_http_request_duration_seconds_sum{handler="/metrics"} 0.024123016999999997
      prometheus_http_request_duration_seconds_count{handler="/metrics"} 3
      A real histogram from Prometheus: bucket lines with le labels from 0.1 to +Inf, then a sum and a count.

      A histogram: Counts requests into time buckets (le = less or equal), plus a _sum and a _count. counts requests into buckets. le means “less or equal”. All 3 requests here took 0.1 s or less.

      Try it

      Buckets count everything below them. le="0.25" says 100. le="0.5" says 114. How many took between 0.25 s and 0.5 s?

      Pick one answer.

      Check

      A summary: Quantiles worked out inside the app. You cannot add them up across servers. works out quantiles inside the app. Histogram or summary? Sort each one.

      Drag a card into a box. Or tap the card, then tap the box.

          You did it!

          You can now tell counters, gauges, histograms and summaries apart.

          Go deeper (optional)

          Names help: counters end in _total; units go in the name, like _seconds or _bytes. Prometheus 3 also has native histograms, with buckets built in. You turn them on with scrape_native_histograms. This course uses the classic le buckets.

          Real mission

          1. docker compose up -d
          2. curl -s localhost:9090/metrics | grep '^# TYPE'
          3. docker compose down

          0 of 4 steps done · Your ticks are saved.