Repository navigation
alerts: name the firing series (node/pod) in the webhook and email - #258
Merged
Merged
Conversation
A rule folds every matching series into one scalar (agg across time AND series), so a firing alarm named only the rule — not which node/pod crossed. For a cluster-wide rule like node load average (agg=max over all nodes) that left the operator, and fixer, running `kubectl top nodes` by hand to find the hot box. When a rule fires, additionally resolve the ONE series that drove the breach — the series with the largest per-series aggregate for a `gt` rule, the smallest for `lt` — and attach its `attributes` JSONB (k8s.node.name, host.arch, …) to the webhook payload (new optional `attributes` field, omitted on resolve) and as a `Series:` line in the email. The attribution query mirrors eval_sql's window / predicate / rate shape exactly but GROUPs BY (service, attributes) instead of folding across them; it runs only when a rule actually fires, and is best-effort (no-data/error → no series, the page still goes out). No schema change — computed from the existing metrics.attributes column. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013cYVqzH7Xfwea7fAozdQK7
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.
What
A rule aggregates every matching series into one scalar (
aggfolds across time and series), so a firing alarm carried only{rule, metric, service}— never which node/pod crossed. For a cluster-wide rule likenode load average(agg=maxacross all nodes) that left the operator — and fixer — to runkubectl top nodesby hand to find the hot box. This is the watcher-engine half of the cluster-repoTODO(JEF)on that rule.How
When a rule fires, additionally resolve the one series that drove the breach — the series with the largest per-series aggregate for a
gtrule, the smallest forlt— and attach itsattributesJSONB (k8s.node.name,host.arch, …):attributesfield (omitted on resolve and when unresolved), so fixer can act on the node, not just the rule.Series: k8s.node.name=cluster-main, host.arch=arm64line.The attribution query (
series_attrs_sql) mirrorseval_sql's window / predicate / rate / increase shape exactly butGROUPsBY (service, attributes)instead of folding across them, ordered in the breach direction,LIMIT 1. It runs only when a rule actually fires (not every breach tick) and is best-effort — no data or a query error yields no series and the page still goes out. No schema change (computed from the existingmetrics.attributescolumn); injection-safe on the same terms aseval_sql(only the whitelistedagg_exprand the comparator-derivedASC/DESCare interpolated, every operand bound).Tests
cargo clippy --all-targets -- -D warningsclean,cargo fmtapplied, 25/25alerts::tests pass — new coverage: the attribution SQL shape (group-by, breach-direction order, limit 1, plain/rate/increase),render_attrs(sorted, bounded, skips empty/non-object), the emailSeries:line, and the webhook payload including/omittingattributes.Follow-ups (separate repos)
charts/watcherimage digest must be bumped to deploy it, and theTODO(JEF)comment on the arm64 load rule removed.🤖 Generated with Claude Code
https://claude.ai/code/session_013cYVqzH7Xfwea7fAozdQK7