Skip to content
Novus Examples
yaml952 B

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.

Preview — first 30 linesyaml
# 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)

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