Repository navigation
alerts: the dashboard shows the queries to run on your own cluster under each displayed alert - #57
Merged
Merged
Conversation
…der each displayed alert
Under every alert the summary displays (fired, or its query failed), one
collapsed line — "queries to run on your cluster (N)" — opens the rule's
query exactly as it ran ({sys.*} expanded for the bundle's mode, so it
pastes into clickhouse-client on the same cluster) and the rule's new
optional investigate: follow-ups, each with a copy button. The follow-ups
answer the "which one?" a finding raises: every background pool now and
per hour against its size for the pool and propagation-lag rules; stuck
entries per table and replica health for replication_queue_errors.
Follow-ups are shown, never run by the tool, and validated read-only like
the rule's query — an unsafe one breaks the rule and shows nothing. Clean
rules carry no SQL, so the page does not grow for them, and
alerts_summary.json stays counts only. The main query now goes through
the evaluator's query seam, so a fired result is unit-testable.
Checked on the lab: a fired rule's three queries, copied from the rendered
page, run and return the alert's rows; every follow-up runs on 26.7 in
both forms and on 22.8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Versioned pool rules omit the follow-ups, and queue-error grouping combines distinct failure causes.
2 open issues
What changed in this PR
Adds copyable diagnostic SQL beneath displayed dashboard alerts, helping engineers investigate findings on their own cluster.
Changes:
- Displays alert queries and optional follow-ups in collapsed, escaped blocks.
- Validates follow-ups without executing them and keeps summary JSON SQL-free.
- Adds pool and replication diagnostics, documentation, and tests.
| File | Description |
|---|---|
| README.md | Documents displayed SQL and follow-up definitions. |
| internal/dashboard/generator.go | Renders collapsed queries with copy buttons. |
| internal/dashboard/alerts_panel_test.go | Tests query rendering and escaping. |
| internal/alert/alert.go | Validates and attaches diagnostic SQL. |
| internal/alert/alert_test.go | Tests SQL validation and result handling. |
| alerts/schedule_pool_saturated.yaml | Adds pool diagnostic follow-ups. |
| alerts/replication_queue_errors.yaml | Adds queue and replica-health queries. |
| alerts/parts_propagation_lag.yaml | Adds pool diagnostics for propagation lag. |
| alerts/fetch_pool_saturated.yaml | Adds fetch-pool diagnostic follow-ups. |
Review effort: Balanced
…uck entries are grouped by cause On 23.3+ RunAll runs the alerts/23.3.1.0/ overrides of fetch_pool_saturated and schedule_pool_saturated — every current server — and neither carried the investigate: list, so the "which pool?" queries never showed where they matter. Both overrides now carry the root's follow-ups, and two tests stop it recurring: TestAlertYAML_OverridesMatchRoot requires an override's investigate: to equal its root's, and a RunAll on the shipped rules at 26.7 requires the version-selected results to carry them. Both failed before. The replication follow-up promised "grouped by table, type and error" but grouped by table and type only, so two causes shared one count and an arbitrary example. It now groups by an error key — the message's start with every number replaced by N — so one cause stays one row although its text carries part names and sizes, and two causes never share one. Checked on realistic rows (two NOT_ENOUGH_SPACE variants, two NETWORK_ERROR) and on 26.7 and 22.8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e-mars
approved these changes
Oct 19, 2026
CamiloSierraH
added a commit
that referenced
this pull request
Oct 20, 2026
…' dashboard tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Why
The alert summary says what is wrong, but not how to see it on the customer's own cluster, or which of several things it is. On a replication-lag case the engineer suspected thread-pool saturation but could not tell which pool, and there was nothing to hand the customer to check.
What changed
Under every alert the summary displays (fired, or its query failed), one collapsed line:
Opening it shows the following, each with a copy button, in the scrollable box the stack traces use:
queryexactly as it ran, with{sys.*}expanded for the bundle's mode, so it pastes intoclickhouse-clienton the same cluster and returns the alert's rows per host.investigate:list in the rule YAML (title plus a read-only SELECT):fetch_pool_saturated,schedule_pool_saturated,parts_propagation_lag: every background pool right now, per replica, busy against its size, and each pool's hourly peak over 24 h. This answers "which pool". On SharedMergeTree, propagation lag from a saturated pool is P-59.replication_queue_errors: stuck entries grouped by table, type and cause (the message with numbers normalised, so one cause is one row), and replica health for the tables with a queue.Further details:
ValidateQueryContentread-only check as the rule's query. A rule with an unsafe follow-up is reported as broken and shows no SQL.alerts_summary.jsonstays counts only (tested).query()seam, which runs the sameExecuteQueryWithFormatin production, so a fired result can be unit-tested.Verification
Lab, real evaluator and dashboard: I fired
fetch_pool_saturatedusing a temporary copy with its thresholds set to zero (the shipped rule is unchanged). In headless Chrome the block renders collapsed. The three queries, copied from the rendered page as shown, all run on the cluster, and the alert's own query returns the row that fired.Every follow-up runs: on 26.7 in both the onprem and the cloud (
clusterAllReplicas) form, and on the 22.8 floor. On a lab replica with a stuck queue, the replica-health follow-up shows the table and its delay.Tests:
Each of the 6 behaviours fails its test when reverted.
Version overrides: the
alerts/23.3.1.0/overrides of the pool rules, which are what runs on every current server, carry the same follow-ups. A test requires every override'sinvestigate:to equal its root's, and aRunAllat 26.7 checks the version-selected results.gofmt,go vet(alsoGOOS=windows) andmake testare green: 273 passed. 11 files.🤖 Generated with Claude Code