Skip to content

[Console] Add Kibana API route autocomplete in Dev Tools Console#272048

Draft
shahzad31 wants to merge 1 commit into
elastic:mainfrom
shahzad31:console/kibana-api-autocomplete
Draft

[Console] Add Kibana API route autocomplete in Dev Tools Console#272048
shahzad31 wants to merge 1 commit into
elastic:mainfrom
shahzad31:console/kibana-api-autocomplete

Conversation

@shahzad31
Copy link
Copy Markdown
Contributor

Summary

Dev Tools Console can call Kibana APIs via the kbn: URL prefix (e.g. GET kbn:/api/data_views), but there was no autocompletion for those routes (open gap: #130661). This PR adds route-name and query-parameter autocomplete for kbn: URLs, reusing Console's existing Elasticsearch matcher engine so everything downstream (tree walking, range math, prefix filtering) is shared.

Type kbn: after a method and Console now suggests Kibana routes, the HTTP methods each supports, and — after ? — the route's query parameters.

What's included

  • core http: new lightweight, public http.getRegisteredRoutes() that enumerates every registered route (path, method, access, description, versioned) without handlers or schemas. An opt-in { includeQueryParameters: true } also extracts each route's query parameters from its validation schema.
  • @kbn/router-to-openapispec: new extractRouteQueryParameters helper (query-only) that reuses the OpenAPI converter, so @kbn/config-schema and Zod schemas — versioned or not — are handled consistently. Returns a lightweight, serializable shape (no openapi-types leak into core's public contract).
  • Console server: builds Kibana autocomplete definitions from the registry (public routes by default, internal routes in dev mode), surfaces query parameters as url_params, and extends /api/console/api_server to return { es, kibana }.
  • Console client: loads a second kbn: matcher, routes kbn:-prefixed URLs to it, advertises the kbn: entry point at the start of a URL, shows supported methods, and re-triggers suggestions while the URL is being edited.

Known limitation / follow-up

Routes built on @kbn/server-route-repository with io-ts schemas (e.g. SLO, much of APM, infra, dataset-quality) register a PassThroughAny placeholder on validate.query and decode io-ts inside the handler, so their query schema never reaches the registered route. As a result these routes get route-name autocomplete but no query-parameter suggestions yet. Closing this would require surfacing the io-ts query schema at the repository layer (a shared platform package), tracked as a follow-up. Routes on that repository that use Zod already work.

How to test

  1. Run Kibana in dev mode against an ES instance.
  2. Open Dev Tools → Console.
  3. Type GET kbn: — Kibana routes should autocomplete (with method hints).
  4. Pick e.g. GET kbn:/api/synthetics/monitors? — query params should suggest (page, perPage, sortOrder, …).
  5. Confirm Elasticsearch autocomplete is unchanged, and that the kbn: entry point appears at the start of a URL.

Checklist

  • Docs / release note
  • Query-parameter coverage for io-ts (@kbn/server-route-repository) routes — follow-up

Part of #130661

Made with Cursor

Dev Tools Console can call Kibana APIs via the `kbn:` URL prefix
(e.g. `GET kbn:/api/data_views`) but offered no autocompletion for those
routes. This adds route-name and query-parameter autocomplete for `kbn:`
URLs, reusing Console's existing Elasticsearch matcher engine.

- core http: add a lightweight, public `http.getRegisteredRoutes()` that
  enumerates every registered route (path, method, access, description,
  versioned) without handlers or schemas. An opt-in
  `includeQueryParameters` also extracts each route's query parameters
  from its validation schema.
- @kbn/router-to-openapispec: add `extractRouteQueryParameters`
  (query-only) that reuses the OpenAPI converter so config-schema and Zod
  schemas, versioned or not, are handled. io-ts / server-route-repository
  routes (e.g. SLO, APM) are not yet covered.
- Console server: build Kibana autocomplete definitions from the registry
  (public by default, internal in dev mode), surface query parameters as
  `url_params`, and extend `/api/console/api_server` to return
  `{ es, kibana }`.
- Console client: load a second `kbn:` matcher and route `kbn:`-prefixed
  URLs to it, showing supported methods and re-triggering suggestions
  while the URL is edited.

Part of elastic#130661

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the author:actionable-obs PRs authored by the actionable obs team label May 31, 2026
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

infra-vault-gh-plugin-prod Bot commented May 31, 2026

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!

@kibanamachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #3 / AssetDocumentTab should select json tab when clicked
  • [job] [logs] Jest Integration Tests #4 / workflow with wait step when duration is short should have correct workflow duration

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
console 208.9KB 210.1KB +1.2KB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:actionable-obs PRs authored by the actionable obs team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants