Bitpath

Lesson 2 · Unit 01

Metrics

Counters, gauges and histograms, a rate from two readings, and what a label costs.

13 exercisesabout 3 min

What you practise

  • Counters, gauges and histograms, a rate computed from a counter, labels and the cost of too many values

Try a question from this lesson

Pick one

A service handles 2,000 requests a second. You want to know, all day, whether the share of errors is higher than an hour ago. What is the cheapest thing to keep?

Hint

A share needs two counts. What is the least you must store to get them?

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Counter, gauge, histogram

These three names come from the Prometheus metric types and are now common vocabulary.

A counter only goes up: requests served, errors, bytes sent. It restarts from zero when the process restarts.

A gauge goes up and down: memory in use, connections open, queue length.

A histogram counts observations into buckets by size, such as request durations, and keeps their sum and count.

counter    0 .. 41 .. 97 .. 160   only up
gauge      12 .. 30 .. 8 .. 19    up, down
histogram  <=100 ms: 870
           <=500 ms: 990
           any:      1000

Concept

Labels split one metric into many series

One counter for all requests cannot say which ones failed. So a metric carries labels, such as method and status, and keeps a separate number for every combination of values.

Each combination is its own time series, stored and paid for separately. Three series here; a new label multiplies them.

requests_total
method  status   value
GET     200       8812
GET     500         14
POST    200        950

10 more exercises in the app

  • 1× match the pairs
  • 3× type the answer
  • 4× multiple choice
  • 1× true or false
  • 1× fill the blanks

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy