Exercise 3 of 8 · PromQL · About 18 min

Rate, errors, and tail latency

Calculate request rate, error ratio and tail latency from the same measured population.

Before you begin

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

With every third payment failing, what steady-state error fraction do you expect? Predict how a 30-second window behaves immediately after recovery.

PromQLStep 1 of 4

Compare totals and rates

Generate traffic in a second terminal while querying. A total counter and a per-second rate answer different questions.

node lab.mjs query "sum(rate(baodium_checkout_requests_total[30s]))"
What you should see

A requests-per-second value after at least two scrapes. It changes with the traffic instead of increasing forever.

Help with this exercise

An empty vector often means the metric has not been scraped. Do not add two differently filtered denominators or confuse a fraction such as 0.33 with 0.33%.

Need a hint or a troubleshooting path?

An empty vector often means the metric has not been scraped. Do not add two differently filtered denominators or confuse a fraction such as 0.33 with 0.33%.

Check a common misconception

A ratio of 0.33 means 33%. Missing samples and NaN are not evidence of zero errors; inspect the numerator and denominator separately.

Before you move on

What to keep
Save the exact query, timestamp, numerator, denominator and resulting ratio during sustained fault traffic.
What to explain
Use the same population and window on both sides. Explain deviations from one third using scrape timing and the mix of old and new samples.
A question to take further
Would averaging per-instance error percentages preserve the correct fleet-wide error ratio when instances handle different traffic volumes?

Write what you found

Build histogram_quantile(0.95, sum by (le) (rate(baodium_checkout_duration_seconds_bucket[30s]))) and explain its unit and approximation.

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
Reference: PromQL basics ↗ (opens in a new tab)