From 1a82bb476782e9e466420c1c863bf640d58e2f19 Mon Sep 17 00:00:00 2001 From: Alexander Akhmetov Date: Mon, 18 Aug 2025 11:42:28 +0200 Subject: [PATCH] Alerting: Fix duplication of imported Prometheus alert rules (#109770) --- .../rule-editor/query-and-alert-condition/reducer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts index b3499b8c520..372e028bbcc 100644 --- a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts @@ -247,8 +247,9 @@ export const queriesAndExpressionsReducer = createReducer(initialState, (builder const dataQuery = updatedQueries.at(0); const isInstantDataQuery = dataQuery ? getInstantFromDataQuery(dataQuery) : false; + const hasReducer = expressionQueries.some((q) => isReducerExpression(q.model)); + const shouldRemoveReducer = isInstantDataQuery && expressionQueries.length === 2 && hasReducer; - const shouldRemoveReducer = isInstantDataQuery && expressionQueries.length === 2; if (shouldRemoveReducer) { const reduceExpressionIndex = state.queries.findIndex( (query) =>