PCA PCA Recording Rules & Aggregation 2 — Questions and Answers
Question 1: Which PromQL function is most commonly used in recording rules to compute per-second rates from counters?
- rate() (Correct answer)
- irate()
- increase()
- delta()
Correct answer: rate()
rate() computes the per-second average rate of a counter over a time range and is the standard function for counter-based recording rules.
Question 2: What is the benefit of using `without` instead of `by` in aggregation expressions within recording rules?
- without drops specified labels and keeps all others, making rules more resilient to new labels being added (Correct answer)
- without is faster because it skips the label matching step entirely
- without preserves the original metric name in the output
- without is required for counter metrics while by is for gauges
Correct answer: without drops specified labels and keeps all others, making rules more resilient to new labels being added
Using without means you only specify labels to remove; any newly added labels are automatically included in the aggregation grouping.
Question 3: In a recording rule, what does the `labels` field allow you to do?
- Add or overwrite labels on the resulting recorded metric (Correct answer)
- Filter which series the rule expression is applied to
- Define the label set used for grouping in the PromQL expression
- Specify the labels that will be inherited from the source metric
Correct answer: Add or overwrite labels on the resulting recorded metric
The labels field in a recording rule attaches additional static labels to all series written by that rule.
Question 4: Why is it important to align a recording rule's range vector window with its evaluation interval?
- Using a window shorter than the interval can cause samples to be missed, producing inaccurate rates (Correct answer)
- Prometheus rejects rule files where the window and interval don't match
- Misalignment causes the WAL to grow unbounded
- Shorter windows always produce higher rates than longer windows regardless of interval
Correct answer: Using a window shorter than the interval can cause samples to be missed, producing inaccurate rates
If the range window is shorter than the evaluation interval, some scrape samples may fall outside the window, creating holes in computed rates.
Question 5: What is stale marker handling in the context of Prometheus recording rules?
- When a source series disappears, Prometheus marks recorded outputs as stale so dashboards show gaps instead of stale values (Correct answer)
- It is a mechanism that replaces missing data points with the last known good value
- Stale markers are injected into WAL to signal block compaction boundaries
- Recording rules inject NaN values when source metrics exceed retention
Correct answer: When a source series disappears, Prometheus marks recorded outputs as stale so dashboards show gaps instead of stale values
Prometheus propagates staleness from input series to recording rule outputs, causing downstream metrics to also show as stale/missing when the source goes away.
Question 6: Which Prometheus flag or API allows you to check whether rule files are valid before loading them?
- promtool check rules <file> (Correct answer)
- prometheus --validate-rules <file>
- promtool lint rules <file>
- prometheus --dry-run-rules <file>
Correct answer: promtool check rules <file>
The `promtool check rules` command validates the syntax and PromQL expressions in rule files without starting a Prometheus server.
Which PromQL function is most commonly used in recording rules to compute per-second rates from counters?