Skip to content

feat(dashboard): support per-target multi-datasource queries - #2238

Draft
jsers wants to merge 12 commits into
mainfrom
feat-dashboard-multi-datasource-query
Draft

feat(dashboard): support per-target multi-datasource queries#2238
jsers wants to merge 12 commits into
mainfrom
feat-dashboard-multi-datasource-query

Conversation

@jsers

@jsers jsers commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Allow each panel query target to carry its own datasource so a single panel can mix datasources. Mixed panels render via SingleTargetQueryEditor reusing each datasource's existing QueryBuilder; single-datasource panels keep the existing per-plugin builder path.

  • Add ITarget.datasource and a v4 migrator that normalizes legacy mode/expr targets to kind-based targets on dashboard load.
  • Introduce datasource registry/contract/service/requestState for the new /api/n9e/v2/query-batch rendering path with expression dependency resolution.
  • Unify expression detection on isExpressionTarget across plugin builders so migrated targets keep rendering after save/reload.
  • Omit field.key when spreading onto nested Form.Items to fix React duplicate-key warnings; add query.mixed_datasource i18n key.

Allow each panel query target to carry its own datasource so a single
panel can mix datasources. Mixed panels render via SingleTargetQueryEditor
reusing each datasource's existing QueryBuilder; single-datasource panels
keep the existing per-plugin builder path.

- Add ITarget.datasource and a v4 migrator that normalizes legacy
  __mode__/expr targets to kind-based targets on dashboard load.
- Introduce datasource registry/contract/service/requestState for the
  new /api/n9e/v2/query-batch rendering path with expression dependency
  resolution.
- Unify expression detection on isExpressionTarget across plugin builders
  so migrated targets keep rendering after save/reload.
- Omit field.key when spreading onto nested Form.Items to fix React
  duplicate-key warnings; add query.mixed_datasource i18n key.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e73683a8-613f-4553-9aad-deb6135ea511

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

jsers added 11 commits August 4, 2026 21:12
Spread elasticsearch/opensearch query.values into one backend query per
value, preserving the first value's RefID and allocating unique sub
RefIDs for the rest. Normalize responses back to the originating target
while letting an exact-match RefID win over a value-query prefix match.
Also port each datasource's legacy isQueryReady short-circuit so
unprepared targets are silently skipped without triggering validation.
… usage

- migrate Menu.Item children to Menu items prop in DashboardLinks, Detail/Title, Renderer/Main
- add hidden input child to hidden Form.Item in ES QueryPanel/Values, OrganizeFields, TransformationsEditorNG
- reset fields before setFieldsValue in DataLinks FormModal
- move setTableFields side effect from useMemo to useEffect in TableNG
…datasource-query

# Conflicts:
#	src/pages/dashboard/Editor/index.tsx
#	src/pages/dashboard/Renderer/Renderer/Main.tsx
#	src/pages/dashboard/Renderer/Renderer/TableNG/index.tsx
#	src/pages/dashboard/Renderer/Renderer/Timeseries/index.tsx
Strip the `key` field before spreading Form.List field props onto
Form.Item / Form.List to silence the React key-spread warning across
the Elasticsearch query editor and plugin AdvancedSettings components.
Replace `any` across dashboard query/variable/renderer modules with
JsonObject and typed series shapes, extract getDashboardQueryStep from
the legacy prometheus executor, and add a `check:dashboard-types` script
that enforces no-implicit-any on active dashboard code.
Set up jsdom + testing-library harness: jest.setup injects jest-dom
matchers and jsdom-missing browser APIs; jest.config maps plus: virtual
modules to a stub and proxies .less/.css to identity-obj-proxy; add
renderWithProviders / resetGlobalState helpers and dashboardQuery
fixtures.

Cover the unified query contract validation, the useQuery hook
(debounce, viewport deferral, stale-response drop, unmount safety), and
the ExpressionPanel interactions.

Also export setGlobalState from dashboard globalState for test resets,
and memoize TableNG overrides key before passing to useEffect deps.
…rer types

- destroy G2/TsGraph instances in BarChart/Heatmap/Stat on unmount to
  avoid leaked event listeners
- remove tooltip overlay DOM and mouseup listener in tooltipPlugin destroy
- null gridApiRef on grid pre-destroy; guard undefined field in cell renderer
- narrow cellOptions, DashboardSeries and TableCellValue types across
  TableNG and normalizeData
- fix ITransformation.id literal type ('string' -> string)
…ling

- Preserve user-saved field order in Organize editor; only append new columns
- Clamp activeIndex to valid range and guard getFormattedRowData against undefined tableData
- Snapshot/restore frame ids across transformation pipeline; keep columns and rows keys in sync
- Fix MergeTransformation losing rows when tables share no common fields
- Match organize fields by displayName with name fallback; preserve TableData extras
- Configure Vite optimizeDeps define for react-draggable and add n9e-plus dev proxy
- Add tests for Organize editor, normalizeData, getFormattedRowData, Merge, OrganizeFields
Tighten TypeScript across dashboard renderer, editor, variables and
transformations: narrow per-panel `custom` JsonObject destructuring,
widen IThresholds step value to number | null with downstream ?? 0 and
type guards, unify getCalculatedValuesBySeries return via the new
CalculatedSeriesValue interface, fix getBuiltInVariables call to match
its (range, params?) signature, and add null safety in transformations.

Also show a brief summary of configured maxDataPoints / time options
next to the QueryOptions button, covered by a jest test.
…logs series metadata

- Row edit modal keeps original row.name when input is cleared instead of overwriting with empty
- Populate n9e_internal (id, refId, metric) for victorialogs base series so legend highlight and override matching work
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.

1 participant