Exercise 2 of 8 · Prometheus metrics · About 15 min
A counter, a gauge, and a histogram
Distinguish a counter, an in-flight gauge and a latency histogram using actual checkout requests.
Keep your stack running. In Codespaces, use labs/observability and the Ports tab for tool URLs; locally, use the extracted baodium-observability folder. Earlier exercises establish the signals used here.
Before you run it
After traffic stops, which signal should remain cumulative, which should return to zero, and which records the distribution of completed work?
Generate real requests
Send bounded concurrent traffic through checkout and payment. The CLI reports successful and failed HTTP responses and the final trace ID.
node lab.mjs traffic 15Successful requests in the default healthy configuration. Every finished request increments the checkout counter.
Help with this exercise
Prometheus scrapes every two seconds. No samples yet is different from zero requests. A request counter is not the number currently in flight.
Need a hint or a troubleshooting path?
Prometheus scrapes every two seconds. No samples yet is different from zero requests. A request counter is not the number currently in flight.
Check a common misconception
Zero active requests says nothing about past failures. A counter reset after a restart is not negative traffic.
Before you move on
- What to keep
- Record a counter before and after traffic, an active-request observation during load, and two histogram bucket boundaries with their counts.
- What to explain
- Connect each instrument to an operational question. Explain cumulative buckets and why trace IDs would create unbounded label cardinality.
- A question to take further
- How would you distinguish a service doing no work from a service whose metrics endpoint stopped responding?
Write what you found
Explain why a trace ID should not become a label on the request counter.
Stop the stack when you finish
Continue to the next exercise with the stack running. When finished, stop and remove only this lab’s Compose services and volumes.
node lab.mjs down