Skip to content

Commit

Permalink
[8.x] [RCA] Fix equation for rule condition chart (#193689) (#193888)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[RCA] Fix equation for rule condition chart
(#193689)](#193689)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Bena
Kansara","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-24T14:59:35Z","message":"[RCA]
Fix equation for rule condition chart (#193689)\n\nResolves
https://github.com/elastic/kibana/issues/193688","sha":"913b6fed50cbbbc6e05811fa013311e98389e7d0","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","ci:project-deploy-observability","Team:obs-ux-management","v8.16.0","backport:version"],"title":"[RCA]
Fix equation for rule condition
chart","number":193689,"url":"https://github.com/elastic/kibana/pull/193689","mergeCommit":{"message":"[RCA]
Fix equation for rule condition chart (#193689)\n\nResolves
https://github.com/elastic/kibana/issues/193688","sha":"913b6fed50cbbbc6e05811fa013311e98389e7d0"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193689","number":193689,"mergeCommit":{"message":"[RCA]
Fix equation for rule condition chart (#193689)\n\nResolves
https://github.com/elastic/kibana/issues/193688","sha":"913b6fed50cbbbc6e05811fa013311e98389e7d0"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Bena Kansara <[email protected]>
  • Loading branch information
kibanamachine and benakansara authored Sep 24, 2024
1 parent 0b4ac42 commit 7757bdb
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const AggMappingForLens: Record<string, string> = {
const genLensEqForCustomThresholdRule = (criterion: MetricExpression) => {
const metricNameResolver: Record<string, string> = {};

criterion.metrics.forEach(
(metric: CustomThresholdExpressionMetric) =>
(metricNameResolver[metric.name] = `${
AggMappingForLens[metric.aggType] ? AggMappingForLens[metric.aggType] : metric.aggType
}(${metric.field ? metric.field : metric.filter ? 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
Expand Down

0 comments on commit 7757bdb

Please sign in to comment.