beginner ยท Module 1.3
PromQL Mastery
Learning Objectives
- Write instant and range queries using label selectors and range selectors [Xm].
- Use rate() and increase() on counters and aggregate with sum by(label).
- Reason about why rate() over a counter is always non-negative.
Key Concepts
Selectors and ranges
video_start_failures_total{cdn="mum-1"} is an instant vector; adding [5m] makes it a range vector suitable for rate()/increase(). Practice these against the PromQL Playground sandbox.
rate vs increase
rate() gives per-second average over the window; increase() gives total growth over the window. Both operate on counters and handle resets, so they never go negative.
Aggregation with by/without
sum by(cdn)(rate(video_start_failures_total[5m])) groups failure rate per CDN PoP so you can see which edge location is degrading during a match.
Insight
rate() before sum(): rate the raw counter first, then aggregate. Summing counters and then rating mixes resets across series and produces garbage.
Info
The PromQL Playground sandbox evaluates queries against a deterministic dataset anchored to a virtual T_0, not wall-clock time.
Knowledge Check
1. Which expression yields per-second failure rate grouped by CDN PoP?
2. Why can rate() over a counter never return a negative value?
3. What is the difference between rate() and increase() over the same [5m] window?