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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix(alerts): invalidate rule cache after disable/enable toggle (#11295)
Jatinderjit Singhb572e300454f
diff --git a/frontend/src/container/ListAlertRules/ToggleAlertState.tsx b/frontend/src/container/ListAlertRules/ToggleAlertState.tsxindex 6040dde63f..a642c6fc8a 100644--- a/frontend/src/container/ListAlertRules/ToggleAlertState.tsx+++ b/frontend/src/container/ListAlertRules/ToggleAlertState.tsx@@ -1,6 +1,8 @@import { Dispatch, SetStateAction, useState } from 'react';+import { useQueryClient } from 'react-query';import { patchRulePartial } from 'api/alerts/patchRulePartial';import { convertToApiError } from 'api/ErrorResponseHandlerForGeneratedAPIs';+import { invalidateGetRuleByID } from 'api/generated/services/rules';import type {RenderErrorResponseDTO,RuletypesRuleDTO,@@ -28,6 +30,7 @@ function ToggleAlertState({const { notifications } = useNotifications();const { showErrorModal } = useErrorModal();+ const queryClient = useQueryClient();const onToggleHandler = async (id: string,@@ -60,6 +63,9 @@ function ToggleAlertState({loading: false,payload: updatedRule,}));++ invalidateGetRuleByID(queryClient, { id });+notifications.success({message: 'Success',});diff --git a/frontend/src/pages/AlertDetails/hooks.tsx b/frontend/src/pages/AlertDetails/hooks.tsxindex 1a9d33195b..9facd099c9 100644--- a/frontend/src/pages/AlertDetails/hooks.tsx+++ b/frontend/src/pages/AlertDetails/hooks.tsx@@ -12,6 +12,7 @@ import { convertToApiError } from 'api/ErrorResponseHandlerForGeneratedAPIs';import {createRule,deleteRuleByID,+ invalidateGetRuleByID,updateRuleByID,useGetRuleByID,useListRules,@@ -408,6 +409,7 @@ export const useAlertRuleStatusToggle = ({{onSuccess: (data) => {setAlertRuleState(data.data.state);+ invalidateGetRuleByID(queryClient, { id: ruleId });queryClient.refetchQueries([REACT_QUERY_KEY.ALERT_RULE_DETAILS, ruleId]);notifications.success({message: `Alert has been ${@@ -416,6 +418,7 @@ export const useAlertRuleStatusToggle = ({});},onError: (error) => {+ invalidateGetRuleByID(queryClient, { id: ruleId });queryClient.refetchQueries([REACT_QUERY_KEY.ALERT_RULE_DETAILS, ruleId]);showErrorModal(convertToApiError(error as AxiosError<RenderErrorResponseDTO>) as APIError,