Prometheus Recording Rules — Layered Pre-Aggregations (yaml)
Five recording rules following the level:metric:operation naming convention, where one rule consumes two others recorded earlier in the same group — evaluation order inside a group is sequential, which is exactly what makes that legal and what a rule validator must understand.
# Recording rules that pre-compute the expensive expressions used by the
# alerting rules and dashboards in this category.
groups:
- name: shop-recording
interval: 30s
rules:
- record: service:http_requests:rate5m
expr: sum by (service) (rate(http_requests_total[5m]))
- record: service:http_errors:rate5m
expr: sum by (service) (rate(http_requests_total{status=~"5.."}[5m]))
- record: service:http_error_ratio:rate5m
expr: service:http_errors:rate5m / service:http_requests:rate5m
- record: service:latency_p99:5m
expr: |
histogram_quantile(
0.99,
sum by (le, service) (rate(http_request_duration_seconds_bucket[5m]))
)
labels:
quantile: "0.99"
- name: shop-recording-slow
interval: 5m
rules:
- record: service:http_requests:increase1d
expr: sum by (service) (increase(http_requests_total[1d]))
Specifications
- Groups
- 2
- Rules
- 5
- Dependent Rules
- 1
- Naming Convention
- level:metric:operation
- Intervals
- 30s, 5m
- Adds Labels
- true
Testing contract
Expected to pass- Scenario
- Validate the rules and resolve the dependency between them.
- Expected result
- service:http_error_ratio:rate5m resolves against the two rules recorded above it in the same group, and moving it earlier is flagged as an ordering error.
What is a .yaml file?
YAML (YAML Ain't Markup Language) is a human-readable data-serialization format using indentation, key-value pairs, and lists, and is a superset of JSON. It supports comments, anchors, and multiple documents per file, favoring readability for configuration. Its indentation sensitivity makes it error-prone to hand-edit.
How to use this file
Use an example YAML file to test config parsers, indentation and anchor handling, multi-document streams, and safe-loading to avoid arbitrary object construction.
How to use this file for testing
“Prometheus Recording Rules — Layered Pre-Aggregations (yaml)” is a deterministic Novus Examples fixture for Observability, Config parsing, Time-series data. Structured and plain-text telemetry with known timestamps, levels, request identifiers, and error states for testing log ingestion, correlation, dashboards, and alert pipelines.
Documented properties for this file: YAML · 952 bytes. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.
Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.
Telemetry fixtures use fixed trace IDs, span IDs, and timestamps so ingestion is reproducible run to run. Point your collector, parser, or query layer at the file and assert the documented span tree, metric families, or severity mix; service and host names are invented.
Code examples
import yaml # pip install pyyaml
with open("prometheus-recording-rules.yaml") as f:
data = yaml.safe_load(f)
print(data)Related files
- promPrometheus Exposition — Counters and Gauges (prom)The body a /metrics endpoint returns: five metric families with HELP and TYPE metadata across 27 labelled series — request counters by route and status, process and runtime gauges, per-target up values (one deliberately 0) and a business gauge. The baseline exposition-parser fixture.

- yamlAlertmanager Config — Routing Tree, Inhibition and Mute Windows (yaml)An Alertmanager configuration with the routing behaviour that is hard to reason about without a fixture: a continue: true branch so a critical alert reaches two receivers, an inhibition rule suppressing warnings under a matching critical, and a weekend mute window.

- confFluent Bit — Tail, Enrich and Forward Pipeline (conf)A Fluent Bit configuration in its INI-like section format: a tail input using the CRI multiline parser that reassembles the partial-line fixture, Kubernetes enrichment, a modify filter dropping two of the high-cardinality fields, and a throttle. Keys are space-aligned, not delimited.

- yamlOpenTelemetry Collector — Tail-Sampling Policies (yaml)Six tail-sampling policies including an inverted regex match that drops health checks and a composite policy with its own rate limit and ordered sub-policies. Policies are OR-ed and one match keeps the entire trace, which is the semantic most people get backwards.

- yamlOpenTelemetry Collector — Three-Signal Pipeline Configuration (yaml)A Collector configuration wiring traces, metrics and logs through separate pipelines, with named component instances, a filelog receiver that parses the CRI log fixture, OTTL statements performing the semantic-convention migration from the paired trace fixtures, and a redaction processor.

- yamlPrometheus Scrape Config — Relabelling and Federation (yaml)Three scrape jobs with the parts that actually matter: relabel_configs rewriting a target label with a capture group, metric_relabel_configs dropping the two unbounded labels from the cardinality fixture, honor_timestamps for the textfile collector and a federation job with a match[] selector.

Generated by generation/observability.py. Free for any use, no attribution required — license.