Repository navigation
test(observability): the alert rule files are checked, and their rule tests run, by a pinned promtool in the unit tests (#1492) - #1499
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The checker fails to detect omitted sibling files when the macro receives package-root file paths.
1 open finding
What changed in this PR
Adds pinned promtool validation for shipped Prometheus alert rules and rule tests.
Changes:
- Pins Prometheus 3.15.0 binaries for supported host platforms.
- Adds a reusable Bazel test macro and validation scripts.
- Documents and tests the observability rule workflow.
| File | Description |
|---|---|
MODULE.bazel |
Pins Prometheus release archives. |
BUILD.bazel |
Adds the observability rules test. |
docs/observability/README.md |
Documents rule validation. |
bazel/promtool/BUILD.bazel |
Defines promtool targets and tests. |
bazel/promtool/defs.bzl |
Adds the reusable test macro. |
bazel/promtool/promtool.sh |
Wraps the pinned binary. |
bazel/promtool/version_test.sh |
Verifies the pinned version. |
bazel/promtool/check_rules.sh |
Runs rule and rule-test validation. |
bazel/promtool/check_rules_test.sh |
Tests checker behavior. |
bazel/promtool/testdata/good.yml |
Adds a valid rule fixture. |
bazel/promtool/testdata/good_test.yml |
Adds a passing rule-test fixture. |
bazel/promtool/testdata/broken.yml |
Adds an invalid PromQL fixture. |
bazel/promtool/testdata/not_rules.yml |
Adds a non-rule YAML fixture. |
bazel/promtool/testdata/failing_test.yml |
Adds a failing rule-test fixture. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… tests run, by a pinned promtool in the unit tests (#1492) Nothing in the build ran promtool, so a rule file under docs/observability was checked by hand only, and so would be the rule test #1490 adds. - MODULE.bazel pins the official Prometheus 3.15.0 release archives (linux and darwin, amd64 and arm64, sha256 from the release's sha256sums.txt), the way oras and actionlint are pinned. //bazel/promtool selects the host's promtool; :version_test fails until its EXPECTED moves with a bump. - promtool_rules_test (//bazel/promtool:defs.bzl) runs `promtool check rules` on every rule file and `promtool test rules` on every rule test. It fails on no rule file at all, and on a .yml that sits beside the files it was handed and was not handed. - //:observability_rules_test applies it to docs/observability by glob: every .yml there is a rule file, except <name>_test.yml, which is a rule test. It is in the root package because a BUILD file in docs/observability would take that directory's .md files out of the website's inputs. - //bazel/promtool:check_rules_test holds the checker to fixtures written to fail: an invalid expression, a file that is not a rule file, a rule test whose expectation does not hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
force-pushed
the
fix/1492-promtool-rule-tests
branch
from
October 9, 2026 10:45
a84bfd3 to
f96da5a
Compare
…s on a missing file Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #1492
An agent wrote this pull request.
What
MODULE.bazelpins the official Prometheus 3.15.0 release archives for linux and darwin, amd64 and arm64, with the sha256 of each from the release'ssha256sums.txt, the wayorasandactionlintare pinned.//bazel/promtoolselects the host's binary;bazel run //bazel/promtool -- <args>runs it from the caller's directory;//bazel/promtool:version_testfails until itsEXPECTEDmoves with a bump.promtool_rules_test(name, rules, tests)in//bazel/promtool:defs.bzlrunspromtool check ruleson every rule file andpromtool test ruleson every rule test, reports every file, and fails if any failed.//:observability_rules_testapplies it todocs/observabilityby glob: every.ymlthere is a rule file, except<name>_test.yml, which is a rule test. A file added there is picked up with no edit. It has no tag, so it is in the unit leg.docs/observability/README.mdsays so at the top.Decisions
go.mod.BUILD.bazelindocs/observabilitywould make that directory a package, and the root'sglob(["docs/**/*.md"])(the website's inputs) would stop seeing its two.mdfiles..ymlbeside the files it was handed that it was not handed (a rule test listed as data and never run).MODULE.bazel.lockdoes not change (bazel mod tidyis a no-op), so there is no lock conflict with another pull request.Evidence
The rule files on
mainare valid. All three passpromtool check rulesunchanged:There is no rule test on
mainyet, so on this branch thetest ruleshalf of//:observability_rules_testruns nothing. Two things stand in for it://bazel/promtool:check_rules_testruns the checker on fixtures whose verdict is known (13 cases): a good rule file and its test pass; a rule file with an unclosed parenthesis failscheck rules; a scrape config failscheck rules; a rule test that expects an alert for a target that is up failstest rules; a failure does not stop the files after it; a.ymlbeside the given files that was not given fails, also when the files are given by bare name; no rule file fails.//bazel/promtool:fixtures_rules_testruns the good pair through the macro.agent-pin-alerts.ymlandagent-pin-alerts_test.ymlfrom the open fix(agent,observability): the NACK counters are seeded, a cluster with no TLS published is not reported as the validation gap, and alert rules ship for the SAN-pin state (#1480, #1482, #1481) #1490 into the tree, ran the test, and removed them:So #1490's rule test passes with promtool 3.15.0 (its header says 3.5.0), and it will be run by this target as soon as both are on
main, in either order: the two pull requests merge cleanly (git merge-tree).Red, then green. Each applied alone, seen to fail, restored:
mesh-dns-alerts.ymlgiven an unclosed parenthesis//:observability_rules_test:FAIL check rules docs/observability/mesh-dns-alerts.yml ... unclosed left parenthesisfor:ofagent-pin-alerts.ymlchanged to3h//:observability_rules_test:FAIL test rules docs/observability/agent-pin-alerts_test.yml, expected alerts, got noneagent-pin-alerts_test.ymlbroken//:observability_rules_test:FAIL test rules ...check_rules_test: the broken rule file exits 0check_rules_test: the failing rule test exits 0check rulescheck_rules_testcheck_rules_testcheck_rules_testfixtures_rules_test:good_test.yml is a rule test next to the files given, and was not runEXPECTEDinversion_test.shchangedversion_testRun locally:
bazel test //bazel/promtool:all //:observability_rules_test //website:all //bazel/actionlint:all,bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //bazel/promtool:all //:observability_rules_test,make format-check,scripts/check-shell-lint.sh(the four new scripts are covered),bazel mod tidy(no change).Unverified
testleg is the first fetch of the archive on a runner. If the unit leg shows//:observability_rules_testand the three//bazel/promtooltests passing, the pin works there.agent-pin-alerts_test.yml("This repository has no promtool in its build, so CI does not run this file") is out of date. It is that pull request's file; not changed here.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr