From f24f59225dd0c743e78ebe988bc83fea294d9031 Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:07:16 +0300 Subject: [PATCH] [v11.3.x] Alerting: Fix getSimpleConditionFromExpressions (#94584) Alerting: Fix getSimpleConditionFromExpressions (#94516) fix getSimpleConditionFromExpressions (cherry picked from commit 419598c7453523027f7668d59ca5b4239678ca3e) Co-authored-by: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> --- .../query-and-alert-condition/SimpleCondition.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SimpleCondition.tsx b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SimpleCondition.tsx index 7307675defd..1e745c46da6 100644 --- a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SimpleCondition.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SimpleCondition.tsx @@ -218,11 +218,17 @@ export function getSimpleConditionFromExpressions(expressions: Array query.model.type === ExpressionQueryType.threshold && query.refId === SIMPLE_CONDITION_THRESHOLD_ID ); const conditionsFromThreshold = thresholdExpression?.model.conditions ?? []; + const whenField = reduceExpression?.model.reducer ?? ReducerID.last; + const params = conditionsFromThreshold[0]?.evaluator?.params + ? [...conditionsFromThreshold[0]?.evaluator?.params] + : [0]; + const type = conditionsFromThreshold[0]?.evaluator?.type ?? EvalFunction.IsAbove; + return { - whenField: reduceExpression?.model.reducer ?? ReducerID.last, + whenField: whenField, evaluator: { - params: [...conditionsFromThreshold[0]?.evaluator?.params] ?? [0], - type: conditionsFromThreshold[0]?.evaluator?.type ?? EvalFunction.IsAbove, + params: params, + type: type, }, }; }