PCA PCA Recording Rules & Aggregation 1 — Questions and Answers
Question 1: What is the primary purpose of recording rules in Prometheus?
- To precompute expensive PromQL expressions and store results as new time series (Correct answer)
- To define thresholds that trigger alerts when exceeded
- To record scrape events for audit logging
- To store raw scrape results in a separate TSDB partition
Correct answer: To precompute expensive PromQL expressions and store results as new time series
Recording rules evaluate PromQL expressions on a schedule and write the results as new metric series, making repeated queries faster.
Question 2: What naming convention does Prometheus recommend for recording rule metric names?
- level:metric:operations (e.g., job:http_requests_total:rate5m) (Correct answer)
- metric_name_rule (e.g., http_requests_total_rule)
- record_metric_name (e.g., record_http_requests)
- agg_metric_name (e.g., agg_http_requests_total)
Correct answer: level:metric:operations (e.g., job:http_requests_total:rate5m)
The recommended format is level:metric:operations, encoding aggregation level, source metric, and transformations into the name.
Question 3: In a Prometheus rule file, which YAML key defines a recording rule's output metric name?
- record (Correct answer)
- metric
- name
- output
Correct answer: record
The `record` key in a rule group entry specifies the name of the new time series that the rule's expression will be written to.
Question 4: How are recording rule files loaded into Prometheus?
- Via the rule_files directive in prometheus.yml listing file paths or globs (Correct answer)
- By placing them in a predefined /etc/prometheus/rules/ directory automatically
- Via the Prometheus admin API at /api/v1/rules/upload
- By restarting Prometheus with --rule-file flags
Correct answer: Via the rule_files directive in prometheus.yml listing file paths or globs
The rule_files section of prometheus.yml accepts file paths and glob patterns pointing to YAML files containing rule groups.
Question 5: What happens when Prometheus evaluates a recording rule that produces no series (empty result)?
- No new data points are written for that evaluation interval (Correct answer)
- The rule writes a 0 value to prevent gaps in the recorded metric
- Prometheus raises a rule evaluation error and logs a warning
- The rule is disabled automatically after 3 consecutive empty results
Correct answer: No new data points are written for that evaluation interval
If a recording rule returns an empty result, Prometheus simply writes nothing for that interval, leaving a gap in the recorded metric.
Question 6: What is the `interval` field in a Prometheus rule group used for?
- Setting how frequently all rules in the group are evaluated (Correct answer)
- Defining the time range used in range vector selectors within the group
- Setting the retention period for metrics produced by the group
- Controlling how often Alertmanager receives notifications from the group
Correct answer: Setting how frequently all rules in the group are evaluated
The interval field overrides the global evaluation_interval for a specific rule group, allowing different groups to evaluate at different frequencies.
What is the primary purpose of recording rules in Prometheus?