Observability & OpenTelemetry
PromQL rate
rate() turns a counter into a per-second increase over a window and corrects for counter resets, so the window should be longer than two scrape intervals and never applied to a gauge.
What you will be able to do
- Explain what rate() returns for a counter and why it handles resets.
- Decide the window length and the function to use for a counter or a gauge.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in Observability & OpenTelemetry
- USE metricsIntermediate · 4 min
The USE method checks utilization, saturation and errors for each resource on a host, and saturation shows the waiting that a moderate utilization figure can hide.
- Prometheus scrape modelIntermediate · 4 min
Prometheus pulls metrics from each target on a scrape interval and records a failed scrape as up equal to 0, so gaps in a graph often come from scrape timeouts rather…
- PromQL histogram quantileIntermediate · 4 min
histogram_quantile estimates a percentile from cumulative buckets, using the le label as each bound, so the estimate is only as precise as the bucket layout around the…
- Label cardinalityIntermediate · 4 min
Each distinct combination of label values is a separate time series, so cardinality is the product of the label value counts, and unbounded labels make storage and…
- Recording rulesIntermediate · 4 min
A recording rule runs an expensive query on a fixed schedule and stores the result as a new time series. Dashboards and alerts then read that stored result quickly and…
- Alertmanager routingIntermediate · 4 min
Alertmanager routes each alert through a tree of matchers, so the order of routes and the continue flag decide who gets paged. Testing label sets before a change…