Skip to content

test(lower): real-world PromQL conformance over the awesome-prometheus-alerts corpus - #32

Merged
zzylol merged 1 commit into
mainfrom
test/awesome-prometheus-alerts-corpus
Jul 2, 2026
Merged

test(lower): real-world PromQL conformance over the awesome-prometheus-alerts corpus#32
zzylol merged 1 commit into
mainfrom
test/awesome-prometheus-alerts-corpus

Conversation

@zzylol

@zzylol zzylol commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

What & why

Adds PromQL parsing/lowering conformance tests over real-world alerting queries — the 949 deduplicated expr values from awesome-prometheus-alerts (MIT), spanning Prometheus self-monitoring, host/hardware, node-exporter, databases, brokers, Kubernetes, and more.

Tests only — no production code changes. The corpus snapshot lives in crates/lower/tests/data/awesome_prometheus_alerts.txt; the suite is crates/lower/tests/awesome_prometheus_alerts.rs.

What it pins

Corpus-wide invariants (corpus_lowering_is_total_and_fully_parseable):

  • Totality — every real query lowers to Ok or a clean LoweringError, never panics.
  • Parseability0/949 fail at the parse stage; the parser accepts 100% of real-world alert PromQL.
  • A lowering coverage floor (ratchet) guards against regressions.

Pattern shape tests (verbatim corpus queries) — vector-vs-vector comparisons → BinaryOp{Compare}, and the bodies of the canonical patterns lower to the right L3: histogram-quantile latency SLO (Quantile / sum by (le) / rate), error-rate ratio (BinaryOp(Div) of two sum(rate)), sum by (job) (up).

__GAP tests pin the dominant patterns we cleanly reject today (so adding support flips them deliberately):

  • scalar-threshold comparisons (… > 0, … != 1) — ~822/949 of the corpus, rejected only because a bare numeric operand has no L2 scalar node yet. This is the single biggest blocker to lowering real alerts.
  • absent / changes / delta / predict_linear / vector functions.
  • without(...) grouping.

Headline finding

Real alerting PromQL is overwhelmingly <vector-expr> <cmp> <scalar>. Parsing is already 100%; lowering coverage is gated almost entirely by the scalar-threshold operand gap — the bodies underneath (rate, *_over_time, histogram_quantile, sum by (…)) lower fine on their own. That suggests a high-leverage follow-up: a scalar/number-literal node in the L2 PromQL path would unlock a large fraction of the corpus.

Notes

🤖 Generated with Claude Code

…s-alerts corpus

Adds a 949-query corpus of real-world alerting PromQL expressions (deduplicated
`expr` values from https://samber.github.io/awesome-prometheus-alerts/, MIT)
plus a conformance suite over it.

Corpus-wide invariants:
- Totality — every real query lowers to Ok or a clean LoweringError, never
  panics.
- Parseability — 0 of the 949 fail at the parse stage (the parser accepts 100%
  of real-world alert PromQL).
- A lowering coverage floor (ratchet) guards against regressions.

Targeted tests pin the L3 shape of the patterns we lower (vector-vs-vector
comparisons; and the bodies of the histogram-quantile latency SLO, error-rate
ratio, and `sum by (job) (up)` patterns), and `__GAP` tests pin the dominant
patterns we cleanly reject today so support flips them deliberately:

- scalar-threshold comparisons (`… > 0` / `… != 1`) — ~822/949 of the corpus;
  rejected only because a bare numeric operand has no L2 scalar node yet. This
  is the single biggest blocker to lowering real alerts.
- `absent` / `changes` / `delta` / `predict_linear` / `vector` functions.
- `without(...)` grouping.

No production code changes — tests only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zzylol
zzylol force-pushed the test/awesome-prometheus-alerts-corpus branch from d5ca25e to aeee242 Compare July 2, 2026 13:00
@zzylol
zzylol merged commit b324676 into main Jul 2, 2026
1 check passed
@zzylol
zzylol deleted the test/awesome-prometheus-alerts-corpus branch July 2, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant