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.

fix(dashboard-v2): panel drilldown fixes + New Panel modal one-click create (#12026)

Abhi kumar08de39cdbd59
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx
index 1e7dd508ad..a506c62f9d 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx
@@ -146,9 +146,14 @@ function BarPanelRenderer({
const renderTooltipFooter = useCallback(
({ isPinned, dismiss }: IRenderTooltipFooterArgs) => (
- <TooltipFooter id={panelId} isPinned={isPinned} dismiss={dismiss} />
+ <TooltipFooter
+ id={panelId}
+ isPinned={isPinned}
+ canDrilldown={!!enableDrillDown}
+ dismiss={dismiss}
+ />
),
- [panelId],
+ [panelId, enableDrillDown],
);
// Keying on sync prefs forces a full chart teardown/re-mount so stale sync
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/__tests__/prepareData.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/__tests__/prepareData.test.ts
index 35d0c82c6f..7a4005b1ab 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/__tests__/prepareData.test.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/__tests__/prepareData.test.ts
@@ -127,4 +127,37 @@ describe('preparePieData', () => {
it('returns no slices for empty tables', () => {
expect(preparePieData(args([]))).toStrictEqual([]);
});
+
+ it('carries the value column query name and group-by labels for drilldown', () => {
+ const table = tableWith(
+ [
+ {
+ name: 'service.name',
+ queryName: 'A',
+ isValueColumn: false,
+ id: 'service.name',
+ },
+ { name: 'count', queryName: 'A', isValueColumn: true, id: 'A' },
+ ],
+ [{ data: { 'service.name': 'adservice', A: 100 } }],
+ );
+
+ const [slice] = preparePieData(args([table]));
+
+ expect(slice.queryName).toBe('A');
+ expect(slice.labels).toStrictEqual({ 'service.name': 'adservice' });
+ });
+
+ it('leaves labels empty for an ungrouped slice', () => {
+ const table = tableWith(
+ [{ name: 'count', queryName: 'A', isValueColumn: true, id: 'A' }],
+ [{ data: { A: 42 } }],
+ { legend: 'requests' },
+ );
+
+ const [slice] = preparePieData(args([table]));
+
+ expect(slice.queryName).toBe('A');
+ expect(slice.labels).toStrictEqual({});
+ });
});
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/prepareData.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/prepareData.ts
index 3823433775..bfb22f5e85 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/prepareData.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/prepareData.ts
@@ -37,6 +37,15 @@ export function preparePieData({
.map(String)
.join(', ');
+ // Group-by key→value, keyed by field name for drilldown filters (`enrichPieClick`).
+ const labels: Record<string, string> = {};
+ labelColumns.forEach((column) => {
+ const value = row.data[column.id || column.name];
+ if (value != null) {
+ labels[column.name] = String(value as string | number);
+ }
+ });
+
valueColumns.forEach((column) => {
let label: string;
if (hasMultipleValueColumns) {
@@ -50,6 +59,8 @@ export function preparePieData({
label,
value: Number(row.data[column.id || column.name]),
color,
+ queryName: column.queryName,
+ labels,
});
});
});
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx
index 64f83aa724..c155dc7dc1 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx
@@ -147,9 +147,14 @@ function TimeSeriesPanelRenderer({
const renderTooltipFooter = useCallback(
({ isPinned, dismiss }: IRenderTooltipFooterArgs) => (
- <TooltipFooter id={panelId} isPinned={isPinned} dismiss={dismiss} />
+ <TooltipFooter
+ id={panelId}
+ isPinned={isPinned}
+ canDrilldown={!!enableDrillDown}
+ dismiss={dismiss}
+ />
),
- [panelId],
+ [panelId, enableDrillDown],
);
// Keying on sync prefs forces a full chart teardown/re-mount so stale sync
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModal.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModal.tsx
index 1529ea0806..4b49f246e7 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModal.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModal.tsx
@@ -27,6 +27,11 @@ function PanelTypeSelectionModal({
const sections = useDashboardSections();
const options = useMemo(() => buildSectionOptions(sections), [sections]);
+ // With more than one section the user must pick a target section, so we keep
+ // the select-then-confirm flow. Otherwise there's nothing to choose: hide the
+ // footer and let a tile click create the panel outright.
+ const hasSectionPicker = options.length > 1;
+
const [selectedValue, setSelectedValue] = useState('');
const [selectedPanelKind, setSelectedPanelKind] = useState<PanelKind | null>(
null,
@@ -40,12 +45,24 @@ function PanelTypeSelectionModal({
}
}, [open, options, defaultLayoutIndex]);
+ const createPanel = (panelKind: PanelKind): void => {
+ const layoutIndex = selectedValue === '' ? undefined : Number(selectedValue);
+ onSelect(panelKind, layoutIndex);
+ };
+
+ const handleTileClick = (panelKind: PanelKind): void => {
+ if (hasSectionPicker) {
+ setSelectedPanelKind(panelKind);
+ return;
+ }
+ createPanel(panelKind);
+ };
+
const handleConfirm = (): void => {
if (selectedPanelKind === null) {
return;
}
- const layoutIndex = selectedValue === '' ? undefined : Number(selectedValue);
- onSelect(selectedPanelKind, layoutIndex);
+ createPanel(selectedPanelKind);
};
return (
@@ -58,17 +75,21 @@ function PanelTypeSelectionModal({
}}
title="New Panel"
footer={
- <PanelTypeSelectionModalFooter
- options={options}
- selectedValue={selectedValue}
- onSectionChange={setSelectedValue}
- isConfirmDisabled={selectedPanelKind === null}
- onConfirm={handleConfirm}
- />
+ hasSectionPicker ? (
+ <PanelTypeSelectionModalFooter
+ options={options}
+ selectedValue={selectedValue}
+ onSectionChange={setSelectedValue}
+ isConfirmDisabled={selectedPanelKind === null}
+ onConfirm={handleConfirm}
+ />
+ ) : undefined
}
>
<div className={styles.panelTypeSection}>
- <span className={styles.pickerLabel}>Select panel type</span>
+ {hasSectionPicker && (
+ <span className={styles.pickerLabel}>Select panel type</span>
+ )}
<div className={styles.grid}>
{PANEL_TYPES.map(({ panelKind, label, Icon }) => (
<button
@@ -79,7 +100,7 @@ function PanelTypeSelectionModal({
})}
data-testid={`panel-type-${panelKind}`}
aria-pressed={panelKind === selectedPanelKind}
- onClick={(): void => setSelectedPanelKind(panelKind)}
+ onClick={(): void => handleTileClick(panelKind)}
>
<Icon size={24} color={Color.BG_ROBIN_400} />
{label}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModalFooter.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModalFooter.tsx
index bdea492f82..e5a647fd6e 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModalFooter.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModalFooter.tsx
@@ -15,8 +15,9 @@ interface PanelTypeSelectionModalFooterProps {
}
/**
- * Footer for the New Panel modal: an "Add panel to" section picker (shown only
- * when the dashboard has more than one section) and the confirm button.
+ * Footer for the New Panel modal: an "Add panel to" section picker and the
+ * confirm button. Only rendered when the dashboard has more than one section —
+ * otherwise there's nothing to pick and a tile click creates the panel directly.
*/
function PanelTypeSelectionModalFooter({
options,
@@ -25,20 +26,16 @@ function PanelTypeSelectionModalFooter({
isConfirmDisabled,
onConfirm,
}: PanelTypeSelectionModalFooterProps): JSX.Element {
- const hasSectionPicker = options.length > 1;
-
return (
<div className={styles.footerActions}>
- {hasSectionPicker && (
- <div className={styles.footerPicker}>
- <span className={styles.pickerLabel}>Add panel to</span>
- <SectionPicker
- options={options}
- value={selectedValue}
- onChange={onSectionChange}
- />
- </div>
- )}
+ <div className={styles.footerPicker}>
+ <span className={styles.pickerLabel}>Add panel to</span>
+ <SectionPicker
+ options={options}
+ value={selectedValue}
+ onChange={onSectionChange}
+ />
+ </div>
<Button
color="primary"
size="md"
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/__tests__/useDrilldown.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/__tests__/useDrilldown.test.tsx
index 8d26c14559..0e17ec6103 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/__tests__/useDrilldown.test.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/__tests__/useDrilldown.test.tsx
@@ -6,12 +6,14 @@ import {
} from 'api/generated/services/sigNoz.schemas';
import { PANEL_TYPES } from 'constants/queryBuilder';
import type { DrilldownContext } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/drilldown';
+import { EQueryType } from 'types/common/dashboard';
import { useDrilldown } from '../hooks/useDrilldown';
const mockOpenViewWithQuery = jest.fn();
const mockNavigate = jest.fn();
const mockGetBuilderQueries = jest.fn();
+const mockGetPanelQueryType = jest.fn();
let mockResolved = { resolvedQuery: 'RESOLVED_QUERY', isResolving: false };
let mockDashboardVariables: {
hasFieldVariables: boolean;
@@ -95,6 +97,13 @@ jest.mock(
mockGetBuilderQueries(...args),
}),
);
+jest.mock(
+ 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getPanelQueryType',
+ () => ({
+ getPanelQueryType: (...args: unknown[]): unknown =>
+ mockGetPanelQueryType(...args),
+ }),
+);
// Capability lookup mocked (its per-kind values are data in the definitions); avoids
// importing the whole renderer registry into the test.
jest.mock('pages/DashboardPageV2/DashboardContainer/Panels/registry', () => ({
@@ -133,6 +142,7 @@ describe('useDrilldown', () => {
beforeEach(() => {
jest.clearAllMocks();
mockGetBuilderQueries.mockReturnValue([{ name: 'A' }]);
+ mockGetPanelQueryType.mockReturnValue(EQueryType.QUERY_BUILDER);
mockResolved = { resolvedQuery: 'RESOLVED_QUERY', isResolving: false };
mockDashboardVariables = {
hasFieldVariables: true,
@@ -152,6 +162,15 @@ describe('useDrilldown', () => {
expect(result.current.enableDrillDown).toBe(false);
});
+ it.each([EQueryType.PROM, EQueryType.CLICKHOUSE, undefined])(
+ 'is false when the query type is %s (not the builder)',
+ (queryType) => {
+ mockGetPanelQueryType.mockReturnValue(queryType);
+ const { result } = renderHook(() => useDrilldown(tsPanel, 'p1'));
+ expect(result.current.enableDrillDown).toBe(false);
+ },
+ );
+
it('is false for a kind that opts out of drilldown', () => {
const { result } = renderHook(() =>
useDrilldown(panelOfKind('signoz/ListPanel'), 'p1'),
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDrilldown.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDrilldown.tsx
index 8351c9e625..6d379a9559 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDrilldown.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useDrilldown.tsx
@@ -16,7 +16,9 @@ import { PANEL_KIND_TO_PANEL_TYPE } from 'pages/DashboardPageV2/DashboardContain
import { getPanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/registry';
import { buildAggregateData } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/drilldown/buildAggregateData';
import { getBuilderQueries } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries';
+import { getPanelQueryType } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getPanelQueryType';
import { fromPerses } from 'pages/DashboardPageV2/DashboardContainer/queryV5/persesQueryAdapters';
+import { EQueryType } from 'types/common/dashboard';
import DrilldownAggregateMenu from '../DrilldownMenu/DrilldownAggregateMenu';
import DrilldownBreakoutMenu from '../DrilldownMenu/DrilldownBreakoutMenu';
@@ -76,12 +78,14 @@ export function useDrilldown(
const panelType = PANEL_KIND_TO_PANEL_TYPE[kind];
const queries = panel.spec.queries;
- // Kind must opt in via its capability AND have a builder query to drill into.
+ // Drilldown only for builder-authored panels with a query to drill into (PromQL /
+ // ClickHouse have no builder context to refine).
const enableDrillDown = useMemo(
() =>
getPanelDefinition(kind).actions.drilldown &&
+ getPanelQueryType(panel) === EQueryType.QUERY_BUILDER &&
getBuilderQueries(queries).length > 0,
- [kind, queries],
+ [kind, panel, queries],
);
const v1Query = useMemo(