Skip to content

feat(admin): Search all nodes in System Queries instead of picking a storage - #8609

Merged
onewland merged 3 commits into
masterfrom
feat/admin-system-queries-node-search
Oct 27, 2026
Merged

onewland merged 3 commits into
masterfrom
feat/admin-system-queries-node-search

Conversation

@onewland

@onewland onewland commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

System Queries made you pick a storage before a host. The storage list repeats each ClickHouse cluster under many storage names, so finding the right host meant scrolling a long list of near-duplicates. The host field is now one autocomplete across every node the admin knows about, whichever storage it comes from.

Local screenshots:
Screenshot 2026-10-26 at 3 30 11 PM

Screenshot 2026-10-26 at 3 30 01 PM

Old-storage based selector remains:
Screenshot 2026-10-26 at 3 32 11 PM


The backend is unchanged. It still needs a storage, because the storage is how it finds the cluster's credentials, database and TLS settings, and how it checks that the host is a real node. So picking a node quietly sends a storage that lists it:

  1. the storage from a shared link or the last pick, if it lists the node; otherwise
  2. querylog, which has no 25s timeout; otherwise
  3. the shortest name.

Manual host entry keeps a storage picker for the same reason. Share links and history entries still carry the storage, so existing links keep working.

The search is built around how our hostnames look. The full rules are in snuba/admin/static/utils/NODE_SEARCH.md. In short:

  • Separators are optional: eap1 finds …-platform-1-0.
  • A run of words can be typed as initials: eap finds events-analytics-platform.
  • A typed separator can skip the rest of a word: err-1 finds errors-1-*.
  • Results rank matches at the start of a word first, then matches whose word breaks line up best with the search (eap-11 prefers …-11-1 over …-1-1). Distributed-only nodes go last. Matched characters are highlighted.

I considered a library such as fzf-for-js, match-sorter or Fuse.js. These score fuzzy subsequences, so with about 200 similar hostnames, a search like err-1 would also match hosts such as generic-metrics-1-0, ranked lower. Rules this specific to hostnames are simpler to keep exact in about 250 lines of our own than to tune into someone else's scorer.

A second, separate commit makes every admin CustomSelect select its contents on focus, so typing replaces the current value instead of having to delete it first. It ignores the mouseup from the click that focused the field, because Chrome and Safari would otherwise use it to clear the selection again.

Worth a careful look in review:

  • Storage choice: storageForNode in clickhouse_node_utils.tsx. It decides which cluster's credentials a query uses.
  • Matcher: matchVariantFrom in the same file, the backtracking part of the search.

On 576 hosts the search takes about 1–12ms per keystroke. /clickhouse_nodes still looks up cluster topology once per storage, as it did before.

🤖 Generated with Claude Code

onewland and others added 3 commits October 26, 2026 15:26
…storage

System Queries made you pick a storage before a host, and the storage list
repeats every cluster under many names. The host field is now one
autocomplete across every node the admin knows about.

Picking a node still sends a storage that lists it, since the backend uses
the storage to find the cluster's credentials and validate the node, so
the backend is unchanged. Manual host entry keeps a storage picker for the
same reason.

The search understands hostnames: separators are optional, runs of words
can be typed as initials (eap for events-analytics-platform), and a typed
separator can skip the rest of a word (err-1 for errors-1). Results rank
word-start matches first, then closer word-break alignment, with
distributed nodes last, and the matched characters are highlighted. The
rules are written up in snuba/admin/static/utils/NODE_SEARCH.md.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Clearing a select's current value to search for another meant deleting
it by hand. Focusing a select now selects its text, so typing replaces
it. The mouseup that ends the focusing click is ignored so it doesn't
put the caret back.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Some people will still want to pick a storage and then one of its hosts.
The host entry toggle is now Search nodes / By storage / Manual. By
storage works as before the node search: picking a storage fills in its
first host and lists only that storage's nodes. The page remembers which
of the two picking modes was used last, and switching between them keeps
the current host and storage.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@onewland
onewland marked this pull request as ready for review October 26, 2026 22:40
@onewland
onewland requested a review from a team as a code owner October 26, 2026 22:40

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b1d7c6d. Configure here.

...prevQuery,
...queryForNode(node, prevQuery.storage),
}));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

By-storage host not restored

Medium Severity

Picking a storage in by-storage mode fills the first host in query state only, and never writes select-host. Reload always restores that key through queryForNode, so an auto-filled host is lost, and an older search-mode host can overwrite the current storage.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b1d7c6d. Configure here.

setByStorage(value === "storage");
saveByStorage(value === "storage");
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Manual-to-search drops storage

Medium Severity

setHostEntry only toggles flags. After a host is typed in Manual, switching back to Search keeps host and port but never runs queryForNode, so storage can stay unset while the storage picker is hidden and Execute stays disabled.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b1d7c6d. Configure here.

@onewland
onewland merged commit ca4c4bd into master Oct 27, 2026
69 checks passed
@onewland
onewland deleted the feat/admin-system-queries-node-search branch October 27, 2026 16:29
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.

2 participants