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 adding new query in new alert page changing the data source (#6286)

Shaheer Kochai939e2a357028
diff --git a/frontend/src/container/FormAlertRules/index.tsx b/frontend/src/container/FormAlertRules/index.tsx
index 05c4149d73..5572af8365 100644
--- a/frontend/src/container/FormAlertRules/index.tsx
+++ b/frontend/src/container/FormAlertRules/index.tsx
@@ -53,6 +53,7 @@ import {
QueryFunctionProps,
} from 'types/api/queryBuilder/queryBuilderData';
import { EQueryType } from 'types/common/dashboard';
+import { DataSource } from 'types/common/queryBuilder';
import { GlobalReducer } from 'types/reducer/globalTime';
import BasicInfo from './BasicInfo';
@@ -105,6 +106,11 @@ function FormAlertRules({
const location = useLocation();
const queryParams = new URLSearchParams(location.search);
+ const dataSource = useMemo(
+ () => urlQuery.get(QueryParams.alertType) as DataSource,
+ [urlQuery],
+ );
+
// In case of alert the panel types should always be "Graph" only
const panelType = PANEL_TYPES.TIME_SERIES;
@@ -114,13 +120,12 @@ function FormAlertRules({
handleSetQueryData,
handleRunQuery,
handleSetConfig,
- initialDataSource,
redirectWithQueryBuilderData,
} = useQueryBuilder();
useEffect(() => {
- handleSetConfig(panelType || PANEL_TYPES.TIME_SERIES, initialDataSource);
- }, [handleSetConfig, initialDataSource, panelType]);
+ handleSetConfig(panelType || PANEL_TYPES.TIME_SERIES, dataSource);
+ }, [handleSetConfig, dataSource, panelType]);
// use query client
const ruleCache = useQueryClient();