Skip to content
Novus Examples
yaml2 KB

Prometheus Alerting Rules — Four Rules Across Two Groups (yaml)

Four alerting rules over two groups, using the YAML features that break naive config readers: block scalars for multi-line PromQL, folded scalars for descriptions, Go template annotations with pipes, and keep_firing_for. Every expression references metrics that exist in this category's fixtures.

Preview — first 50 linesyaml
# Prometheus alerting rules for the shop namespace.
# Every expression references metric families that exist in this category's
# Prometheus and OpenMetrics fixtures.
groups:
  - name: shop-availability
    interval: 30s
    rules:
      - alert: TargetDown
        expr: up == 0
        for: 5m
        labels:
          severity: critical
          team: platform
        annotations:
          summary: "{{ $labels.job }} target {{ $labels.instance }} is down"
          description: >-
            Prometheus has been unable to scrape {{ $labels.instance }} for five
            minutes. Check the pod status before paging the service owner.
          runbook_url: https://runbooks.example.com/shop/target-down

      - alert: HighErrorRate
        expr: |
          sum by (service) (rate(http_requests_total{status=~"5.."}[5m]))
            /
          sum by (service) (rate(http_requests_total[5m]))
            > 0.05
        for: 10m
        labels:
          severity: warning
          team: shop
        annotations:
          summary: "{{ $labels.service }} is serving more than 5% 5xx"
          description: "Current ratio: {{ $value | humanizePercentage }}."

  - name: shop-latency
    interval: 30s
    rules:
      - alert: CheckoutLatencySLOBurn
        expr: |
          histogram_quantile(
            0.99,
            sum by (le, service) (rate(http_request_duration_seconds_bucket{service="checkout-api"}[5m]))
          ) > 1
        for: 15m
        keep_firing_for: 5m
        labels:
          severity: critical
          team: shop
          slo: checkout-latency
        annotations:
62 lines total — download for the full file.

Specifications

Groups
2
Rules
4
Multiline Expressions
2
Has Keep Firing For
true
Has Runbook Urls
2
Templated Annotations
true
Evaluation Interval
30s

Testing contract

Expected to pass
Scenario
Load the file with promtool-style rule validation.
Expected result
Two groups and four rules load, the block-scalar expressions parse as valid PromQL, and the {{ $labels.job }} templates are preserved rather than being expanded at load time.

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 Alerting Rules — Four Rules Across Two Groups (yaml)” is a deterministic Novus Examples fixture for Observability, Config parsing, Config testing. 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 · 2,037 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-alerting-rules.yaml") as f:
    data = yaml.safe_load(f)
print(data)

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