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: fix the issue of group by queries not switching to timeseries view in logs and traces explorer (#8870)

Shaheer Kochai17533b2f1cf0
diff --git a/frontend/src/container/LogsExplorerViews/index.tsx b/frontend/src/container/LogsExplorerViews/index.tsx
index 29b3f466b4..f300e2b40a 100644
--- a/frontend/src/container/LogsExplorerViews/index.tsx
+++ b/frontend/src/container/LogsExplorerViews/index.tsx
@@ -478,8 +478,7 @@ function LogsExplorerViewsContainer({
);
useEffect(() => {
- const shouldChangeView =
- (isMultipleQueries || isGroupByExist) && selectedView !== ExplorerViews.LIST;
+ const shouldChangeView = isMultipleQueries || isGroupByExist;
if (selectedPanelType === PANEL_TYPES.LIST && shouldChangeView) {
handleExplorerTabChange(PANEL_TYPES.TIME_SERIES);
diff --git a/frontend/src/pages/TracesExplorer/index.tsx b/frontend/src/pages/TracesExplorer/index.tsx
index 671202e917..6c4c04a596 100644
--- a/frontend/src/pages/TracesExplorer/index.tsx
+++ b/frontend/src/pages/TracesExplorer/index.tsx
@@ -219,6 +219,35 @@ function TracesExplorer(): JSX.Element {
useShareBuilderUrl({ defaultValue: defaultQuery, forceReset: shouldReset });
+ const isMultipleQueries = useMemo(() => {
+ const builder = currentQuery?.builder;
+ const queriesLen = builder?.queryData?.length ?? 0;
+ const formulasLen = builder?.queryFormulas?.length ?? 0;
+ return queriesLen > 1 || formulasLen > 0;
+ }, [currentQuery]);
+
+ const isGroupByExist = useMemo(() => {
+ const queryData = currentQuery?.builder?.queryData ?? [];
+ return queryData.some((q) => (q?.groupBy?.length ?? 0) > 0);
+ }, [currentQuery]);
+ useEffect(() => {
+ const shouldChangeView = isMultipleQueries || isGroupByExist;
+
+ if (
+ (selectedView === ExplorerViews.LIST ||
+ selectedView === ExplorerViews.TRACE) &&
+ shouldChangeView
+ ) {
+ // Switch to timeseries view automatically
+ handleChangeSelectedView(ExplorerViews.TIMESERIES);
+ }
+ }, [
+ selectedView,
+ isMultipleQueries,
+ isGroupByExist,
+ handleChangeSelectedView,
+ ]);
+
useEffect(() => {
if (shouldReset) {
setShouldReset(false);