Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

refactor(dashboards-v2): declare per-kind query capabilities instead of inferring them from panel types (#12559)

Abhi kumare1ee38601679
diff --git a/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityMetrics/configBuilder.ts b/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityMetrics/configBuilder.ts
index 2da06c0732..c08d1b0a7f 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityMetrics/configBuilder.ts
+++ b/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityMetrics/configBuilder.ts
@@ -1,5 +1,4 @@
import { Timezone } from 'components/CustomTimePicker/timezoneUtils';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import { getLegend } from 'lib/dashboard/getQueryResults';
import getLabelName from 'lib/getLabelName';
import {
@@ -76,7 +75,7 @@ export function buildEntityMetricsChartConfig({
show: true,
side: 2,
isDarkMode,
- panelType: PANEL_TYPES.TIME_SERIES,
+ isTimeAxis: true,
});
builder.addAxis({
@@ -85,7 +84,6 @@ export function buildEntityMetricsChartConfig({
side: 3,
isDarkMode,
yAxisUnit,
- panelType: PANEL_TYPES.TIME_SERIES,
});
if (!apiResponse?.data?.result) {
diff --git a/frontend/src/container/MeterExplorer/Explorer/configBuilder.ts b/frontend/src/container/MeterExplorer/Explorer/configBuilder.ts
index 1369f27f28..8e0bf208fb 100644
--- a/frontend/src/container/MeterExplorer/Explorer/configBuilder.ts
+++ b/frontend/src/container/MeterExplorer/Explorer/configBuilder.ts
@@ -1,5 +1,4 @@
import { Timezone } from 'components/CustomTimePicker/timezoneUtils';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import { getLegend } from 'lib/dashboard/getQueryResults';
import getLabelName from 'lib/getLabelName';
import {
@@ -72,7 +71,7 @@ export function buildMeterChartConfig({
show: true,
side: 2,
isDarkMode,
- panelType: PANEL_TYPES.BAR,
+ isTimeAxis: true,
});
builder.addAxis({
@@ -81,7 +80,6 @@ export function buildMeterChartConfig({
side: 3,
isDarkMode,
yAxisUnit,
- panelType: PANEL_TYPES.BAR,
});
if (!apiResponse?.data?.result) {
diff --git a/frontend/src/lib/uPlotV2/config/UPlotAxisBuilder.ts b/frontend/src/lib/uPlotV2/config/UPlotAxisBuilder.ts
index 6da73e957e..93d523381c 100644
--- a/frontend/src/lib/uPlotV2/config/UPlotAxisBuilder.ts
+++ b/frontend/src/lib/uPlotV2/config/UPlotAxisBuilder.ts
@@ -1,5 +1,4 @@
import { getToolTipValue } from 'components/Graph/yAxisConfig';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import uPlot, { Axis } from 'uplot';
import { uPlotXAxisValuesFormat } from '../../uPlotLib/utils/constants';
@@ -7,11 +6,6 @@ import getGridColor from '../../uPlotLib/utils/getGridColor';
import { buildYAxisSizeCalculator } from '../utils/axis';
import { AxisProps, ConfigBuilder } from './types';
-const PANEL_TYPES_WITH_X_AXIS_DATETIME_FORMAT = [
- PANEL_TYPES.TIME_SERIES,
- PANEL_TYPES.BAR,
-];
-
/**
* Builder for uPlot axis configuration
* Handles creation and merging of axis settings
@@ -67,12 +61,9 @@ export class UPlotAxisBuilder extends ConfigBuilder<AxisProps, Axis> {
* Build values formatter for X-axis (time)
*/
private buildXAxisValuesFormatter(): uPlot.Axis.Values | undefined {
- const { panelType } = this.props;
+ const { isTimeAxis } = this.props;
- if (
- panelType &&
- PANEL_TYPES_WITH_X_AXIS_DATETIME_FORMAT.includes(panelType)
- ) {
+ if (isTimeAxis) {
return uPlotXAxisValuesFormat as uPlot.Axis.Values;
}
diff --git a/frontend/src/lib/uPlotV2/config/__tests__/UPlotAxisBuilder.test.ts b/frontend/src/lib/uPlotV2/config/__tests__/UPlotAxisBuilder.test.ts
index 8f2b136821..3db4d075d1 100644
--- a/frontend/src/lib/uPlotV2/config/__tests__/UPlotAxisBuilder.test.ts
+++ b/frontend/src/lib/uPlotV2/config/__tests__/UPlotAxisBuilder.test.ts
@@ -1,5 +1,4 @@
import { getToolTipValue } from 'components/Graph/yAxisConfig';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import { uPlotXAxisValuesFormat } from 'lib/uPlotLib/utils/constants';
import type uPlot from 'uplot';
@@ -137,11 +136,11 @@ describe('UPlotAxisBuilder', () => {
});
});
- it('uses time-based X-axis values formatter for time-series like panels', () => {
+ it('uses time-based X-axis values formatter when the caller declares a time axis', () => {
const builder = new UPlotAxisBuilder(
createAxisProps({
scaleKey: 'x',
- panelType: PANEL_TYPES.TIME_SERIES,
+ isTimeAxis: true,
}),
);
@@ -150,11 +149,11 @@ describe('UPlotAxisBuilder', () => {
expect(config.values).toBe(uPlotXAxisValuesFormat);
});
- it('does not attach X-axis datetime formatter when panel type is not supported', () => {
+ it('does not attach X-axis datetime formatter for a non-time axis', () => {
const builder = new UPlotAxisBuilder(
createAxisProps({
scaleKey: 'x',
- panelType: PANEL_TYPES.LIST, // not in PANEL_TYPES_WITH_X_AXIS_DATETIME_FORMAT
+ isTimeAxis: false,
}),
);
@@ -290,22 +289,9 @@ describe('UPlotAxisBuilder', () => {
expect(config.space).toBe(50);
});
- it('includes PANEL_TYPES.BAR and PANEL_TYPES.TIME_SERIES in X-axis datetime formatter', () => {
- const barBuilder = new UPlotAxisBuilder(
- createAxisProps({
- scaleKey: 'x',
- panelType: PANEL_TYPES.BAR,
- }),
- );
- expect(barBuilder.getConfig().values).toBe(uPlotXAxisValuesFormat);
-
- const timeSeriesBuilder = new UPlotAxisBuilder(
- createAxisProps({
- scaleKey: 'x',
- panelType: PANEL_TYPES.TIME_SERIES,
- }),
- );
- expect(timeSeriesBuilder.getConfig().values).toBe(uPlotXAxisValuesFormat);
+ it('omits the X-axis datetime formatter when no time axis is declared', () => {
+ const builder = new UPlotAxisBuilder(createAxisProps({ scaleKey: 'x' }));
+ expect(builder.getConfig().values).toBeUndefined();
});
it('should return the existing size when cycleNum > 1', () => {
diff --git a/frontend/src/lib/uPlotV2/config/types.ts b/frontend/src/lib/uPlotV2/config/types.ts
index a699d0b5c5..af3e38d952 100644
--- a/frontend/src/lib/uPlotV2/config/types.ts
+++ b/frontend/src/lib/uPlotV2/config/types.ts
@@ -1,5 +1,4 @@
import { PrecisionOption } from 'components/Graph/types';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import uPlot, { Series } from 'uplot';
import { ThresholdsDrawHookOptions } from '../hooks/types';
@@ -53,31 +52,51 @@ export interface ConfigBuilderProps {
* Props for configuring an axis
*/
export interface AxisProps {
+ /** Scale this axis is drawn against — `'x'` / `'y'`, matching an `addScale` key. Also
+ * selects the default tick formatter and sizing (x: time, y: value + unit). */
scaleKey: string;
+ /** Axis title drawn alongside the ticks; omitted when there's nothing to name. */
label?: string;
+ /** Render the axis at all; false keeps the scale but draws no ticks or labels. */
show?: boolean;
- side?: 0 | 1 | 2 | 3; // top, right, bottom, left
+ /** Which edge of the plot the axis sits on: 0 | 1 | 2 | 3 — top, right, bottom, left. */
+ side?: 0 | 1 | 2 | 3;
+ /** Tick/label color. Defaults to black or white from `isDarkMode`. */
stroke?: string;
+ /** Partial override of the grid lines; unset keys fall back to the theme defaults. */
grid?: {
stroke?: string;
width?: number;
show?: boolean;
};
+ /** Partial override of the tick marks; provided as-is to uPlot when set. */
ticks?: {
stroke?: string;
width?: number;
show?: boolean;
size?: number;
};
+ /** Explicit tick formatter, replacing the scale's default (time / unit-formatted). */
values?: uPlot.Axis.Values;
+ /** Pixels between the ticks and their labels; also feeds the y axis width calculation. */
gap?: number;
+ /** Explicit axis thickness. Left unset, the y axis sizes itself to its widest label. */
size?: uPlot.Axis.Size;
- formatValue?: (v: number) => string;
- space?: number; // Space for log scale axes
+ /** Minimum pixels between ticks, capping how many uPlot draws. For log scale axes. */
+ space?: number;
+ /** Picks the dark or light default for stroke and grid color. */
isDarkMode?: boolean;
+ /** Axis is on a log scale — thins the grid lines to keep dense decades readable. */
isLogScale?: boolean;
+ /** Unit the y axis ticks are formatted in (`spec.formatting.unit`). */
yAxisUnit?: string;
- panelType?: PANEL_TYPES;
+ /**
+ * X axis carries timestamps, so its ticks format as dates/times. Declared by the caller
+ * rather than inferred from a panel type — a chart whose x axis is buckets or categories
+ * (histogram) leaves it off.
+ */
+ isTimeAxis?: boolean;
+ /** Decimal places for y axis tick values; unset lets the unit formatter decide. */
decimalPrecision?: PrecisionOption;
}
diff --git a/frontend/src/lib/visualization/panels/utils/baseConfigBuilder.ts b/frontend/src/lib/visualization/panels/utils/baseConfigBuilder.ts
index 240e82e002..96cd1c19a0 100644
--- a/frontend/src/lib/visualization/panels/utils/baseConfigBuilder.ts
+++ b/frontend/src/lib/visualization/panels/utils/baseConfigBuilder.ts
@@ -14,6 +14,7 @@ import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
import uPlot from 'uplot';
import { PanelMode } from 'lib/visualization/panels/types';
+import { plotsTimeOnXAxis } from 'lib/visualization/panels/utils/panelAxis';
export interface BaseConfigBuilderProps {
id: string;
@@ -124,7 +125,7 @@ export function buildBaseConfig({
side: 2,
isDarkMode,
isLogScale,
- panelType,
+ isTimeAxis: plotsTimeOnXAxis(panelType),
});
builder.addAxis({
@@ -134,7 +135,6 @@ export function buildBaseConfig({
isDarkMode,
isLogScale,
yAxisUnit,
- panelType,
});
return builder;
diff --git a/frontend/src/lib/visualization/panels/utils/panelAxis.ts b/frontend/src/lib/visualization/panels/utils/panelAxis.ts
new file mode 100644
index 0000000000..2ab4f6760b
--- /dev/null
+++ b/frontend/src/lib/visualization/panels/utils/panelAxis.ts
@@ -0,0 +1,9 @@
+import { PANEL_TYPES } from 'constants/queryBuilder';
+
+/**
+ * Whether the panel type plots time on X. Graph and bar do; the rest drawn through
+ * `buildBaseConfig` — histogram buckets, billing categories — plot a value there instead.
+ */
+export function plotsTimeOnXAxis(panelType: PANEL_TYPES): boolean {
+ return panelType === PANEL_TYPES.TIME_SERIES || panelType === PANEL_TYPES.BAR;
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.tsx
index 954ccc7579..b61b8e22d5 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.tsx
@@ -13,7 +13,6 @@ import type { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.sche
import PromQLIcon from 'assets/Dashboard/PromQl';
import { QueryBuilderV2 } from 'components/QueryBuilderV2/QueryBuilderV2';
import TextToolTip from 'components/TextToolTip';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import ClickHouseQueryContainer from 'container/QueryBuilder/rawQueryEditors/ClickHouse';
import PromQLQueryContainer from 'container/QueryBuilder/rawQueryEditors/PromQL';
import RunQueryBtn from 'container/QueryBuilder/components/RunQueryBtn/RunQueryBtn';
@@ -64,8 +63,12 @@ function PanelEditorQueryBuilder({
footer,
stickyHeader = true,
}: PanelEditorQueryBuilderProps): JSX.Element {
- // The shared QueryBuilderV2 / list-view checks still speak the legacy PANEL_TYPES.
+ // The shared QueryBuilderV2 provider still speaks the legacy PANEL_TYPES; what the
+ // builder offers for this kind comes from the kind's own declaration.
const panelType = PANEL_KIND_TO_PANEL_TYPE[panelKind];
+ // Raw rows: the builder drops its aggregation controls, and with them the trace
+ // operator that combines aggregated trace queries (V1 parity).
+ const isListViewPanel = panelKind === 'signoz/ListPanel';
const { currentQuery, redirectWithQueryBuilderData } = useQueryBuilder();
const isDarkMode = useIsDarkMode();
@@ -112,9 +115,9 @@ function PanelEditorQueryBuilder({
<QueryBuilderV2
panelType={panelType}
filterConfigs={filterConfigs}
- showTraceOperator={panelType !== PANEL_TYPES.LIST}
+ showTraceOperator={!isListViewPanel}
version="v3"
- isListViewPanel={panelType === PANEL_TYPES.LIST}
+ isListViewPanel={isListViewPanel}
queryComponents={{}}
signalSourceChangeEnabled
savePreviousQuery
@@ -148,7 +151,7 @@ function PanelEditorQueryBuilder({
),
children: queryTypeComponents[queryType].component,
}));
- }, [panelKind, panelType, filterConfigs, isDarkMode]);
+ }, [panelKind, panelType, filterConfigs, isDarkMode, isListViewPanel]);
return (
<div
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/__tests__/PanelEditorQueryBuilder.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/__tests__/PanelEditorQueryBuilder.test.tsx
index 9be326d792..023c8be1e4 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/__tests__/PanelEditorQueryBuilder.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/__tests__/PanelEditorQueryBuilder.test.tsx
@@ -60,6 +60,7 @@ function renderBuilder(
function lastQueryBuilderProps(): {
panelType: string;
isListViewPanel: boolean;
+ showTraceOperator: boolean;
filterConfigs: unknown;
} {
const calls = mockQueryBuilderV2.mock.calls;
@@ -115,6 +116,9 @@ describe('PanelEditorQueryBuilder field visibility (driven by the capabilities g
const props = lastQueryBuilderProps();
expect(props.panelType).toBe('graph');
expect(props.isListViewPanel).toBe(false);
+ // The trace operator combines aggregated trace queries, so it rides along with
+ // the aggregation controls.
+ expect(props.showTraceOperator).toBe(true);
expect(props.filterConfigs).toStrictEqual({});
});
@@ -124,6 +128,7 @@ describe('PanelEditorQueryBuilder field visibility (driven by the capabilities g
const props = lastQueryBuilderProps();
expect(props.panelType).toBe('list');
expect(props.isListViewPanel).toBe(true);
+ expect(props.showTraceOperator).toBe(false);
expect(props.filterConfigs).toStrictEqual({
stepInterval: { isHidden: true, isDisabled: true },
having: { isHidden: true, isDisabled: true },
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/PlotTag.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/PlotTag.tsx
index 4a35c437be..38a03d13b0 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/PlotTag.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/PlotTag.tsx
@@ -1,26 +1,14 @@
import { Spline } from '@signozhq/icons';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import QueryTypeTag from 'components/QueryTypeTag/QueryTypeTag';
import { EQueryType } from 'types/common/dashboard';
interface PlotTagProps {
- /** Authoring mode of the panel's query; undefined when no query exists yet. */
queryType: EQueryType | undefined;
- panelType: PANEL_TYPES;
className?: string;
}
-/**
- * "Plotted with <query mode>" chip for the editor preview; V2 counterpart of V1's
- * PlotTag (duplicated per the split policy). Hidden for list panels and before a
- * query exists, where the mode is irrelevant.
- */
-function PlotTag({
- queryType,
- panelType,
- className,
-}: PlotTagProps): JSX.Element | null {
- if (queryType === undefined || panelType === PANEL_TYPES.LIST) {
+function PlotTag({ queryType, className }: PlotTagProps): JSX.Element | null {
+ if (queryType === undefined) {
return null;
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.tsx
index 61f333e368..8d367a6bf8 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.tsx
@@ -7,7 +7,6 @@ import PanelBody from 'pages/DashboardPage/DashboardContainer/PanelsAndSectionsL
import PanelHeader from 'pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeader';
import type { AnyPanelInteractionProps } from 'pages/DashboardPage/DashboardContainer/Panels/types/interactions';
import type { RenderablePanelDefinition } from 'pages/DashboardPage/DashboardContainer/Panels/types/panelDefinition';
-import { PANEL_KIND_TO_PANEL_TYPE } from 'pages/DashboardPage/DashboardContainer/Panels/types/panelKind';
import type { DashboardPreference } from 'pages/DashboardPage/DashboardContainer/Panels/types/rendererProps';
import { getPanelQueryType } from 'pages/DashboardPage/DashboardContainer/Panels/utils/getPanelQueryType';
import type {
@@ -72,7 +71,6 @@ function PreviewPane({
onClick,
enableDrillDown,
}: PreviewPaneProps): JSX.Element {
- const panelType = PANEL_KIND_TO_PANEL_TYPE[panel.spec.plugin.kind];
const queryType = getPanelQueryType(panel);
// Search term is ephemeral preview state, threaded to header + renderer but
@@ -84,11 +82,7 @@ function PreviewPane({
<div className={styles.preview}>
{!hideHeader && (
<div className={styles.header}>
- <PlotTag
- queryType={queryType}
- panelType={panelType}
- className={styles.queryType}
- />
+ <PlotTag queryType={queryType} className={styles.queryType} />
<div className={styles.dateTimeSelector}>
<DateTimeSelectionV2 showAutoRefresh hideShareModal />
</div>
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/__tests__/PlotTag.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/__tests__/PlotTag.test.tsx
index 894b5fc4aa..f439a2b3b1 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/__tests__/PlotTag.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/PreviewPane/__tests__/PlotTag.test.tsx
@@ -1,30 +1,17 @@
import { render, screen } from '@testing-library/react';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import { EQueryType } from 'types/common/dashboard';
import PlotTag from '../PlotTag';
describe('PlotTag', () => {
it('renders the resolved query mode', () => {
- render(
- <PlotTag queryType={EQueryType.PROM} panelType={PANEL_TYPES.TIME_SERIES} />,
- );
+ render(<PlotTag queryType={EQueryType.PROM} />);
expect(screen.getByTestId('panel-editor-plot-tag')).toBeInTheDocument();
expect(screen.getByText('PromQL')).toBeInTheDocument();
});
it('renders nothing when there is no query yet', () => {
- render(<PlotTag queryType={undefined} panelType={PANEL_TYPES.TIME_SERIES} />);
- expect(screen.queryByTestId('panel-editor-plot-tag')).not.toBeInTheDocument();
- });
-
- it('renders nothing for list panels (query mode is irrelevant)', () => {
- render(
- <PlotTag
- queryType={EQueryType.QUERY_BUILDER}
- panelType={PANEL_TYPES.LIST}
- />,
- );
+ render(<PlotTag queryType={undefined} />);
expect(screen.queryByTestId('panel-editor-plot-tag')).not.toBeInTheDocument();
});
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/usePanelEditSession.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/usePanelEditSession.ts
index 4ab408b579..cba82b0d0b 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/usePanelEditSession.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/usePanelEditSession.ts
@@ -4,7 +4,10 @@ import type {
TelemetrytypesSignalDTO,
} from 'api/generated/services/sigNoz.schemas';
import type { PANEL_TYPES } from 'constants/queryBuilder';
-import { getPanelDefinition } from 'pages/DashboardPage/DashboardContainer/Panels/registry';
+import {
+ getPanelDefinition,
+ isPanelKindSupported,
+} from 'pages/DashboardPage/DashboardContainer/Panels/registry';
import type { RenderablePanelDefinition } from 'pages/DashboardPage/DashboardContainer/Panels/types/panelDefinition';
import {
PANEL_KIND_TO_PANEL_TYPE,
@@ -91,8 +94,9 @@ export function usePanelEditSession({
const query = usePanelQuery({
panel: draft,
panelId,
+ queryCapabilities: panelDefinition.queryCapabilities,
time,
- enabled: !!panelDefinition,
+ enabled: isPanelKindSupported(panelKind),
});
const { runQuery, isQueryDirty, buildSaveSpec } = usePanelEditorQuerySync({
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/usePanelTypeSwitch.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/usePanelTypeSwitch.ts
index f663a05685..74cc0fc9f2 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/usePanelTypeSwitch.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/usePanelTypeSwitch.ts
@@ -6,7 +6,7 @@ import type {
DashboardtypesQueryDTO,
TelemetrytypesSignalDTO,
} from 'api/generated/services/sigNoz.schemas';
-import { PANEL_TYPES } from 'constants/queryBuilder';
+import type { PANEL_TYPES } from 'constants/queryBuilder';
import {
handleQueryChange,
type PartialPanelTypes,
@@ -146,7 +146,7 @@ export function usePanelTypeSwitch({
);
// Match a fresh list panel's default order so the builder's Order By isn't empty.
const nextQuery =
- newPanelType === PANEL_TYPES.LIST
+ newKind === 'signoz/ListPanel'
? withDefaultListOrder(transformed)
: transformed;
const signal = getBuilderQueries(currentSpec.queries)[0]
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/__tests__/capabilities.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/__tests__/capabilities.test.ts
index 93e0424c7c..bd584ad69d 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/__tests__/capabilities.test.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/__tests__/capabilities.test.ts
@@ -1,7 +1,14 @@
-import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ Querybuildertypesv5RequestTypeDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { OPERATORS } from 'constants/queryBuilder';
import { EQueryType } from 'types/common/dashboard';
+import { UNSUPPORTED_PANEL } from '../kinds/UnsupportedPanel/definition';
+import { getPanelDefinition, isPanelKindSupported } from '../registry';
+import type { PanelQueryCapabilities } from '../types/panelCapabilities';
+import { NO_PANEL_ACTIONS } from '../types/panelDefinition';
import {
getHiddenQueryBuilderFields,
getSupportedQueryTypes,
@@ -15,6 +22,7 @@ import type { PanelKind } from '../types/panelKind';
const { QUERY_BUILDER, CLICKHOUSE, PROM } = EQueryType;
const { logs, traces, metrics } = TelemetrytypesSignalDTO;
+const { time_series, scalar, raw } = Querybuildertypesv5RequestTypeDTO;
const EXPECTED_QUERY_TYPES: Record<PanelKind, EQueryType[]> = {
'signoz/TimeSeriesPanel': [QUERY_BUILDER, CLICKHOUSE, PROM],
@@ -37,9 +45,117 @@ const EXPECTED_SIGNALS: Record<PanelKind, TelemetrytypesSignalDTO[]> = {
'signoz/ListPanel': [logs, traces],
};
+// Exhaustive over PanelKind, so a new kind can't ship without stating how its request is
+// shaped — the check that used to be implicit in a legacy PANEL_TYPES switch.
+const EXPECTED_QUERY_CAPABILITIES: Record<PanelKind, PanelQueryCapabilities> = {
+ 'signoz/TimeSeriesPanel': {
+ requestType: time_series,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
+ // Bar bins client-side, so it asks for a widened step interval over a raw series.
+ 'signoz/BarChartPanel': {
+ requestType: time_series,
+ formatTableResultForUI: false,
+ bucketedStepInterval: true,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
+ 'signoz/HistogramPanel': {
+ requestType: time_series,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
+ 'signoz/NumberPanel': {
+ requestType: scalar,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
+ 'signoz/PieChartPanel': {
+ requestType: scalar,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
+ // Only Table asks the server to transpose its scalar result into UI rows.
+ 'signoz/TablePanel': {
+ requestType: scalar,
+ formatTableResultForUI: true,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
+ // Only List reads raw rows, pages them server-side, and needs an order tiebreaker.
+ 'signoz/ListPanel': {
+ requestType: raw,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: true,
+ serverPaginated: true,
+ },
+};
+
const ALL_KINDS = Object.keys(EXPECTED_QUERY_TYPES) as PanelKind[];
describe('panel capabilities guard', () => {
+ describe('query capabilities', () => {
+ it.each(ALL_KINDS)('declares how %s shapes its request', (kind) => {
+ expect(getPanelDefinition(kind).queryCapabilities).toStrictEqual(
+ EXPECTED_QUERY_CAPABILITIES[kind],
+ );
+ });
+ });
+
+ // A dashboard spec written by a newer SigNoz can name a kind this build has no
+ // definition for. The registry answers with UNSUPPORTED_PANEL rather than nothing, so
+ // every guard below reads it without first proving a definition exists.
+ describe('a kind this build cannot render', () => {
+ const unknownKind = 'signoz/SomeFutureKindPanel' as PanelKind;
+
+ it('is not reported as supported', () => {
+ expect(isPanelKindSupported(unknownKind)).toBe(false);
+ expect(isPanelKindSupported('signoz/TimeSeriesPanel')).toBe(true);
+ });
+
+ it('still resolves to a definition', () => {
+ expect(getPanelDefinition(unknownKind)).toBe(UNSUPPORTED_PANEL);
+ });
+
+ it('declares nothing, so it is never offered as authorable', () => {
+ expect(getSupportedSignals(unknownKind)).toStrictEqual([]);
+ expect(getSupportedQueryTypes(unknownKind)).toStrictEqual([]);
+ expect(isSignalSupported(unknownKind, logs)).toBe(false);
+ expect(
+ isPanelCombinationValid({ kind: unknownKind, queryType: QUERY_BUILDER }),
+ ).toBe(false);
+ expect(getHiddenQueryBuilderFields(unknownKind, logs)).toStrictEqual({});
+ expect(getPanelDefinition(unknownKind).sections).toStrictEqual([]);
+ });
+
+ it('offers no actions', () => {
+ expect(getPanelDefinition(unknownKind).actions).toStrictEqual(
+ NO_PANEL_ACTIONS,
+ );
+ expect(NO_PANEL_ACTIONS.view).toBe(false);
+ expect(NO_PANEL_ACTIONS.edit).toBe(false);
+ expect(NO_PANEL_ACTIONS.drilldown).toBe(false);
+ });
+
+ it('carries an inert query shape, so a stray request can do no harm', () => {
+ const { queryCapabilities } = getPanelDefinition(unknownKind);
+ expect(queryCapabilities.requestType).toBe(time_series);
+ expect(queryCapabilities.serverPaginated).toBe(false);
+ expect(queryCapabilities.formatTableResultForUI).toBe(false);
+ });
+ });
+
describe('query type support', () => {
it.each(ALL_KINDS)('declares the expected query types for %s', (kind) => {
expect(getSupportedQueryTypes(kind)).toStrictEqual(
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/components/NoData/NoData.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/components/NoData/NoData.tsx
index c3a8fca99c..4c263e2aca 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/components/NoData/NoData.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/components/NoData/NoData.tsx
@@ -20,8 +20,12 @@ interface NoDataProps {
isFetching?: boolean;
/** When provided, renders a Retry button that re-runs the query. */
onRetry?: () => void;
- /** Hides the global "Extend time range" action when this panel is locked to a fixed time preference. */
- panel?: DashboardtypesPanelDTO;
+ /**
+ * The panel this empty state stands in for. Every renderer has it, and it decides
+ * whether the global "Extend time range" action applies (a panel locked to a fixed
+ * time preference can't be widened by it) as well as what the action events report.
+ */
+ panel: DashboardtypesPanelDTO;
'data-testid'?: string;
}
@@ -43,19 +47,17 @@ function NoData({
const globalExtend = useExtendTimeWindow();
// The View modal's local extender wins; the global one only applies to a panel that
// follows the ambient window (a fixed preference can't be widened by it).
- const hasFixedTimePreference = panel
- ? panelHasFixedTimePreference(panel)
- : false;
const activeExtend =
- viewExtend ?? (hasFixedTimePreference ? undefined : globalExtend);
+ viewExtend ?? (panelHasFixedTimePreference(panel) ? undefined : globalExtend);
if (isFetching) {
return <PanelLoader />;
}
- const panelType = panel
- ? PANEL_KIND_TO_PANEL_TYPE[panel.spec.plugin.kind]
- : undefined;
+ // `panelType` stays on the event so existing reports keep resolving; `panelKind` is the
+ // V2 identity, and the only one that can tell two kinds sharing a panel type apart.
+ const panelKind = panel.spec.plugin.kind;
+ const panelType = PANEL_KIND_TO_PANEL_TYPE[panelKind];
const extendAction: PanelMessageAction | undefined =
activeExtend?.canExtend && activeExtend.actionLabel
@@ -65,6 +67,7 @@ function NoData({
void logEvent(DashboardDetailEvents.NoDataAction, {
action: 'extendTime',
panelType,
+ panelKind,
});
activeExtend.extend();
},
@@ -79,6 +82,7 @@ function NoData({
void logEvent(DashboardDetailEvents.NoDataAction, {
action: 'retry',
panelType,
+ panelKind,
});
onRetry();
},
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/components/NoData/__tests__/NoData.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/components/NoData/__tests__/NoData.test.tsx
index af5ed3cfb7..e977f306ed 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/components/NoData/__tests__/NoData.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/components/NoData/__tests__/NoData.test.tsx
@@ -33,7 +33,12 @@ function panelWith(
timePreference?: DashboardtypesTimePreferenceDTO,
): DashboardtypesPanelDTO {
return {
- spec: { plugin: { spec: { visualization: { timePreference } } } },
+ spec: {
+ plugin: {
+ kind: 'signoz/TimeSeriesPanel',
+ spec: { visualization: { timePreference } },
+ },
+ },
} as unknown as DashboardtypesPanelDTO;
}
@@ -44,7 +49,7 @@ describe('NoData', () => {
});
it('renders the empty-state title and hint', () => {
- render(<NoData />);
+ render(<NoData panel={panelWith()} />);
expect(screen.getByTestId('panel-no-data')).toBeInTheDocument();
expect(screen.getByText('No data in this time range')).toBeInTheDocument();
@@ -55,7 +60,7 @@ describe('NoData', () => {
it('offers to extend the window as the primary action', () => {
mockUseExtendTimeWindow.mockReturnValue(extender());
- render(<NoData />);
+ render(<NoData panel={panelWith()} />);
const action = screen.getByTestId('panel-no-data-action');
expect(action).toHaveTextContent('Extend time range');
@@ -68,7 +73,7 @@ describe('NoData', () => {
it('renders both Extend (primary) and Retry (secondary) when a retry handler is given', () => {
const onRetry = jest.fn();
mockUseExtendTimeWindow.mockReturnValue(extender());
- render(<NoData onRetry={onRetry} />);
+ render(<NoData onRetry={onRetry} panel={panelWith()} />);
expect(screen.getByTestId('panel-no-data-action')).toHaveTextContent(
'Extend time range',
@@ -82,7 +87,7 @@ describe('NoData', () => {
it('falls back to Retry as the sole action when the window cannot be widened', () => {
const onRetry = jest.fn();
- render(<NoData onRetry={onRetry} />);
+ render(<NoData onRetry={onRetry} panel={panelWith()} />);
const action = screen.getByTestId('panel-no-data-action');
expect(action).toHaveTextContent('Retry');
@@ -101,7 +106,7 @@ describe('NoData', () => {
useViewPanelStore.setState({
viewPanelExtendWindow: extender({ extend: storeExtend }),
});
- render(<NoData />);
+ render(<NoData panel={panelWith()} />);
fireEvent.click(screen.getByTestId('panel-no-data-action'));
expect(storeExtend).toHaveBeenCalledTimes(1);
@@ -109,7 +114,7 @@ describe('NoData', () => {
});
it('renders no action when nothing can be widened and no retry handler', () => {
- render(<NoData />);
+ render(<NoData panel={panelWith()} />);
expect(screen.queryByTestId('panel-no-data-action')).not.toBeInTheDocument();
expect(
@@ -119,7 +124,7 @@ describe('NoData', () => {
it('shows the panel loader (not the empty state) while refetching', () => {
mockUseExtendTimeWindow.mockReturnValue(extender());
- render(<NoData isFetching />);
+ render(<NoData isFetching panel={panelWith()} />);
expect(screen.getByTestId('panel-loading')).toBeInTheDocument();
expect(screen.queryByTestId('panel-no-data')).not.toBeInTheDocument();
@@ -128,7 +133,7 @@ describe('NoData', () => {
it('honours the data-testid override for the number panel', () => {
mockUseExtendTimeWindow.mockReturnValue(extender());
- render(<NoData data-testid="number-panel-no-data" />);
+ render(<NoData data-testid="number-panel-no-data" panel={panelWith()} />);
expect(screen.getByTestId('number-panel-no-data')).toBeInTheDocument();
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/definition.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/definition.ts
index 1d99f65ad0..1e5fbad423 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/definition.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/definition.ts
@@ -1,7 +1,10 @@
import type { PanelDefinition } from '../../types/panelDefinition';
import Renderer from './Renderer';
import { sections } from './sections';
-import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ Querybuildertypesv5RequestTypeDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { EQueryType } from 'types/common/dashboard';
export const definition: PanelDefinition<'signoz/BarChartPanel'> = {
@@ -20,6 +23,15 @@ export const definition: PanelDefinition<'signoz/BarChartPanel'> = {
EQueryType.PROM,
],
queryBuilderFields: {},
+ // Bars are binned client-side from a raw time series, so the request asks for a
+ // step interval wide enough to keep the bar count readable (V1 parity).
+ queryCapabilities: {
+ requestType: Querybuildertypesv5RequestTypeDTO.time_series,
+ formatTableResultForUI: false,
+ bucketedStepInterval: true,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
actions: {
view: true,
edit: true,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/buildConfig.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/buildConfig.ts
index 2cb2f09b33..264f40427c 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/buildConfig.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/buildConfig.ts
@@ -1,33 +1,22 @@
import type { DashboardtypesBarChartPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
-import { Timezone } from 'components/CustomTimePicker/timezoneUtils';
-import { PANEL_TYPES } from 'constants/queryBuilder';
-import { PanelMode } from 'lib/visualization/panels/types';
-import { buildBaseConfig } from 'pages/DashboardPage/DashboardContainer/Panels/utils/baseConfigBuilder';
+import {
+ buildBaseConfig,
+ type TimeAxisChromeArgs,
+} from 'pages/DashboardPage/DashboardContainer/Panels/utils/baseConfigBuilder';
import { resolveSeriesLabelV5 } from 'pages/DashboardPage/DashboardContainer/Panels/utils/resolveSeriesLabel';
import type { PanelSeries } from 'pages/DashboardPage/DashboardContainer/queryV5/types';
import { toClickPluginPayload } from 'pages/DashboardPage/DashboardContainer/queryV5/uplotData';
import getLabelName from 'lib/getLabelName';
-import { OnClickPluginOpts } from 'lib/uPlotLib/plugins/onClickPlugin';
import { DrawStyle } from 'lib/uPlotV2/config/types';
import { UPlotConfigBuilder } from 'lib/uPlotV2/config/UPlotConfigBuilder';
import type { BuilderQuery } from 'types/api/v5/queryRange';
-export interface BuildBarChartConfigArgs {
- panelId: string;
+export interface BuildBarChartConfigArgs extends TimeAxisChromeArgs {
spec: DashboardtypesBarChartPanelSpecDTO;
/** Flat list of builder queries (see `getBuilderQueries`); powers per-query legend resolution. */
builderQueries: BuilderQuery[];
/** Flattened V5 series (see `flattenTimeSeries`). */
series: PanelSeries[];
- /** Per-query step intervals from the response exec stats. */
- stepIntervals?: Record<string, number>;
- isDarkMode: boolean;
- timezone: Timezone;
- panelMode: PanelMode;
- onDragSelect?: (start: number, end: number) => void;
- onClick?: OnClickPluginOpts['onClick'];
- minTimeScale?: number;
- maxTimeScale?: number;
}
/** Builds a `UPlotConfigBuilder` for a Bar chart panel: shared scaffolding, optional stacking, one bar series per result. */
@@ -47,7 +36,7 @@ export function buildBarChartConfig({
}: BuildBarChartConfigArgs): UPlotConfigBuilder {
const builder = buildBaseConfig({
panelId,
- panelType: PANEL_TYPES.BAR,
+ isTimeAxis: true,
isDarkMode,
timezone,
panelMode,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/HistogramPanel/definition.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/HistogramPanel/definition.ts
index 276799fab4..26a5c9818d 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/HistogramPanel/definition.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/HistogramPanel/definition.ts
@@ -1,7 +1,10 @@
import type { PanelDefinition } from '../../types/panelDefinition';
import Renderer from './Renderer';
import { sections } from './sections';
-import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ Querybuildertypesv5RequestTypeDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { EQueryType } from 'types/common/dashboard';
export const definition: PanelDefinition<'signoz/HistogramPanel'> = {
@@ -20,6 +23,15 @@ export const definition: PanelDefinition<'signoz/HistogramPanel'> = {
EQueryType.PROM,
],
queryBuilderFields: {},
+ // Buckets are computed client-side from the raw series, so the request is a plain
+ // time series — the bucket count is a display concern, not a query one.
+ queryCapabilities: {
+ requestType: Querybuildertypesv5RequestTypeDTO.time_series,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
actions: {
view: true,
edit: true,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/HistogramPanel/utils/buildConfig.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/HistogramPanel/utils/buildConfig.ts
index 0bd144b0aa..35b8493bad 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/HistogramPanel/utils/buildConfig.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/HistogramPanel/utils/buildConfig.ts
@@ -1,8 +1,8 @@
import type { DashboardtypesHistogramPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
-import { Timezone } from 'components/CustomTimePicker/timezoneUtils';
-import { PANEL_TYPES } from 'constants/queryBuilder';
-import { PanelMode } from 'lib/visualization/panels/types';
-import { buildBaseConfig } from 'pages/DashboardPage/DashboardContainer/Panels/utils/baseConfigBuilder';
+import {
+ buildBaseConfig,
+ type PanelChromeArgs,
+} from 'pages/DashboardPage/DashboardContainer/Panels/utils/baseConfigBuilder';
import { resolveSeriesLabelV5 } from 'pages/DashboardPage/DashboardContainer/Panels/utils/resolveSeriesLabel';
import type { PanelSeries } from 'pages/DashboardPage/DashboardContainer/queryV5/types';
import getLabelName from 'lib/getLabelName';
@@ -16,16 +16,12 @@ const BAR_WIDTH_FACTOR = 1;
const MERGED_SERIES_LINE_COLOR = '#3f5ecc';
const MERGED_SERIES_FILL_COLOR = '#4E74F8';
-export interface BuildHistogramConfigArgs {
- panelId: string;
+export interface BuildHistogramConfigArgs extends PanelChromeArgs {
spec: DashboardtypesHistogramPanelSpecDTO;
/** Builder queries on this panel — used to resolve per-series labels. */
builderQueries: BuilderQuery[];
/** Flattened V5 series (see `flattenTimeSeries`). */
series: PanelSeries[];
- isDarkMode: boolean;
- timezone: Timezone;
- panelMode: PanelMode;
}
/**
@@ -44,7 +40,7 @@ export function buildHistogramConfig({
}: BuildHistogramConfigArgs): UPlotConfigBuilder {
const builder = buildBaseConfig({
panelId,
- panelType: PANEL_TYPES.HISTOGRAM,
+ isTimeAxis: false,
isDarkMode,
timezone,
panelMode,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/ListPanel/definition.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/ListPanel/definition.ts
index 39fe40923f..62af5fcda2 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/ListPanel/definition.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/ListPanel/definition.ts
@@ -1,7 +1,10 @@
import type { PanelDefinition } from '../../types/panelDefinition';
import Renderer from './Renderer';
import { sections } from './sections';
-import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ Querybuildertypesv5RequestTypeDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { OPERATORS } from 'constants/queryBuilder';
import { EQueryType } from 'types/common/dashboard';
@@ -30,6 +33,15 @@ export const definition: PanelDefinition<'signoz/ListPanel'> = {
},
},
sections,
+ // The only kind reading raw rows: they page server-side, and the sort needs a
+ // tiebreaker so a duplicated sort key can't repeat or skip a row across pages.
+ queryCapabilities: {
+ requestType: Querybuildertypesv5RequestTypeDTO.raw,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: true,
+ serverPaginated: true,
+ },
actions: {
view: true,
edit: true,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/NumberPanel/definition.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/NumberPanel/definition.ts
index 5c2b7bbe94..2a784a0bc7 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/NumberPanel/definition.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/NumberPanel/definition.ts
@@ -1,7 +1,10 @@
import type { PanelDefinition } from '../../types/panelDefinition';
import Renderer from './Renderer';
import { sections } from './sections';
-import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ Querybuildertypesv5RequestTypeDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { EQueryType } from 'types/common/dashboard';
export const definition: PanelDefinition<'signoz/NumberPanel'> = {
@@ -20,6 +23,13 @@ export const definition: PanelDefinition<'signoz/NumberPanel'> = {
EQueryType.PROM,
],
queryBuilderFields: {},
+ queryCapabilities: {
+ requestType: Querybuildertypesv5RequestTypeDTO.scalar,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
actions: {
view: true,
edit: true,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/PieChartPanel/definition.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/PieChartPanel/definition.ts
index 2fd72f1db3..05d87c03d2 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/PieChartPanel/definition.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/PieChartPanel/definition.ts
@@ -1,7 +1,10 @@
import type { PanelDefinition } from '../../types/panelDefinition';
import Renderer from './Renderer';
import { sections } from './sections';
-import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ Querybuildertypesv5RequestTypeDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { EQueryType } from 'types/common/dashboard';
export const definition: PanelDefinition<'signoz/PieChartPanel'> = {
@@ -16,6 +19,13 @@ export const definition: PanelDefinition<'signoz/PieChartPanel'> = {
],
supportedQueryTypes: [EQueryType.QUERY_BUILDER, EQueryType.CLICKHOUSE],
queryBuilderFields: {},
+ queryCapabilities: {
+ requestType: Querybuildertypesv5RequestTypeDTO.scalar,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
actions: {
view: true,
edit: true,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TablePanel/definition.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TablePanel/definition.ts
index 478a845def..f756aaa72c 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TablePanel/definition.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TablePanel/definition.ts
@@ -1,7 +1,10 @@
import type { PanelDefinition } from '../../types/panelDefinition';
import Renderer from './Renderer';
import { sections } from './sections';
-import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ Querybuildertypesv5RequestTypeDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { EQueryType } from 'types/common/dashboard';
export const definition: PanelDefinition<'signoz/TablePanel'> = {
@@ -16,6 +19,14 @@ export const definition: PanelDefinition<'signoz/TablePanel'> = {
],
supportedQueryTypes: [EQueryType.QUERY_BUILDER, EQueryType.CLICKHOUSE],
queryBuilderFields: {},
+ // The only kind that asks the server to transpose its scalar result into UI rows.
+ queryCapabilities: {
+ requestType: Querybuildertypesv5RequestTypeDTO.scalar,
+ formatTableResultForUI: true,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
// Tables carry tabular data worth exporting (V1 parity: download is table-only).
actions: {
view: true,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/definition.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/definition.ts
index 0217960fcf..b03485d934 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/definition.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/definition.ts
@@ -1,7 +1,10 @@
import type { PanelDefinition } from '../../types/panelDefinition';
import Renderer from './Renderer';
import { sections } from './sections';
-import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ Querybuildertypesv5RequestTypeDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { EQueryType } from 'types/common/dashboard';
export const definition: PanelDefinition<'signoz/TimeSeriesPanel'> = {
@@ -20,6 +23,13 @@ export const definition: PanelDefinition<'signoz/TimeSeriesPanel'> = {
EQueryType.PROM,
],
queryBuilderFields: {},
+ queryCapabilities: {
+ requestType: Querybuildertypesv5RequestTypeDTO.time_series,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
actions: {
view: true,
edit: true,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/buildConfig.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/buildConfig.ts
index 8cc944ed5e..97cba6f40c 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/buildConfig.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/buildConfig.ts
@@ -1,10 +1,8 @@
import type { DashboardtypesTimeSeriesPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
-import { Timezone } from 'components/CustomTimePicker/timezoneUtils';
-import { PANEL_TYPES } from 'constants/queryBuilder';
-import { PanelMode } from 'lib/visualization/panels/types';
import {
buildBaseConfig,
minStepInterval,
+ type TimeAxisChromeArgs,
} from 'pages/DashboardPage/DashboardContainer/Panels/utils/baseConfigBuilder';
import {
FILL_MODE_MAP,
@@ -19,7 +17,6 @@ import {
toClickPluginPayload,
} from 'pages/DashboardPage/DashboardContainer/queryV5/uplotData';
import getLabelName from 'lib/getLabelName';
-import { OnClickPluginOpts } from 'lib/uPlotLib/plugins/onClickPlugin';
import {
DrawStyle,
FillMode,
@@ -31,22 +28,12 @@ import type { BuilderQuery } from 'types/api/v5/queryRange';
const DEFAULT_POINT_SIZE = 5;
-export interface BuildTimeSeriesConfigArgs {
- panelId: string;
+export interface BuildTimeSeriesConfigArgs extends TimeAxisChromeArgs {
spec: DashboardtypesTimeSeriesPanelSpecDTO;
/** Flat list of builder queries (see `getBuilderQueries`); powers per-query legend resolution. */
builderQueries: BuilderQuery[];
/** Flattened V5 series (see `flattenTimeSeries`). */
series: PanelSeries[];
- /** Per-query step intervals from the response exec stats. */
- stepIntervals?: Record<string, number>;
- isDarkMode: boolean;
- timezone: Timezone;
- panelMode: PanelMode;
- onDragSelect?: (start: number, end: number) => void;
- onClick?: OnClickPluginOpts['onClick'];
- minTimeScale?: number;
- maxTimeScale?: number;
}
/** Builds a `UPlotConfigBuilder` for a TimeSeries panel: shared scaffolding plus one series per result. */
@@ -66,7 +53,7 @@ export function buildTimeSeriesConfig({
}: BuildTimeSeriesConfigArgs): UPlotConfigBuilder {
const builder = buildBaseConfig({
panelId,
- panelType: PANEL_TYPES.TIME_SERIES,
+ isTimeAxis: true,
isDarkMode,
timezone,
panelMode,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/UnsupportedPanel/Renderer.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/UnsupportedPanel/Renderer.tsx
new file mode 100644
index 0000000000..69785380b1
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/UnsupportedPanel/Renderer.tsx
@@ -0,0 +1,26 @@
+import { CircleHelp } from '@signozhq/icons';
+
+import PanelMessage from '../../components/PanelMessage/PanelMessage';
+import PanelStyles from '../../panel.module.scss';
+
+/**
+ * Body for a panel whose kind this build has no renderer for — a spec written by a newer
+ * SigNoz names a visualization that didn't exist when this client shipped. Says so in
+ * place of the chart, so the panel keeps its slot in the layout instead of leaving a hole.
+ */
+function UnsupportedPanelRenderer(): JSX.Element {
+ return (
+ <div
+ data-testid="unsupported-panel-renderer"
+ className={PanelStyles.panelContainer}
+ >
+ <PanelMessage
+ icon={<CircleHelp size={18} />}
+ title="Unsupported panel type"
+ description="This panel was built with a newer version of SigNoz. Upgrade to view it."
+ />
+ </div>
+ );
+}
+
+export default UnsupportedPanelRenderer;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/UnsupportedPanel/definition.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/UnsupportedPanel/definition.ts
new file mode 100644
index 0000000000..fca95f1e6f
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/UnsupportedPanel/definition.ts
@@ -0,0 +1,34 @@
+import { Querybuildertypesv5RequestTypeDTO } from 'api/generated/services/sigNoz.schemas';
+
+import {
+ NO_PANEL_ACTIONS,
+ type RenderablePanelDefinition,
+} from '../../types/panelDefinition';
+import Renderer from './Renderer';
+
+/**
+ * Stand-in definition for a kind that isn't in the registry, so `getPanelDefinition`
+ * always resolves and no caller has to branch on a missing one. It declares nothing: no
+ * signals, no query types, no config sections and no actions — an unknown kind can't be
+ * queried, configured or acted on, only shown as unsupported.
+ *
+ * `kind` carries a sentinel that no API enum value can collide with; the cast is the one
+ * place this definition steps outside `PanelKind`.
+ */
+export const UNSUPPORTED_PANEL: RenderablePanelDefinition = {
+ kind: '<unsupported>' as RenderablePanelDefinition['kind'],
+ displayName: 'Unsupported panel',
+ Renderer,
+ sections: [],
+ supportedSignals: [],
+ supportedQueryTypes: [],
+ queryBuilderFields: {},
+ queryCapabilities: {
+ requestType: Querybuildertypesv5RequestTypeDTO.time_series,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
+ actions: NO_PANEL_ACTIONS,
+};
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/registry.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/registry.ts
index 4c3788c176..063febf4dd 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/registry.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/registry.ts
@@ -5,6 +5,7 @@ import { definition as PieChart } from './kinds/PieChartPanel/definition';
import { definition as TimeSeries } from './kinds/TimeSeriesPanel/definition';
import { definition as Table } from './kinds/TablePanel/definition';
import { definition as List } from './kinds/ListPanel/definition';
+import { UNSUPPORTED_PANEL } from './kinds/UnsupportedPanel/definition';
import type {
PanelRegistry,
RenderablePanelDefinition,
@@ -22,8 +23,24 @@ export const PANELS: PanelRegistry = {
[List.kind]: List,
};
+/**
+ * Whether this build can render the kind. `PanelKind` spans every kind the API declares,
+ * but a dashboard spec written by a newer SigNoz can name one this client has never heard
+ * of — so ask before doing work on a panel's behalf, such as fetching its data.
+ */
+export function isPanelKindSupported(kind: PanelKind): boolean {
+ return kind in PANELS;
+}
+
+/**
+ * The definition for a kind — always one. An unregistered kind resolves to
+ * {@link UNSUPPORTED_PANEL}, which declares no capabilities and renders as unsupported, so
+ * callers read a definition's fields without first proving it exists.
+ */
export function getPanelDefinition(kind: PanelKind): RenderablePanelDefinition {
// Single intentional cast widening the per-kind Renderer to the kind-agnostic
// prop surface (a per-kind renderer can't be statically validated against the union).
- return PANELS[kind] as RenderablePanelDefinition;
+ return (
+ (PANELS[kind] as RenderablePanelDefinition | undefined) ?? UNSUPPORTED_PANEL
+ );
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/panelCapabilities.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/panelCapabilities.ts
index a5d20aa2c7..d524e131a3 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/panelCapabilities.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/panelCapabilities.ts
@@ -1,4 +1,7 @@
-import type { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ Querybuildertypesv5RequestTypeDTO,
+ type TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
import type { QueryBuilderProps } from 'container/QueryBuilder/QueryBuilder.interfaces';
/**
@@ -18,3 +21,30 @@ export type FilterConfigsPartial = NonNullable<
export type QueryBuilderFieldRule = {
default?: FilterConfigsPartial;
} & Partial<Record<TelemetrytypesSignalDTO, FilterConfigsPartial>>;
+
+/**
+ * How a kind's query-range request is shaped. Declared per-kind in
+ * `kinds/<Kind>/definition.ts` and read through the capabilities guard, so no V2 code
+ * has to translate a panel kind into the legacy `PANEL_TYPES` enum to answer these.
+ */
+export interface PanelQueryCapabilities {
+ /** V5 request type the panel's data comes back as. */
+ requestType: Querybuildertypesv5RequestTypeDTO;
+ /** Server transposes the scalar result into UI table rows (`formatOptions.formatTableResultForUI`). */
+ formatTableResultForUI: boolean;
+ /**
+ * Widen the step interval to cap how many buckets come back — kinds that bin
+ * client-side from a raw time series rather than plotting every point.
+ */
+ bucketedStepInterval: boolean;
+ /**
+ * Append a deterministic tiebreaker to the query's `order` so offset paging over raw
+ * rows can't repeat or skip a row when the sort key has duplicates.
+ */
+ orderTiebreaker: boolean;
+ /**
+ * Rows page server-side via `offset`/`limit`. AND-ed at the call site with "the query
+ * carries no explicit limit" — an explicit limit means the user asked for a fixed set.
+ */
+ serverPaginated: boolean;
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/panelDefinition.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/panelDefinition.ts
index 930a852d60..c376a1b12b 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/panelDefinition.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/panelDefinition.ts
@@ -5,7 +5,10 @@ import type { EQueryType } from 'types/common/dashboard';
import type { SectionConfig } from './sections';
import type { AnyPanelInteractionProps } from './interactions';
import type { PanelKind } from './panelKind';
-import type { QueryBuilderFieldRule } from './panelCapabilities';
+import type {
+ PanelQueryCapabilities,
+ QueryBuilderFieldRule,
+} from './panelCapabilities';
import type { BaseRendererProps, PanelRendererProps } from './rendererProps';
/** Export formats offered under the single "Download" action. */
@@ -39,6 +42,24 @@ export interface PanelActionCapabilities {
drilldown: boolean;
}
+/**
+ * No actions at all — for a kind this build can't render, where every action would act on
+ * a panel body that isn't there. See `UNSUPPORTED_PANEL`.
+ */
+export const NO_PANEL_ACTIONS: PanelActionCapabilities = {
+ view: false,
+ edit: false,
+ clone: false,
+ download: {
+ [DownloadFormat.CSV]: false,
+ [DownloadFormat.PNG]: false,
+ [DownloadFormat.SVG]: false,
+ },
+ createAlert: false,
+ search: false,
+ drilldown: false,
+};
+
export interface PanelDefinition<K extends PanelKind = PanelKind> {
kind: K;
displayName: string;
@@ -50,6 +71,8 @@ export interface PanelDefinition<K extends PanelKind = PanelKind> {
supportedQueryTypes: EQueryType[];
/** Query-builder fields this kind hides/disables, optionally per signal (`{}` hides none). */
queryBuilderFields: QueryBuilderFieldRule;
+ /** How this kind's query-range request is shaped (request type, paging, result formatting). */
+ queryCapabilities: PanelQueryCapabilities;
actions: PanelActionCapabilities;
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/__tests__/buildDefaultQueries.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/__tests__/buildDefaultQueries.test.ts
index c52e16bd63..48160895fb 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/__tests__/buildDefaultQueries.test.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/__tests__/buildDefaultQueries.test.ts
@@ -1,7 +1,7 @@
import { buildDefaultQueries } from '../buildDefaultQueries';
describe('buildDefaultQueries', () => {
- it('seeds a List panel with a runnable logs query ordered by timestamp desc', () => {
+ it('seeds a list panel with a runnable logs query ordered by timestamp desc', () => {
const queries = buildDefaultQueries('signoz/ListPanel');
expect(queries).toHaveLength(1);
@@ -13,7 +13,7 @@ describe('buildDefaultQueries', () => {
expect(serialized.toLowerCase()).toContain('logs');
});
- it('seeds a List panel without a limit so it pages server-side by default', () => {
+ it('seeds a list panel without a limit so it pages server-side by default', () => {
const queries = buildDefaultQueries('signoz/ListPanel');
// A limit would make usePanelQuery treat the panel as a static, unpaged list.
@@ -21,7 +21,7 @@ describe('buildDefaultQueries', () => {
expect(spec.limit).toBeUndefined();
});
- it('seeds no query for non-List kinds (they seed from the builder)', () => {
+ it('seeds no query for plotted kinds (they seed from the builder)', () => {
expect(buildDefaultQueries('signoz/TimeSeriesPanel')).toStrictEqual([]);
expect(buildDefaultQueries('signoz/NumberPanel')).toStrictEqual([]);
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/baseConfigBuilder.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/baseConfigBuilder.ts
index 442214a678..f8d757fd3a 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/baseConfigBuilder.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/baseConfigBuilder.ts
@@ -3,7 +3,6 @@ import type {
DashboardtypesThresholdWithLabelDTO,
} from 'api/generated/services/sigNoz.schemas';
import { Timezone } from 'components/CustomTimePicker/timezoneUtils';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import { PanelMode } from 'lib/visualization/panels/types';
import onClickPlugin, {
OnClickPluginOpts,
@@ -26,7 +25,11 @@ import {
*/
export interface BuildBaseConfigArgs {
panelId: string;
- panelType: PANEL_TYPES;
+ /**
+ * X axis plots timestamps, so its ticks format as dates/times. Each kind states this
+ * for itself — a bucketed x axis (histogram) passes false.
+ */
+ isTimeAxis: boolean;
isDarkMode: boolean;
timezone: Timezone;
panelMode: PanelMode;
@@ -56,6 +59,18 @@ export interface BuildBaseConfigArgs {
onClick?: OnClickPluginOpts['onClick'];
}
+/** What a kind's build args pass straight through; the rest is derived from its spec. */
+export type PanelChromeArgs = Pick<
+ BuildBaseConfigArgs,
+ 'panelId' | 'isDarkMode' | 'timezone' | 'panelMode'
+>;
+
+export type TimeAxisChromeArgs = PanelChromeArgs &
+ Pick<
+ BuildBaseConfigArgs,
+ 'stepIntervals' | 'minTimeScale' | 'maxTimeScale' | 'onDragSelect' | 'onClick'
+ >;
+
/**
* Builds the panel-agnostic scaffolding of a uPlot chart (scales, thresholds,
* axes, drag-to-zoom, click plugin). Callers then `addSeries`/`addPlugin` on the
@@ -63,7 +78,7 @@ export interface BuildBaseConfigArgs {
*/
export function buildBaseConfig({
panelId,
- panelType,
+ isTimeAxis,
isDarkMode,
timezone,
panelMode,
@@ -133,7 +148,7 @@ export function buildBaseConfig({
side: 2,
isDarkMode,
isLogScale,
- panelType,
+ isTimeAxis,
});
builder.addAxis({
@@ -143,7 +158,6 @@ export function buildBaseConfig({
isDarkMode,
isLogScale,
yAxisUnit,
- panelType,
});
return builder;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/buildDefaultQueries.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/buildDefaultQueries.ts
index 08d25b6b68..1fcd11c1c6 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/buildDefaultQueries.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/buildDefaultQueries.ts
@@ -1,14 +1,15 @@
import type { DashboardtypesQueryDTO } from 'api/generated/services/sigNoz.schemas';
-import { listViewInitialLogQuery, PANEL_TYPES } from 'constants/queryBuilder';
+import { listViewInitialLogQuery } from 'constants/queryBuilder';
import { toPerses } from '../../queryV5/persesQueryAdapters';
import { PANEL_KIND_TO_PANEL_TYPE, type PanelKind } from '../types/panelKind';
-/** Seed query for a new panel. Only List needs one (logs, timestamp desc) so its
+/** Seed query for a new panel. Only a list panel needs one (logs, timestamp desc) so its
* preview runs on open; other kinds start empty and seed from the builder. */
export function buildDefaultQueries(kind: PanelKind): DashboardtypesQueryDTO[] {
- if (PANEL_KIND_TO_PANEL_TYPE[kind] === PANEL_TYPES.LIST) {
- return toPerses(listViewInitialLogQuery, PANEL_TYPES.LIST);
+ if (kind !== 'signoz/ListPanel') {
+ return [];
}
- return [];
+ // `toPerses` pivots through the V1 `Query`, which is still keyed by panel type.
+ return toPerses(listViewInitialLogQuery, PANEL_KIND_TO_PANEL_TYPE[kind]);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx
index 1a3cefb5ee..74c08b4596 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx
@@ -1,7 +1,10 @@
import { useState } from 'react';
import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
import ContextMenu from 'periscope/components/ContextMenu';
-import { getPanelDefinition } from 'pages/DashboardPage/DashboardContainer/Panels/registry';
+import {
+ getPanelDefinition,
+ isPanelKindSupported,
+} from 'pages/DashboardPage/DashboardContainer/Panels/registry';
import {
getPanelTimePreference,
panelTimePreferenceLabel,
@@ -50,15 +53,22 @@ function Panel({
// Header search: only kinds that declare it render the box. The term is owned
// here and threaded to both the header (input) and renderer (filter).
- const searchable = !!panelDefinition?.actions.search;
+ const searchable = panelDefinition.actions.search;
const [searchTerm, setSearchTerm] = useState('');
+ // Only an explicit false defers the fetch: `isVisible` is undefined wherever no
+ // observer reports visibility (the View modal, the editor preview), and those panels
+ // are on screen by construction.
+ const isOffScreen = isVisible === false;
+
const { data, isFetching, isPreviousData, error, refetch, pagination } =
usePanelQuery({
panel,
panelId,
- // Lazy: fetch only once on screen (undefined → visible) and a renderer exists.
- enabled: !!panelDefinition && isVisible !== false,
+ queryCapabilities: panelDefinition.queryCapabilities,
+ // Lazy: fetch once on screen, and never for a kind this build can't render —
+ // the data would have nothing to render into.
+ enabled: isPanelKindSupported(panelKind) && !isOffScreen,
});
const { onDragSelect, dashboardPreference } = usePanelInteractions();
@@ -67,7 +77,7 @@ function Panel({
return (
<div
className={styles.panel}
- data-panel-visible={isVisible ? 'true' : 'false'}
+ data-panel-visible={isOffScreen ? 'false' : 'true'}
// Stable locator so the "Download as PNG" action can find this node to
// capture, without threading a ref through the header/actions chain.
data-panel-root={panelId}
@@ -85,25 +95,23 @@ function Panel({
searchTerm={searchTerm}
onSearchChange={setSearchTerm}
/>
- {panelDefinition && (
- <PanelBody
- panelDefinition={panelDefinition}
- panel={panel}
- panelId={panelId}
- data={data}
- isFetching={isFetching}
- isVisible={isVisible}
- isPreviousData={isPreviousData}
- error={error}
- refetch={refetch}
- onDragSelect={onDragSelect}
- dashboardPreference={dashboardPreference}
- searchTerm={searchable ? searchTerm : undefined}
- pagination={pagination}
- onClick={drilldown.onPanelClick}
- enableDrillDown={drilldown.enableDrillDown}
- />
- )}
+ <PanelBody
+ panelDefinition={panelDefinition}
+ panel={panel}
+ panelId={panelId}
+ data={data}
+ isFetching={isFetching}
+ isVisible={isVisible}
+ isPreviousData={isPreviousData}
+ error={error}
+ refetch={refetch}
+ onDragSelect={onDragSelect}
+ dashboardPreference={dashboardPreference}
+ searchTerm={searchable ? searchTerm : undefined}
+ pagination={pagination}
+ onClick={drilldown.onPanelClick}
+ enableDrillDown={drilldown.enableDrillDown}
+ />
<ContextMenu {...drilldown.contextMenuProps} />
</div>
);
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelQueryBuilder.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelQueryBuilder.tsx
deleted file mode 100644
index 87d82ea4d0..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelQueryBuilder.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import { type KeyboardEvent, useCallback } from 'react';
-import { QueryBuilderV2 } from 'components/QueryBuilderV2/QueryBuilderV2';
-import { PANEL_TYPES } from 'constants/queryBuilder';
-import RightToolbarActions from 'container/QueryBuilder/components/ToolbarActions/RightToolbarActions';
-
-import styles from './ViewPanelModal.module.scss';
-
-interface ViewPanelQueryBuilderProps {
- panelType: PANEL_TYPES;
- /** Preview fetch in flight — drives the Run/Cancel button state. */
- isLoadingQueries: boolean;
- /** Run the current query (Run Query button / ⌘↵). */
- onStageRunQuery: () => void;
- /** Abort the in-flight preview fetch. */
- onCancelQuery: () => void;
-}
-
-/**
- * Drilldown query editor for the View modal. Mirrors V1's FullView: the query builder
- * rows + a "Run Query" button, with NO query-type tabs (ClickHouse/PromQL) — drilldown
- * is query-builder only, exactly as V1.
- */
-function ViewPanelQueryBuilder({
- panelType,
- isLoadingQueries,
- onStageRunQuery,
- onCancelQuery,
-}: ViewPanelQueryBuilderProps): JSX.Element {
- const handleKeyDownCapture = useCallback(
- (event: KeyboardEvent<HTMLDivElement>): void => {
- if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
- event.preventDefault();
- event.stopPropagation();
- onStageRunQuery();
- }
- },
- [onStageRunQuery],
- );
-
- return (
- <div
- className={styles.queryBuilder}
- data-testid="view-panel-query-builder"
- onKeyDownCapture={handleKeyDownCapture}
- role="presentation"
- >
- <QueryBuilderV2
- panelType={panelType}
- version="v3"
- isListViewPanel={panelType === PANEL_TYPES.LIST}
- signalSourceChangeEnabled
- />
- <div className={styles.queryBuilderToolbar}>
- <RightToolbarActions
- handleCancelQuery={onCancelQuery}
- onStageRunQuery={onStageRunQuery}
- isLoadingQueries={isLoadingQueries}
- />
- </div>
- </div>
- );
-}
-
-export default ViewPanelQueryBuilder;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/__tests__/useCreateAlertFromPanel.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/__tests__/useCreateAlertFromPanel.test.ts
index 793ef8d14b..25831dbf4e 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/__tests__/useCreateAlertFromPanel.test.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/__tests__/useCreateAlertFromPanel.test.ts
@@ -162,7 +162,9 @@ describe('useCreateAlertFromPanel', () => {
expect(mockBuildQueryRangeRequest).toHaveBeenCalledWith(
expect.objectContaining({
queries: panel.spec.queries,
- panelType: PANEL_TYPES.TIME_SERIES,
+ queryCapabilities: expect.objectContaining({
+ requestType: 'time_series',
+ }),
variables: { service: { type: 'query', value: 'checkout' } },
}),
);
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useClonePanel.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useClonePanel.ts
index 3c9a9a36f9..a136a64a13 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useClonePanel.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useClonePanel.ts
@@ -83,6 +83,7 @@ export function useClonePanel({
void logEvent(DashboardDetailEvents.PanelAction, {
action: 'clone',
panelType: PANEL_KIND_TO_PANEL_TYPE[source.panel.spec.plugin.kind],
+ panelKind: source.panel.spec.plugin.kind,
panelId,
...eventMeta,
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useCreateAlertFromPanel.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useCreateAlertFromPanel.ts
index fdafd615de..fc06c2fb95 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useCreateAlertFromPanel.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useCreateAlertFromPanel.ts
@@ -15,6 +15,7 @@ import { buildQueryRangeRequest } from 'pages/DashboardPage/DashboardContainer/q
import { envelopesToQuery } from 'pages/DashboardPage/DashboardContainer/queryV5/persesQueryAdapters';
import { selectResolvedVariables } from 'pages/DashboardPage/DashboardContainer/store/slices/variableSelectionSlice';
import { useDashboardStore } from 'pages/DashboardPage/DashboardContainer/store/useDashboardStore';
+import { getPanelDefinition } from 'pages/DashboardPage/DashboardContainer/Panels/registry';
import { AppState } from 'store/reducers';
import { GlobalReducer } from 'types/reducer/globalTime';
@@ -47,11 +48,15 @@ export function useCreateAlertFromPanel(): (
return useCallback(
(panel: DashboardtypesPanelDTO, panelId: string): void => {
- const panelType = PANEL_KIND_TO_PANEL_TYPE[panel.spec.plugin.kind];
+ const panelKind = panel.spec.plugin.kind;
+ // Alerts are a V1 surface: the query pivots through the V1 `Query` shape and the
+ // URL carries a legacy panel type, so this flow keeps translating.
+ const panelType = PANEL_KIND_TO_PANEL_TYPE[panelKind];
void logEvent(DashboardDetailEvents.PanelAction, {
action: 'createAlerts',
panelType,
+ panelKind,
...eventMeta,
widgetId: panelId,
queryType: getPanelQueryType(panel),
@@ -65,7 +70,7 @@ export function useCreateAlertFromPanel(): (
// Redux global time is nanoseconds; the request DTO takes epoch ms.
const request = buildQueryRangeRequest({
queries: panel.spec.queries,
- panelType,
+ queryCapabilities: getPanelDefinition(panelKind).queryCapabilities,
startMs: Math.floor(minTime / NANO_SECOND_MULTIPLIER),
endMs: Math.floor(maxTime / NANO_SECOND_MULTIPLIER),
variables,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDeletePanel.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDeletePanel.ts
index b1ee375f13..9b3219278c 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDeletePanel.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDeletePanel.ts
@@ -44,6 +44,7 @@ export function useDeletePanel({
}
const removed = section.items.find((i) => i.id === panelId);
+ const removedKind = removed?.panel?.spec.plugin.kind;
const nextItems = section.items.filter((i) => i.id !== panelId);
try {
await patchAsync([
@@ -52,9 +53,15 @@ export function useDeletePanel({
]);
void logEvent(DashboardDetailEvents.PanelAction, {
action: 'delete',
- panelType: removed?.panel
- ? PANEL_KIND_TO_PANEL_TYPE[removed.panel.spec.plugin.kind]
- : undefined,
+ // An item ref can outlive its panel, so both fields go on together or
+ // not at all: `panelType` keeps existing reports resolving, `panelKind`
+ // is the V2 identity.
+ ...(removedKind
+ ? {
+ panelType: PANEL_KIND_TO_PANEL_TYPE[removedKind],
+ panelKind: removedKind,
+ }
+ : {}),
panelId,
...eventMeta,
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDownloadPanelCsv.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDownloadPanelCsv.ts
index b07a813c02..dfa8d7ed42 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDownloadPanelCsv.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDownloadPanelCsv.ts
@@ -43,6 +43,7 @@ export function useDownloadPanelCsv({
void logEvent(DashboardDetailEvents.PanelExported, {
format: 'csv',
panelType: PANEL_KIND_TO_PANEL_TYPE[panel.spec.plugin.kind],
+ panelKind: panel.spec.plugin.kind,
});
}, [canDownloadCsv, fileName, panel, data]);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDrilldown.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDrilldown.tsx
index a833dddfe8..b1a29f88e4 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDrilldown.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDrilldown.tsx
@@ -128,11 +128,14 @@ export function useDrilldown(
const onPanelClick = useCallback(
(payload: DrilldownClickPayload): void => {
- void logEvent(DashboardDetailEvents.DrilldownOpened, { panelType });
+ void logEvent(DashboardDetailEvents.DrilldownOpened, {
+ panelType,
+ panelKind: kind,
+ });
setSubMenu(DrilldownSubMenu.Base);
onClick(payload.coordinates, payload.context);
},
- [onClick, panelType],
+ [onClick, panelType, kind],
);
const handleClose = useCallback((): void => {
@@ -176,7 +179,8 @@ export function useDrilldown(
const { resolvedQuery, isResolving } = useResolvedDrilldownQuery({
queries,
- panelType,
+ panelKind: kind,
+ queryCapabilities: getPanelDefinition(kind).queryCapabilities,
v1Query,
enabled: showAggregateMenu,
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useMovePanelToSection.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useMovePanelToSection.ts
index 59ccb5b98b..077f09cdff 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useMovePanelToSection.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useMovePanelToSection.ts
@@ -55,6 +55,7 @@ export function useMovePanelToSection({
if (!moved) {
return;
}
+ const movedKind = moved.panel?.spec.plugin.kind;
const sourceItems = source.items.filter((i) => i.id !== panelId);
// Land at the section bottom, not backfilled into a gap — least disruptive
@@ -73,9 +74,15 @@ export function useMovePanelToSection({
);
void logEvent(DashboardDetailEvents.PanelAction, {
action: 'move',
- panelType: moved.panel
- ? PANEL_KIND_TO_PANEL_TYPE[moved.panel.spec.plugin.kind]
- : undefined,
+ // An item ref can outlive its panel, so both fields go on together or
+ // not at all: `panelType` keeps existing reports resolving, `panelKind`
+ // is the V2 identity.
+ ...(movedKind
+ ? {
+ panelType: PANEL_KIND_TO_PANEL_TYPE[movedKind],
+ panelKind: movedKind,
+ }
+ : {}),
panelId,
...eventMeta,
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useResolvedDrilldownQuery.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useResolvedDrilldownQuery.ts
index 02620e8f63..5981a7146d 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useResolvedDrilldownQuery.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useResolvedDrilldownQuery.ts
@@ -3,11 +3,15 @@ import { useEffect, useMemo } from 'react';
import { useSelector } from 'react-redux';
import { useReplaceVariables } from 'api/generated/services/querier';
import type { DashboardtypesQueryDTO } from 'api/generated/services/sigNoz.schemas';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import { buildQueryRangeRequest } from 'pages/DashboardPage/DashboardContainer/queryV5/buildQueryRangeRequest';
import { envelopesToQuery } from 'pages/DashboardPage/DashboardContainer/queryV5/persesQueryAdapters';
import { selectResolvedVariables } from 'pages/DashboardPage/DashboardContainer/store/slices/variableSelectionSlice';
import { useDashboardStore } from 'pages/DashboardPage/DashboardContainer/store/useDashboardStore';
+import type { PanelQueryCapabilities } from 'pages/DashboardPage/DashboardContainer/Panels/types/panelCapabilities';
+import {
+ PANEL_KIND_TO_PANEL_TYPE,
+ type PanelKind,
+} from 'pages/DashboardPage/DashboardContainer/Panels/types/panelKind';
import { AppState } from 'store/reducers';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
import { GlobalReducer } from 'types/reducer/globalTime';
@@ -15,7 +19,9 @@ import { GlobalReducer } from 'types/reducer/globalTime';
interface UseResolvedDrilldownQueryArgs {
/** Panel's perses queries — the substitution source (carries the `$var` refs). */
queries: DashboardtypesQueryDTO[];
- panelType: PANEL_TYPES;
+ panelKind: PanelKind;
+ /** The panel kind's declared query capabilities — shapes the substitution request. */
+ queryCapabilities: PanelQueryCapabilities;
/** The raw V5→V1 query; the fallback until substitution resolves / when no vars exist. */
v1Query: Query;
/** Resolve only while the aggregate menu is open (V1 parity: fires when it appears). */
@@ -38,7 +44,8 @@ interface UseResolvedDrilldownQueryResult {
*/
export function useResolvedDrilldownQuery({
queries,
- panelType,
+ panelKind,
+ queryCapabilities,
v1Query,
enabled,
}: UseResolvedDrilldownQueryArgs): UseResolvedDrilldownQueryResult {
@@ -60,7 +67,7 @@ export function useResolvedDrilldownQuery({
substituteVars({
data: buildQueryRangeRequest({
queries,
- panelType,
+ queryCapabilities,
startMs: Math.floor(minTime / 1e6),
endMs: Math.floor(maxTime / 1e6),
variables,
@@ -70,7 +77,7 @@ export function useResolvedDrilldownQuery({
enabled,
hasVariables,
queries,
- panelType,
+ queryCapabilities,
minTime,
maxTime,
variables,
@@ -81,8 +88,13 @@ export function useResolvedDrilldownQuery({
if (!hasVariables || !data) {
return v1Query;
}
- return envelopesToQuery(data.data.compositeQuery?.queries ?? [], panelType);
- }, [hasVariables, data, v1Query, panelType]);
+ // View-in-X navigates to a V1 explorer, so the resolved query crosses back into the
+ // V1 `Query` shape — the one place this hook still needs a legacy panel type.
+ return envelopesToQuery(
+ data.data.compositeQuery?.queries ?? [],
+ PANEL_KIND_TO_PANEL_TYPE[panelKind],
+ );
+ }, [hasVariables, data, v1Query, panelKind]);
return { resolvedQuery, isResolving: enabled && hasVariables && isLoading };
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/hooks/__tests__/usePanelQuery.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/hooks/__tests__/usePanelQuery.test.tsx
index 12fb5446a1..0d1457c0c1 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/hooks/__tests__/usePanelQuery.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/hooks/__tests__/usePanelQuery.test.tsx
@@ -1,7 +1,11 @@
// eslint-disable-next-line no-restricted-imports
import { useSelector } from 'react-redux';
import { act, renderHook } from '@testing-library/react';
-import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ type DashboardtypesPanelDTO,
+ Querybuildertypesv5RequestTypeDTO,
+} from 'api/generated/services/sigNoz.schemas';
+import type { PanelQueryCapabilities } from 'pages/DashboardPage/DashboardContainer/Panels/types/panelCapabilities';
import {
DASHBOARD_CACHE_TIME,
DASHBOARD_CACHE_TIME_ON_REFRESH_ENABLED,
@@ -54,6 +58,23 @@ function panelWith(
} as unknown as DashboardtypesPanelDTO;
}
+// The capability blocks TimeSeries and List declare. Passed in rather than resolved from
+// the registry: the hook takes them as input, and importing the registry here would pull
+// every panel renderer (and the app's API client) into this suite.
+const TIME_SERIES_CAPABILITIES: PanelQueryCapabilities = {
+ requestType: Querybuildertypesv5RequestTypeDTO.time_series,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+};
+const LIST_PANEL_CAPABILITIES: PanelQueryCapabilities = {
+ ...TIME_SERIES_CAPABILITIES,
+ requestType: Querybuildertypesv5RequestTypeDTO.raw,
+ orderTiebreaker: true,
+ serverPaginated: true,
+};
+
function builderPanel(): DashboardtypesPanelDTO {
return panelWith('signoz/TimeSeriesPanel', {
name: 'A',
@@ -100,7 +121,13 @@ beforeEach(() => {
describe('usePanelQuery', () => {
it('builds the generated V5 request DTO directly from panel.spec.queries', () => {
- renderHook(() => usePanelQuery({ panel: builderPanel(), panelId: 'p1' }));
+ renderHook(() =>
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
+ );
const [{ requestPayload }] = mockUseGetQueryRangeV5.mock.calls[0];
expect(requestPayload.schemaVersion).toBe('v1');
expect(requestPayload.compositeQuery.queries).toStrictEqual([
@@ -112,30 +139,30 @@ describe('usePanelQuery', () => {
});
it('converts redux nanosecond time to epoch ms on the request', () => {
- renderHook(() => usePanelQuery({ panel: builderPanel(), panelId: 'p1' }));
+ renderHook(() =>
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
+ );
const [{ requestPayload }] = mockUseGetQueryRangeV5.mock.calls[0];
expect(requestPayload.start).toBe(1_000_000_000);
expect(requestPayload.end).toBe(2_000_000_000);
});
- it.each([
- ['signoz/TimeSeriesPanel', 'time_series'],
- ['signoz/ListPanel', 'raw'],
- // HISTOGRAM and BAR panels bin/derive from raw time-series data
- // client-side, so the backend must receive `time_series` (V1 parity).
- ['signoz/HistogramPanel', 'time_series'],
- ['signoz/BarChartPanel', 'time_series'],
- ['signoz/NumberPanel', 'scalar'],
- ['signoz/PieChartPanel', 'scalar'],
- ])('%s panel sends requestType=%s', (panelKind, requestType) => {
+ // Which requestType each kind declares is asserted in
+ // Panels/__tests__/capabilities.test.ts; here it only has to reach the request.
+ it('sends the requestType from the declared query capabilities', () => {
renderHook(() =>
usePanelQuery({
- panel: panelWith(panelKind, { name: 'A', signal: 'logs' }),
+ panel: panelWith('signoz/ListPanel', { name: 'A', signal: 'logs' }),
panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
}),
);
const [{ requestPayload }] = mockUseGetQueryRangeV5.mock.calls[0];
- expect(requestPayload.requestType).toBe(requestType);
+ expect(requestPayload.requestType).toBe('raw');
});
it('exposes the raw V5 response, request payload, and legend map on data', () => {
@@ -148,7 +175,11 @@ describe('usePanelQuery', () => {
});
const { result } = renderHook(() =>
- usePanelQuery({ panel: builderPanel(), panelId: 'p1' }),
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
);
expect(result.current.data.response).toBe(v5Response);
@@ -158,7 +189,11 @@ describe('usePanelQuery', () => {
it('exposes an undefined response before data arrives', () => {
const { result } = renderHook(() =>
- usePanelQuery({ panel: builderPanel(), panelId: 'p1' }),
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
);
expect(result.current.data.response).toBeUndefined();
});
@@ -171,7 +206,11 @@ describe('usePanelQuery', () => {
error: new Error('boom'),
});
const { result } = renderHook(() =>
- usePanelQuery({ panel: builderPanel(), panelId: 'p1' }),
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
);
expect(result.current.error?.message).toBe('boom');
});
@@ -186,7 +225,11 @@ describe('usePanelQuery', () => {
error: null,
});
const { result } = renderHook(() =>
- usePanelQuery({ panel: builderPanel(), panelId: 'p1' }),
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
);
expect(result.current.isLoading).toBe(false);
expect(result.current.isFetching).toBe(true);
@@ -200,7 +243,11 @@ describe('usePanelQuery', () => {
error: null,
});
const { result } = renderHook(() =>
- usePanelQuery({ panel: builderPanel(), panelId: 'p1' }),
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
);
expect(result.current.isLoading).toBe(true);
});
@@ -213,14 +260,23 @@ describe('usePanelQuery', () => {
error: undefined,
});
const { result } = renderHook(() =>
- usePanelQuery({ panel: builderPanel(), panelId: 'p1' }),
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
);
expect(result.current.error).toBeNull();
});
it('passes enabled=false to the fetch hook when the caller disables it', () => {
renderHook(() =>
- usePanelQuery({ panel: builderPanel(), panelId: 'p1', enabled: false }),
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ enabled: false,
+ }),
);
const [{ enabled }] = mockUseGetQueryRangeV5.mock.calls[0];
expect(enabled).toBe(false);
@@ -228,7 +284,12 @@ describe('usePanelQuery', () => {
it('auto-disables the fetch when the panel has no queries (even with enabled=true)', () => {
renderHook(() =>
- usePanelQuery({ panel: emptyPanel(), panelId: 'p1', enabled: true }),
+ usePanelQuery({
+ panel: emptyPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ enabled: true,
+ }),
);
const [{ enabled }] = mockUseGetQueryRangeV5.mock.calls[0];
expect(enabled).toBe(false);
@@ -243,6 +304,7 @@ describe('usePanelQuery', () => {
aggregations: [{}],
}),
panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
}),
);
const [{ enabled }] = mockUseGetQueryRangeV5.mock.calls[0];
@@ -251,7 +313,13 @@ describe('usePanelQuery', () => {
it('composes a react-query cache key that includes panelId, time range, kind, and queries', () => {
const panel = builderPanel();
- renderHook(() => usePanelQuery({ panel, panelId: 'p1' }));
+ renderHook(() =>
+ usePanelQuery({
+ panel,
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
+ );
const [{ queryKey }] = mockUseGetQueryRangeV5.mock.calls[0];
expect(queryKey).toStrictEqual(
expect.arrayContaining([
@@ -270,6 +338,7 @@ describe('usePanelQuery', () => {
renderHook(() =>
usePanelQuery({
panel,
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
panelId: 'p1',
time: { startMs: 1_700_000_000_000, endMs: 1_700_000_600_000 },
}),
@@ -296,6 +365,7 @@ describe('usePanelQuery', () => {
usePanelQuery({
panel: builderPanel(),
panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
time: { startMs: 1_700_000_000_000.546, endMs: 1_700_000_600_000.999 },
}),
);
@@ -316,7 +386,11 @@ describe('usePanelQuery', () => {
it('exposes server paging at the default page size when the query has no limit', () => {
const { result } = renderHook(() =>
- usePanelQuery({ panel: listPanel({}), panelId: 'p1' }),
+ usePanelQuery({
+ panel: listPanel({}),
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
);
expect(result.current.pagination).toBeDefined();
expect(result.current.pagination?.pageSize).toBe(25);
@@ -327,20 +401,34 @@ describe('usePanelQuery', () => {
it('disables the server pager when the query has an explicit limit (V1 parity)', () => {
const { result } = renderHook(() =>
- usePanelQuery({ panel: listPanel({ limit: 100 }), panelId: 'p1' }),
+ usePanelQuery({
+ panel: listPanel({ limit: 100 }),
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
);
expect(result.current.pagination).toBeUndefined();
});
it('keeps previous data while paging so the table/pager stay mounted on page change', () => {
- renderHook(() => usePanelQuery({ panel: listPanel({}), panelId: 'p1' }));
+ renderHook(() =>
+ usePanelQuery({
+ panel: listPanel({}),
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
+ );
const [{ keepPreviousData }] = mockUseGetQueryRangeV5.mock.calls[0];
expect(keepPreviousData).toBe(true);
});
it('changes the page size (and re-requests with the new limit) via setPageSize', () => {
const { result } = renderHook(() =>
- usePanelQuery({ panel: listPanel({}), panelId: 'p1' }),
+ usePanelQuery({
+ panel: listPanel({}),
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
);
act(() => result.current.pagination?.setPageSize(50));
@@ -380,7 +468,11 @@ describe('usePanelQuery', () => {
it('starts on page 0 with no prev/next and does not throw before data arrives', () => {
const { result } = renderHook(() =>
- usePanelQuery({ panel: listPanel({}), panelId: 'p1' }),
+ usePanelQuery({
+ panel: listPanel({}),
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
);
expect(result.current.pagination?.pageIndex).toBe(0);
expect(result.current.pagination?.canPrev).toBe(false);
@@ -392,21 +484,33 @@ describe('usePanelQuery', () => {
// window/cursor path), so a full page is the has-more signal.
withResponse(rawResponse(25));
const fullPage = renderHook(() =>
- usePanelQuery({ panel: listPanel({}), panelId: 'p1' }),
+ usePanelQuery({
+ panel: listPanel({}),
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
);
expect(fullPage.result.current.pagination?.canNext).toBe(true);
// Partial page, no cursor → the last page.
withResponse(rawResponse(3));
const partialPage = renderHook(() =>
- usePanelQuery({ panel: listPanel({}), panelId: 'p1' }),
+ usePanelQuery({
+ panel: listPanel({}),
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
);
expect(partialPage.result.current.pagination?.canNext).toBe(false);
// Cursor present (even on a partial page) → more rows (timestamp window path).
withResponse(rawResponse(3, 'cursor-1'));
const withCursor = renderHook(() =>
- usePanelQuery({ panel: listPanel({}), panelId: 'p1' }),
+ usePanelQuery({
+ panel: listPanel({}),
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
);
expect(withCursor.result.current.pagination?.canNext).toBe(true);
});
@@ -416,7 +520,13 @@ describe('usePanelQuery', () => {
// Stable panel reference: a fresh one each render would change the
// `queries` identity and trip the offset-reset effect (real props are stable).
const panel = listPanel({});
- const { result } = renderHook(() => usePanelQuery({ panel, panelId: 'p1' }));
+ const { result } = renderHook(() =>
+ usePanelQuery({
+ panel,
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
+ );
expect(result.current.pagination?.pageIndex).toBe(0);
act(() => result.current.pagination?.goNext());
@@ -428,7 +538,11 @@ describe('usePanelQuery', () => {
it('stays defined and zero-paged for a non-raw (scalar) response', () => {
withResponse({ data: { type: 'scalar', data: { results: [] } } });
const { result } = renderHook(() =>
- usePanelQuery({ panel: listPanel({}), panelId: 'p1' }),
+ usePanelQuery({
+ panel: listPanel({}),
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
);
expect(result.current.pagination).toBeDefined();
expect(result.current.pagination?.canNext).toBe(false);
@@ -437,7 +551,11 @@ describe('usePanelQuery', () => {
it('ignores a non-positive page size so paging never goes invalid', () => {
const { result } = renderHook(() =>
- usePanelQuery({ panel: listPanel({}), panelId: 'p1' }),
+ usePanelQuery({
+ panel: listPanel({}),
+ panelId: 'p1',
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
+ }),
);
act(() => result.current.pagination?.setPageSize(0));
expect(result.current.pagination?.pageSize).toBe(25);
@@ -456,14 +574,26 @@ describe('usePanelQuery', () => {
it('caches for DASHBOARD_CACHE_TIME when auto-refresh is disabled', () => {
withAutoRefreshDisabled(true);
- renderHook(() => usePanelQuery({ panel: builderPanel(), panelId: 'p1' }));
+ renderHook(() =>
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
+ );
const [{ cacheTime }] = mockUseGetQueryRangeV5.mock.calls[0];
expect(cacheTime).toBe(DASHBOARD_CACHE_TIME);
});
it('drops cacheTime to 0 when auto-refresh is enabled', () => {
withAutoRefreshDisabled(false);
- renderHook(() => usePanelQuery({ panel: builderPanel(), panelId: 'p1' }));
+ renderHook(() =>
+ usePanelQuery({
+ panel: builderPanel(),
+ panelId: 'p1',
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
+ }),
+ );
const [{ cacheTime }] = mockUseGetQueryRangeV5.mock.calls[0];
expect(cacheTime).toBe(DASHBOARD_CACHE_TIME_ON_REFRESH_ENABLED);
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/hooks/usePanelQuery.ts b/frontend/src/pages/DashboardPage/DashboardContainer/hooks/usePanelQuery.ts
index 01996f35d4..df95da525d 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/hooks/usePanelQuery.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/hooks/usePanelQuery.ts
@@ -3,7 +3,6 @@ import { useQueryClient } from 'react-query';
// eslint-disable-next-line no-restricted-imports -- TODO: migrate global time selector off redux
import { useSelector } from 'react-redux';
import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import {
DASHBOARD_CACHE_TIME,
DASHBOARD_CACHE_TIME_ON_REFRESH_ENABLED,
@@ -24,7 +23,7 @@ import {
queryReferencesAnyVariable,
} from '../queryV5/getReferencedVariables';
import { getBuilderQueries } from '../Panels/utils/getBuilderQueries';
-import { PANEL_KIND_TO_PANEL_TYPE } from '../Panels/types/panelKind';
+import type { PanelQueryCapabilities } from '../Panels/types/panelCapabilities';
import { selectResolvedVariables } from '../store/slices/variableSelectionSlice';
import { useDashboardStore } from '../store/useDashboardStore';
import { resolvePanelTimeWindow } from './resolvePanelTimeWindow';
@@ -38,6 +37,8 @@ const DEFAULT_LIST_PAGE_SIZE = 25;
export interface UsePanelQueryArgs {
panel: DashboardtypesPanelDTO;
panelId: string;
+ /** The panel kind's declared query capabilities — `panelDefinition.queryCapabilities` at the call site. */
+ queryCapabilities: PanelQueryCapabilities;
/**
* Gate the fetch (default true). PanelV2 sets false for unregistered kinds to skip a wasted
* call. The hook also auto-disables internally when the panel has no runnable queries.
@@ -85,21 +86,20 @@ export interface UsePanelQueryResult {
export function usePanelQuery({
panel,
panelId,
+ queryCapabilities,
enabled = true,
time,
}: UsePanelQueryArgs): UsePanelQueryResult {
const fullKind = panel.spec.plugin.kind;
- const panelType =
- (fullKind && PANEL_KIND_TO_PANEL_TYPE[fullKind]) ?? PANEL_TYPES.TIME_SERIES;
const queries = panel.spec.queries;
- // V1 parity: a list query with an explicit `limit` shows without a server pager; without
- // one it pages server-side at a user-selectable size.
+ // V1 parity: a query with an explicit `limit` shows without a server pager; without
+ // one a paging kind fetches server-side at a user-selectable size.
const hasExplicitLimit = useMemo(
() => !!getBuilderQueries(queries)[0]?.limit,
[queries],
);
- const isPaginated = panelType === PANEL_TYPES.LIST && !hasExplicitLimit;
+ const isPaginated = queryCapabilities.serverPaginated && !hasExplicitLimit;
const [pageSize, setPageSize] = useState(DEFAULT_LIST_PAGE_SIZE);
const [offset, setOffset] = useState(0);
@@ -188,7 +188,7 @@ export function usePanelQuery({
() =>
buildQueryRangeRequest({
queries,
- panelType,
+ queryCapabilities,
startMs,
endMs,
fillGaps,
@@ -197,7 +197,7 @@ export function usePanelQuery({
}),
[
queries,
- panelType,
+ queryCapabilities,
startMs,
endMs,
fillGaps,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/buildQueryRangeRequest.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/buildQueryRangeRequest.test.ts
index 8e323a6b9c..b3f37e0df3 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/buildQueryRangeRequest.test.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/buildQueryRangeRequest.test.ts
@@ -1,12 +1,13 @@
-import type { DashboardtypesQueryDTO } from 'api/generated/services/sigNoz.schemas';
-import { PANEL_TYPES } from 'constants/queryBuilder';
+import {
+ type DashboardtypesQueryDTO,
+ Querybuildertypesv5RequestTypeDTO,
+} from 'api/generated/services/sigNoz.schemas';
import {
buildQueryRangeRequest,
extractLegendMap,
getBarStepIntervalSeconds,
hasRunnableQueries,
- panelTypeToRequestType,
toQueryEnvelopes,
} from '../buildQueryRangeRequest';
@@ -40,20 +41,46 @@ function compositeQuery(
const HOUR_MS = 60 * 60 * 1000;
const START_MS = 1_700_000_000_000;
-describe('panelTypeToRequestType', () => {
+// Capability blocks matching what each kind declares, so these tests exercise the
+// builder's response to the flags rather than the declarations themselves (those are
+// asserted against the registry in Panels/__tests__/capabilities.test.ts).
+const TIME_SERIES_CAPABILITIES = {
+ requestType: Querybuildertypesv5RequestTypeDTO.time_series,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+};
+const BAR_CAPABILITIES = {
+ ...TIME_SERIES_CAPABILITIES,
+ bucketedStepInterval: true,
+};
+const TABLE_CAPABILITIES = {
+ ...TIME_SERIES_CAPABILITIES,
+ requestType: Querybuildertypesv5RequestTypeDTO.scalar,
+ formatTableResultForUI: true,
+};
+const LIST_PANEL_CAPABILITIES = {
+ ...TIME_SERIES_CAPABILITIES,
+ requestType: Querybuildertypesv5RequestTypeDTO.raw,
+ orderTiebreaker: true,
+ serverPaginated: true,
+};
+
+describe('requestType', () => {
it.each([
- [PANEL_TYPES.TIME_SERIES, 'time_series'],
- // HISTOGRAM and BAR bin client-side from time-series data; sending
- // 'distribution' would return a shape the renderers can't bin.
- [PANEL_TYPES.BAR, 'time_series'],
- [PANEL_TYPES.HISTOGRAM, 'time_series'],
- [PANEL_TYPES.TABLE, 'scalar'],
- [PANEL_TYPES.PIE, 'scalar'],
- [PANEL_TYPES.VALUE, 'scalar'],
- [PANEL_TYPES.LIST, 'raw'],
- [PANEL_TYPES.TRACE, 'trace'],
- ])('%s → %s', (panelType, requestType) => {
- expect(panelTypeToRequestType(panelType)).toBe(requestType);
+ Querybuildertypesv5RequestTypeDTO.time_series,
+ Querybuildertypesv5RequestTypeDTO.scalar,
+ Querybuildertypesv5RequestTypeDTO.raw,
+ Querybuildertypesv5RequestTypeDTO.trace,
+ ])('passes %s through from the declared capabilities', (requestType) => {
+ const request = buildQueryRangeRequest({
+ queries: bareBuilderQuery({ name: 'A', signal: 'metrics' }),
+ queryCapabilities: { ...TIME_SERIES_CAPABILITIES, requestType },
+ startMs: START_MS,
+ endMs: START_MS + HOUR_MS,
+ });
+ expect(request.requestType).toBe(requestType);
});
});
@@ -135,7 +162,7 @@ describe('buildQueryRangeRequest', () => {
it('assembles the full request DTO', () => {
const request = buildQueryRangeRequest({
queries: bareBuilderQuery({ name: 'A', signal: 'metrics' }),
- panelType: PANEL_TYPES.TIME_SERIES,
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
});
@@ -157,7 +184,7 @@ describe('buildQueryRangeRequest', () => {
it('sets formatTableResultForUI only for TABLE panels', () => {
const request = buildQueryRangeRequest({
queries: bareBuilderQuery({ name: 'A' }),
- panelType: PANEL_TYPES.TABLE,
+ queryCapabilities: TABLE_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
});
@@ -167,7 +194,7 @@ describe('buildQueryRangeRequest', () => {
it('passes through fillGaps into formatOptions', () => {
const request = buildQueryRangeRequest({
queries: bareBuilderQuery({ name: 'A' }),
- panelType: PANEL_TYPES.TIME_SERIES,
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
fillGaps: true,
@@ -178,7 +205,7 @@ describe('buildQueryRangeRequest', () => {
it('stamps offset/limit onto builder queries when pagination is given', () => {
const request = buildQueryRangeRequest({
queries: bareBuilderQuery({ name: 'A', signal: 'logs' }),
- panelType: PANEL_TYPES.LIST,
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
pagination: { offset: 100, limit: 50 },
@@ -198,7 +225,7 @@ describe('buildQueryRangeRequest', () => {
it('defaults a logs list with no order to timestamp desc + id tiebreaker', () => {
const request = buildQueryRangeRequest({
queries: bareBuilderQuery({ name: 'A', signal: 'logs' }),
- panelType: PANEL_TYPES.LIST,
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
});
@@ -218,7 +245,7 @@ describe('buildQueryRangeRequest', () => {
signal: 'logs',
order: [{ key: { name: 'timestamp' }, direction: 'desc' }],
}),
- panelType: PANEL_TYPES.LIST,
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
});
@@ -238,7 +265,7 @@ describe('buildQueryRangeRequest', () => {
];
const request = buildQueryRangeRequest({
queries: bareBuilderQuery({ name: 'A', signal: 'logs', order }),
- panelType: PANEL_TYPES.LIST,
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
});
@@ -252,7 +279,7 @@ describe('buildQueryRangeRequest', () => {
const order = [{ key: { name: 'timestamp' }, direction: 'desc' }];
const request = buildQueryRangeRequest({
queries: bareBuilderQuery({ name: 'A', signal: 'traces', order }),
- panelType: PANEL_TYPES.LIST,
+ queryCapabilities: LIST_PANEL_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
});
@@ -265,7 +292,7 @@ describe('buildQueryRangeRequest', () => {
it('injects the range-derived stepInterval into BAR builder queries without one', () => {
const request = buildQueryRangeRequest({
queries: bareBuilderQuery({ name: 'A', signal: 'metrics' }),
- panelType: PANEL_TYPES.BAR,
+ queryCapabilities: BAR_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
});
@@ -280,7 +307,7 @@ describe('buildQueryRangeRequest', () => {
it('preserves a user-set stepInterval on BAR builder queries', () => {
const request = buildQueryRangeRequest({
queries: bareBuilderQuery({ name: 'A', stepInterval: 300 }),
- panelType: PANEL_TYPES.BAR,
+ queryCapabilities: BAR_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
});
@@ -293,7 +320,7 @@ describe('buildQueryRangeRequest', () => {
it('does not touch stepInterval for non-BAR panels', () => {
const request = buildQueryRangeRequest({
queries: bareBuilderQuery({ name: 'A' }),
- panelType: PANEL_TYPES.TIME_SERIES,
+ queryCapabilities: TIME_SERIES_CAPABILITIES,
startMs: START_MS,
endMs: START_MS + HOUR_MS,
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/persesQueryAdapters.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/persesQueryAdapters.test.ts
index 0afab16165..b7e9e57c09 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/persesQueryAdapters.test.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/persesQueryAdapters.test.ts
@@ -7,7 +7,12 @@ import type { Query } from 'types/api/queryBuilder/queryBuilderData';
import { EQueryType } from 'types/common/dashboard';
import { DataSource } from 'types/common/queryBuilder';
-import { envelopesToQuery, fromPerses, toPerses } from '../persesQueryAdapters';
+import {
+ envelopesToQuery,
+ fromPerses,
+ panelTypeToRequestType,
+ toPerses,
+} from '../persesQueryAdapters';
/** A bare perses query (single plugin, not wrapped in a CompositeQuery). */
function bareQuery(
@@ -21,6 +26,23 @@ function bareQuery(
}
describe('persesQueryAdapters', () => {
+ describe('panelTypeToRequestType', () => {
+ it.each([
+ [PANEL_TYPES.TIME_SERIES, 'time_series'],
+ // HISTOGRAM and BAR bin client-side from time-series data; sending
+ // 'distribution' would return a shape the renderers can't bin.
+ [PANEL_TYPES.BAR, 'time_series'],
+ [PANEL_TYPES.HISTOGRAM, 'time_series'],
+ [PANEL_TYPES.TABLE, 'scalar'],
+ [PANEL_TYPES.PIE, 'scalar'],
+ [PANEL_TYPES.VALUE, 'scalar'],
+ [PANEL_TYPES.LIST, 'raw'],
+ [PANEL_TYPES.TRACE, 'trace'],
+ ])('%s → %s', (panelType, requestType) => {
+ expect(panelTypeToRequestType(panelType)).toBe(requestType);
+ });
+ });
+
describe('fromPerses', () => {
it('returns a fresh metrics builder query for an empty panel', () => {
const query = fromPerses([], PANEL_TYPES.TIME_SERIES);
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/buildQueryRangeRequest.ts b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/buildQueryRangeRequest.ts
index bc4194484f..8d9219251b 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/buildQueryRangeRequest.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/buildQueryRangeRequest.ts
@@ -14,9 +14,9 @@ import {
Querybuildertypesv5QueryEnvelopeBuilderDTOType,
Querybuildertypesv5QueryEnvelopeClickHouseSQLDTOType,
Querybuildertypesv5QueryEnvelopePromQLDTOType,
- Querybuildertypesv5RequestTypeDTO,
} from 'api/generated/services/sigNoz.schemas';
-import { PANEL_TYPES } from 'constants/queryBuilder';
+
+import type { PanelQueryCapabilities } from '../Panels/types/panelCapabilities';
// Narrow view over the envelope spec variants. Orval erases envelope `spec` to `unknown`, so
// shared fields are read through this view with a localized cast at the envelope boundary.
@@ -29,31 +29,6 @@ interface QuerySpecView {
order?: Querybuildertypesv5OrderByDTO[];
}
-/**
- * Maps a V2 panel type to the V5 `requestType`. HISTOGRAM/BAR bin client-side from raw
- * time-series, so their request type is `time_series` (V1 parity).
- */
-export function panelTypeToRequestType(
- panelType: PANEL_TYPES,
-): Querybuildertypesv5RequestTypeDTO {
- switch (panelType) {
- case PANEL_TYPES.TIME_SERIES:
- case PANEL_TYPES.BAR:
- case PANEL_TYPES.HISTOGRAM:
- return Querybuildertypesv5RequestTypeDTO.time_series;
- case PANEL_TYPES.TABLE:
- case PANEL_TYPES.PIE:
- case PANEL_TYPES.VALUE:
- return Querybuildertypesv5RequestTypeDTO.scalar;
- case PANEL_TYPES.LIST:
- return Querybuildertypesv5RequestTypeDTO.raw;
- case PANEL_TYPES.TRACE:
- return Querybuildertypesv5RequestTypeDTO.trace;
- default:
- return Querybuildertypesv5RequestTypeDTO.time_series;
- }
-}
-
/**
* Unwraps the perses query into the V5 `compositeQuery.queries` list: a CompositeQuery passes
* through verbatim, bare plugins wrap into one envelope. Top-level Formula/TraceOperator are
@@ -239,7 +214,13 @@ function withPagination(
export interface BuildQueryRangeRequestArgs {
queries: DashboardtypesQueryDTO[];
- panelType: PANEL_TYPES;
+ /**
+ * The panel kind's declared query capabilities (`PanelDefinition.queryCapabilities`): request type,
+ * result formatting, and the step-interval/order treatment. Passed in rather than looked up
+ * by kind so this stays a leaf of the query layer — the panel registry carries every
+ * renderer with it, which has no business in the data path.
+ */
+ queryCapabilities: PanelQueryCapabilities;
/** Epoch milliseconds. */
startMs: number;
/** Epoch milliseconds. */
@@ -258,7 +239,12 @@ export interface BuildQueryRangeRequestArgs {
*/
export function buildQueryRangeRequest({
queries,
- panelType,
+ queryCapabilities: {
+ requestType,
+ formatTableResultForUI,
+ bucketedStepInterval,
+ orderTiebreaker,
+ },
startMs,
endMs,
fillGaps = false,
@@ -266,10 +252,10 @@ export function buildQueryRangeRequest({
variables = {},
}: BuildQueryRangeRequestArgs): Querybuildertypesv5QueryRangeRequestDTO {
let envelopes = toQueryEnvelopes(queries);
- if (panelType === PANEL_TYPES.BAR) {
+ if (bucketedStepInterval) {
envelopes = withBarStepInterval(envelopes, startMs, endMs);
}
- if (panelType === PANEL_TYPES.LIST) {
+ if (orderTiebreaker) {
envelopes = withListOrderTiebreaker(envelopes);
}
if (pagination) {
@@ -280,10 +266,10 @@ export function buildQueryRangeRequest({
schemaVersion: 'v1',
start: startMs,
end: endMs,
- requestType: panelTypeToRequestType(panelType),
+ requestType,
compositeQuery: { queries: envelopes },
formatOptions: {
- formatTableResultForUI: panelType === PANEL_TYPES.TABLE,
+ formatTableResultForUI,
fillGaps,
},
variables,
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/persesQueryAdapters.ts b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/persesQueryAdapters.ts
index 12ee5f905c..d4e64155b2 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/persesQueryAdapters.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/persesQueryAdapters.ts
@@ -10,6 +10,7 @@ import {
Querybuildertypesv5QueryEnvelopeBuilderDTOType,
Querybuildertypesv5QueryEnvelopeClickHouseSQLDTOType,
Querybuildertypesv5QueryEnvelopePromQLDTOType,
+ Querybuildertypesv5RequestTypeDTO,
} from 'api/generated/services/sigNoz.schemas';
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
import { mapCompositeQueryFromQuery } from 'lib/newQueryBuilder/queryBuilderMappers/mapCompositeQueryFromQuery';
@@ -20,10 +21,7 @@ import type { QueryEnvelope } from 'types/api/v5/queryRange';
import { EQueryType } from 'types/common/dashboard';
import { DataSource } from 'types/common/queryBuilder';
-import {
- panelTypeToRequestType,
- toQueryEnvelopes,
-} from './buildQueryRangeRequest';
+import { toQueryEnvelopes } from './buildQueryRangeRequest';
/**
* Adapters between the V2 perses query shape and the V1 `Query` the shared query
@@ -90,6 +88,33 @@ export function deriveQueryType(
return EQueryType.QUERY_BUILDER;
}
+/**
+ * Maps a legacy panel type to the V5 `requestType`. Lives on this side of the V1 boundary
+ * because only the V1 pivot still speaks `PANEL_TYPES` — V2 panels read `requestType` off
+ * their kind's declared query capabilities instead. BAR/HISTOGRAM bin client-side from a raw
+ * time series, so they request `time_series` (V1 parity).
+ */
+export function panelTypeToRequestType(
+ panelType: PANEL_TYPES,
+): Querybuildertypesv5RequestTypeDTO {
+ switch (panelType) {
+ case PANEL_TYPES.TIME_SERIES:
+ case PANEL_TYPES.BAR:
+ case PANEL_TYPES.HISTOGRAM:
+ return Querybuildertypesv5RequestTypeDTO.time_series;
+ case PANEL_TYPES.TABLE:
+ case PANEL_TYPES.PIE:
+ case PANEL_TYPES.VALUE:
+ return Querybuildertypesv5RequestTypeDTO.scalar;
+ case PANEL_TYPES.LIST:
+ return Querybuildertypesv5RequestTypeDTO.raw;
+ case PANEL_TYPES.TRACE:
+ return Querybuildertypesv5RequestTypeDTO.trace;
+ default:
+ return Querybuildertypesv5RequestTypeDTO.time_series;
+ }
+}
+
/**
* V5 query-envelope list → V1 `Query`, via `mapQueryDataFromApi`. An empty list opens
* on a fresh metrics builder query. Used by `fromPerses` and by the envelopes a
diff --git a/frontend/src/pages/PublicDashboard/PublicDashboardView/PublicPanel/PublicPanel.tsx b/frontend/src/pages/PublicDashboard/PublicDashboardView/PublicPanel/PublicPanel.tsx
index 0d42aa9a80..a81204f281 100644
--- a/frontend/src/pages/PublicDashboard/PublicDashboardView/PublicPanel/PublicPanel.tsx
+++ b/frontend/src/pages/PublicDashboard/PublicDashboardView/PublicPanel/PublicPanel.tsx
@@ -40,6 +40,7 @@ function PublicPanel({
const { data, isFetching, isPreviousData, error, refetch } =
usePublicPanelQuery({
panel,
+ queryCapabilities: panelDefinition.queryCapabilities,
panelKey,
publicDashboardId,
startMs,
diff --git a/frontend/src/pages/PublicDashboard/PublicDashboardView/hooks/__tests__/usePublicPanelQuery.test.tsx b/frontend/src/pages/PublicDashboard/PublicDashboardView/hooks/__tests__/usePublicPanelQuery.test.tsx
index 65c5b2a3de..558358a315 100644
--- a/frontend/src/pages/PublicDashboard/PublicDashboardView/hooks/__tests__/usePublicPanelQuery.test.tsx
+++ b/frontend/src/pages/PublicDashboard/PublicDashboardView/hooks/__tests__/usePublicPanelQuery.test.tsx
@@ -1,6 +1,9 @@
import { renderHook, waitFor } from '@testing-library/react';
import { getPublicDashboardPanelQueryRangeV2 } from 'api/generated/services/dashboard';
-import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ type DashboardtypesPanelDTO,
+ Querybuildertypesv5RequestTypeDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { ReactNode } from 'react';
import { QueryClient, QueryClientProvider } from 'react-query';
@@ -42,6 +45,15 @@ const panel = {
const args = {
panel,
+ // What TimeSeries declares; passed in rather than resolved from the registry, which
+ // would pull every panel renderer into this suite.
+ queryCapabilities: {
+ requestType: Querybuildertypesv5RequestTypeDTO.time_series,
+ formatTableResultForUI: false,
+ bucketedStepInterval: false,
+ orderTiebreaker: false,
+ serverPaginated: false,
+ },
panelKey: 'panel-1',
publicDashboardId: 'pub-1',
startMs: 1000,
diff --git a/frontend/src/pages/PublicDashboard/PublicDashboardView/hooks/usePublicPanelQuery.ts b/frontend/src/pages/PublicDashboard/PublicDashboardView/hooks/usePublicPanelQuery.ts
index 9488d7283e..e0c3ba63e5 100644
--- a/frontend/src/pages/PublicDashboard/PublicDashboardView/hooks/usePublicPanelQuery.ts
+++ b/frontend/src/pages/PublicDashboard/PublicDashboardView/hooks/usePublicPanelQuery.ts
@@ -3,10 +3,9 @@ import type {
DashboardtypesPanelDTO,
GetPublicDashboardPanelQueryRangeV2200,
} from 'api/generated/services/sigNoz.schemas';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
import { retryUnlessClientError } from 'pages/DashboardPage/DashboardContainer/hooks/useGetQueryRangeV5';
-import { PANEL_KIND_TO_PANEL_TYPE } from 'pages/DashboardPage/DashboardContainer/Panels/types/panelKind';
+import type { PanelQueryCapabilities } from 'pages/DashboardPage/DashboardContainer/Panels/types/panelCapabilities';
import {
buildQueryRangeRequest,
extractLegendMap,
@@ -21,6 +20,8 @@ import { useQuery, useQueryClient } from 'react-query';
export interface UsePublicPanelQueryArgs {
panel: DashboardtypesPanelDTO;
+ /** The panel kind's declared query capabilities — `panelDefinition.queryCapabilities`. */
+ queryCapabilities: PanelQueryCapabilities;
/** Panel key in `spec.panels` — addresses the panel on the public endpoint. */
panelKey: string;
publicDashboardId: string;
@@ -52,15 +53,13 @@ export interface UsePublicPanelQueryResult {
*/
export function usePublicPanelQuery({
panel,
+ queryCapabilities,
panelKey,
publicDashboardId,
startMs,
endMs,
enabled = true,
}: UsePublicPanelQueryArgs): UsePublicPanelQueryResult {
- const fullKind = panel.spec.plugin.kind;
- const panelType =
- (fullKind && PANEL_KIND_TO_PANEL_TYPE[fullKind]) ?? PANEL_TYPES.TIME_SERIES;
const { queries } = panel.spec;
const pluginSpec = panel.spec.plugin.spec;
@@ -77,13 +76,13 @@ export function usePublicPanelQuery({
() =>
buildQueryRangeRequest({
queries,
- panelType,
+ queryCapabilities,
startMs,
endMs,
fillGaps,
variables: {},
}),
- [queries, panelType, startMs, endMs, fillGaps],
+ [queries, queryCapabilities, startMs, endMs, fillGaps],
);
const legendMap = useMemo(() => extractLegendMap(queries), [queries]);