Skip to content

feat: allow to fetch alerts by labels [DX-5105] - #2851

Merged
Tofel merged 3 commits into
mainfrom
dx-5105-filter-by-labels
Sep 29, 2026
Merged

Tofel merged 3 commits into
mainfrom
dx-5105-filter-by-labels

Conversation

@Tofel

@Tofel Tofel commented Sep 29, 2026

Copy link
Copy Markdown
Contributor
  • watch and single-step check can now select alerts by labels instead of names: --include-labels team=bcm,env=stage, optionally refined with --exclude-labels severity=info. Matches are exact; label selection cannot be combined with --alerts or --folder, and is refused with --in. A selection that matches no rules exits 2.

Copilot AI balanced review requested due to automatic review settings September 29, 2026 12:37
@Tofel
Tofel requested a review from a team as a code owner September 29, 2026 12:37
@github-actions

Copy link
Copy Markdown

👋 Tofel, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-testing-framework/grafana-alertcheck

View full report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unsupported excluded rules can bypass fail-closed validation, and the CLI rejects a matcher supported by the selection layer.

Review effort: Balanced
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds exact label-based alert selection to watch and single-step check.

Changes:

  • Parses rule labels and adds include/exclude matching.
  • Integrates label flags with validation and alert resolution.
  • Adds tests and documentation.
File Description
grafana-alertcheck/​README.md Documents label selection.
grafana-alertcheck/​internal/​gate/​watch.go Resolves watched alerts by labels.
grafana-alertcheck/​internal/​gate/​watch_test.go Tests label-based watch behavior.
grafana-alertcheck/​internal/​gate/​parse_ruler.go Parses rule labels.
grafana-alertcheck/​internal/​gate/​parse_ruler_test.go Tests label parsing.
grafana-alertcheck/​internal/​gate/​labels.go Implements matching and validation.
grafana-alertcheck/​internal/​gate/​labels_test.go Tests matching semantics.
grafana-alertcheck/​internal/​gate/​check.go Adds label selection to checks.
grafana-alertcheck/​internal/​gate/​check_test.go Tests label-based checks.
grafana-alertcheck/​docs/​reference/​cli.md Documents flags and constraints.
grafana-alertcheck/​docs/​index.md Updates quickstart guidance.
grafana-alertcheck/​docs/​architecture.md Describes alert-set resolution.
grafana-alertcheck/​cmd/​watch.go Parses watch label flags.
grafana-alertcheck/​cmd/​watch_test.go Tests watch flag validation.
grafana-alertcheck/​cmd/​common.go Adds shared flags and pair parsing.
grafana-alertcheck/​cmd/​common_test.go Tests label-pair parsing.
grafana-alertcheck/​cmd/​check.go Parses check label flags.
grafana-alertcheck/​cmd/​check_test.go Tests check flag validation.
grafana-alertcheck/​.changeset/​v0.1.4.md Records the feature release note.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread grafana-alertcheck/cmd/common.go Outdated
Comment thread grafana-alertcheck/internal/gate/labels.go
Comment thread grafana-alertcheck/docs/index.md Outdated
@Tofel
Tofel force-pushed the dx-5105-filter-by-labels branch from 2ed8f14 to 56cb4b1 Compare September 29, 2026 12:53
@Tofel
Tofel requested a balanced review from Copilot September 29, 2026 12:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The CLI and reference synopses advertise flag combinations that runtime validation rejects.

Review effort: Balanced
Findings: None

Resolved since last review (3)
Previously missed (3)

In code that hasn't changed since last review

Low severity Scope dependent flags to their valid selection branches

grafana-alertcheck/​cmd/​check.go:19

The synopsis places --exclude-labels and --folder outside the selection alternatives, so --help advertises invalid combinations such as --alerts ... --exclude-labels ... and --include-labels ... --folder ..., both of which validation rejects. Scope each dependent flag to its valid branch.

Low severity Scope dependent flags to their valid selection branches

grafana-alertcheck/​cmd/​watch.go:16

The synopsis places --exclude-labels and --folder outside the selection alternatives, so --help advertises invalid combinations such as --alerts ... --exclude-labels ... and --include-labels ... --folder ..., both of which validation rejects. Scope --folder to the alert-name branch and --exclude-labels to the label branch.

Low severity Nest folder and exclusion flags under valid selection branches

grafana-alertcheck/​docs/​reference/​cli.md:30

This synopsis currently presents --exclude-labels and --folder as valid with either selection mode, although the documented and implemented constraints reject exclusions without label inclusion and reject folders with labels. Group these flags under the branch where each is accepted.

This issue also appears on line 69 of the same file.

@Tofel
Tofel enabled auto-merge (squash) September 29, 2026 13:02
@Tofel
Tofel disabled auto-merge September 29, 2026 13:03
@Tofel
Tofel enabled auto-merge (squash) September 29, 2026 13:42
@Tofel
Tofel disabled auto-merge September 29, 2026 13:55
@Tofel
Tofel merged commit 906de2f into main Sep 29, 2026
72 of 73 checks passed
@Tofel
Tofel deleted the dx-5105-filter-by-labels branch September 29, 2026 13:56
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.

3 participants