From df6b62960f4a648ca6d05cd3d4476b8828aa7f6d Mon Sep 17 00:00:00 2001 From: Bena Kansara Date: Mon, 23 Sep 2024 11:47:11 +0200 Subject: [PATCH 1/2] fix equation --- .../observability/public/utils/investigation_item_helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/observability/public/utils/investigation_item_helper.ts b/x-pack/plugins/observability_solution/observability/public/utils/investigation_item_helper.ts index 5ffaa234b3d97..c521225f74b65 100644 --- a/x-pack/plugins/observability_solution/observability/public/utils/investigation_item_helper.ts +++ b/x-pack/plugins/observability_solution/observability/public/utils/investigation_item_helper.ts @@ -26,7 +26,7 @@ const genLensEqForCustomThresholdRule = (criterion: MetricExpression) => { (metric: CustomThresholdExpressionMetric) => (metricNameResolver[metric.name] = `${ AggMappingForLens[metric.aggType] ? AggMappingForLens[metric.aggType] : metric.aggType - }(${metric.field ? metric.field : metric.filter ? metric.filter : ''})`) + }(${metric.field ? metric.field : metric.filter ? `kql='${metric.filter}'` : ''})`) ); let equation = criterion.equation From f7578a8e0ff08cfe6f352baee08a6a9732bb3e5f Mon Sep 17 00:00:00 2001 From: Bena Kansara Date: Mon, 23 Sep 2024 19:19:21 +0200 Subject: [PATCH 2/2] pr feedback --- .../public/utils/investigation_item_helper.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/observability_solution/observability/public/utils/investigation_item_helper.ts b/x-pack/plugins/observability_solution/observability/public/utils/investigation_item_helper.ts index c521225f74b65..cddf3290ed370 100644 --- a/x-pack/plugins/observability_solution/observability/public/utils/investigation_item_helper.ts +++ b/x-pack/plugins/observability_solution/observability/public/utils/investigation_item_helper.ts @@ -22,12 +22,12 @@ const AggMappingForLens: Record = { const genLensEqForCustomThresholdRule = (criterion: MetricExpression) => { const metricNameResolver: Record = {}; - criterion.metrics.forEach( - (metric: CustomThresholdExpressionMetric) => - (metricNameResolver[metric.name] = `${ - AggMappingForLens[metric.aggType] ? AggMappingForLens[metric.aggType] : metric.aggType - }(${metric.field ? metric.field : metric.filter ? `kql='${metric.filter}'` : ''})`) - ); + criterion.metrics.forEach((metric: CustomThresholdExpressionMetric) => { + const metricFilter = metric.filter ? `kql='${metric.filter}'` : ''; + metricNameResolver[metric.name] = `${ + AggMappingForLens[metric.aggType] ? AggMappingForLens[metric.aggType] : metric.aggType + }(${metric.field ? metric.field : metricFilter})`; + }); let equation = criterion.equation ? criterion.equation