Skip to content
Novus Examples
yaml966 B

Prometheus Alerting Rules — Intentionally Invalid, Five Distinct Faults (yaml)

A rule file that is perfectly valid YAML and completely invalid as Prometheus rules: a rule that is both an alert and a recording rule, a PromQL syntax error, a duplicated group name, a rule with no expr and a duration written in prose. Intentionally invalid, with each fault labelled in place.

Preview — first 34 linesyaml
# INTENTIONALLY INVALID rule file. Every group below breaks a different
# promtool check, and the comments say which.
groups:
  # 1. `alert` and `record` are mutually exclusive in one rule.
  - name: both-alert-and-record
    rules:
      - alert: Confused
        record: also_confused
        expr: up == 0

  # 2. PromQL syntax error: an aggregation with no grouping parentheses.
  - name: bad-promql
    rules:
      - alert: BadExpression
        expr: sum by service (rate(http_requests_total[5m])) > 1
        for: 5m

  # 3. Duplicate group name (see group 1's sibling below) and a missing expr.
  - name: bad-promql
    rules:
      - alert: NoExpression
        for: 5m
        labels:
          severity: page

  # 4. `for` must be a duration, and severity must be a string not a bare word list.
  - name: bad-types
    rules:
      - alert: BadDuration
        expr: up == 0
        for: five minutes
        labels:
          severity: [critical, page]

Specifications

Groups
4
Distinct Faults
5
Intentionally Invalid
true
Faults
alert+record together, PromQL syntax, duplicate group name, missing expr, wrong types
Parses As Yaml
true

Testing contract

Expected to fail
Scenario
Run rule validation over the file and collect every diagnostic.
Expected result
All five faults are reported with their group and rule names rather than validation stopping at the first, and the file still parses cleanly as YAML.

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 — Intentionally Invalid, Five Distinct Faults (yaml)” is a deterministic Novus Examples fixture for Observability, Schema validation, 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 · 966 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-invalid.yaml") as f:
    data = yaml.safe_load(f)
print(data)

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