From 3d3ba69a1d24c9d7e12d7a651f973452b629077d Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 24 Oct 2024 02:07:32 +1100 Subject: [PATCH] [8.x] fix(slo): Slices without any data event are considered good (#196942) (#197434) # Backport This will backport the following commits from `main` to `8.x`: - [fix(slo): Slices without any data event are considered good (#196942)](https://github.com/elastic/kibana/pull/196942) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Kevin Delemme --- .../__snapshots__/apm_transaction_duration.test.ts.snap | 4 ++-- .../__snapshots__/apm_transaction_error_rate.test.ts.snap | 4 ++-- .../transform_generators/__snapshots__/histogram.test.ts.snap | 4 ++-- .../__snapshots__/kql_custom.test.ts.snap | 4 ++-- .../__snapshots__/metric_custom.test.ts.snap | 2 +- .../services/transform_generators/apm_transaction_duration.ts | 4 ++-- .../transform_generators/apm_transaction_error_rate.ts | 4 ++-- .../slo/server/services/transform_generators/histogram.ts | 4 ++-- .../slo/server/services/transform_generators/kql_custom.ts | 4 ++-- .../slo/server/services/transform_generators/metric_custom.ts | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/apm_transaction_duration.test.ts.snap b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/apm_transaction_duration.test.ts.snap index e5eba04f5305c..fe0c3a8904c05 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/apm_transaction_duration.test.ts.snap +++ b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/apm_transaction_duration.test.ts.snap @@ -394,7 +394,7 @@ Object { "goodEvents": "slo.numerator.value", "totalEvents": "slo.denominator.value", }, - "script": "params.goodEvents / params.totalEvents >= 0.95 ? 1 : 0", + "script": "if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents >= 0.95 ? 1 : 0 }", }, }, "slo.numerator": Object { @@ -542,7 +542,7 @@ Object { "goodEvents": "slo.numerator.value", "totalEvents": "slo.denominator.value", }, - "script": "params.goodEvents / params.totalEvents > 0 ? 1 : 0", + "script": "if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents > 0 ? 1 : 0 }", }, }, "slo.numerator": Object { diff --git a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/apm_transaction_error_rate.test.ts.snap b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/apm_transaction_error_rate.test.ts.snap index 92c5b8c09385c..a081c2829f2bc 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/apm_transaction_error_rate.test.ts.snap +++ b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/apm_transaction_error_rate.test.ts.snap @@ -358,7 +358,7 @@ Object { "goodEvents": "slo.numerator>_count", "totalEvents": "slo.denominator>_count", }, - "script": "params.goodEvents / params.totalEvents >= 0.95 ? 1 : 0", + "script": "if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents >= 0.95 ? 1 : 0 }", }, }, "slo.numerator": Object { @@ -493,7 +493,7 @@ Object { "goodEvents": "slo.numerator>_count", "totalEvents": "slo.denominator>_count", }, - "script": "params.goodEvents / params.totalEvents > 0 ? 1 : 0", + "script": "if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents > 0 ? 1 : 0 }", }, }, "slo.numerator": Object { diff --git a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/histogram.test.ts.snap b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/histogram.test.ts.snap index 260a9406e7674..43026be44a3bb 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/histogram.test.ts.snap +++ b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/histogram.test.ts.snap @@ -134,7 +134,7 @@ Object { "goodEvents": "slo.numerator>value", "totalEvents": "slo.denominator>value", }, - "script": "params.goodEvents / params.totalEvents >= 0.95 ? 1 : 0", + "script": "if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents >= 0.95 ? 1 : 0 }", }, }, "slo.numerator": Object { @@ -263,7 +263,7 @@ Object { "goodEvents": "slo.numerator>value", "totalEvents": "slo.denominator>value", }, - "script": "params.goodEvents / params.totalEvents > 0 ? 1 : 0", + "script": "if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents > 0 ? 1 : 0 }", }, }, "slo.numerator": Object { diff --git a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/kql_custom.test.ts.snap b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/kql_custom.test.ts.snap index 26fb5dde0f784..95e1e3abf6aa5 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/kql_custom.test.ts.snap +++ b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/kql_custom.test.ts.snap @@ -140,7 +140,7 @@ Object { "goodEvents": "slo.numerator>_count", "totalEvents": "slo.denominator>_count", }, - "script": "params.goodEvents / params.totalEvents >= 0.95 ? 1 : 0", + "script": "if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents >= 0.95 ? 1 : 0 }", }, }, "slo.numerator": Object { @@ -242,7 +242,7 @@ Object { "goodEvents": "slo.numerator>_count", "totalEvents": "slo.denominator>_count", }, - "script": "params.goodEvents / params.totalEvents > 0 ? 1 : 0", + "script": "if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents > 0 ? 1 : 0 }", }, }, "slo.numerator": Object { diff --git a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/metric_custom.test.ts.snap b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/metric_custom.test.ts.snap index c1317435fb97b..4b7dab85cec60 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/metric_custom.test.ts.snap +++ b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/__snapshots__/metric_custom.test.ts.snap @@ -181,7 +181,7 @@ Object { "goodEvents": "slo.numerator>value", "totalEvents": "slo.denominator>value", }, - "script": "params.goodEvents / params.totalEvents >= 0.95 ? 1 : 0", + "script": "if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents >= 0.95 ? 1 : 0 }", }, }, "slo.numerator": Object { diff --git a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/apm_transaction_duration.ts b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/apm_transaction_duration.ts index 85496cb91f6e4..b349a5affeceb 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/apm_transaction_duration.ts +++ b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/apm_transaction_duration.ts @@ -185,9 +185,9 @@ export class ApmTransactionDurationTransformGenerator extends TransformGenerator goodEvents: 'slo.numerator.value', totalEvents: 'slo.denominator.value', }, - script: `params.goodEvents / params.totalEvents ${getTimesliceTargetComparator( + script: `if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents ${getTimesliceTargetComparator( slo.objective.timesliceTarget! - )} ${slo.objective.timesliceTarget} ? 1 : 0`, + )} ${slo.objective.timesliceTarget} ? 1 : 0 }`, }, }, }), diff --git a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/apm_transaction_error_rate.ts b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/apm_transaction_error_rate.ts index 91b4af3a07aff..3aa0d4507e8a4 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/apm_transaction_error_rate.ts +++ b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/apm_transaction_error_rate.ts @@ -168,9 +168,9 @@ export class ApmTransactionErrorRateTransformGenerator extends TransformGenerato goodEvents: 'slo.numerator>_count', totalEvents: 'slo.denominator>_count', }, - script: `params.goodEvents / params.totalEvents ${getTimesliceTargetComparator( + script: `if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents ${getTimesliceTargetComparator( slo.objective.timesliceTarget! - )} ${slo.objective.timesliceTarget} ? 1 : 0`, + )} ${slo.objective.timesliceTarget} ? 1 : 0 }`, }, }, }), diff --git a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/histogram.ts b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/histogram.ts index c7c97639b92a8..b19f9a48e70f0 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/histogram.ts +++ b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/histogram.ts @@ -101,9 +101,9 @@ export class HistogramTransformGenerator extends TransformGenerator { goodEvents: 'slo.numerator>value', totalEvents: 'slo.denominator>value', }, - script: `params.goodEvents / params.totalEvents ${getTimesliceTargetComparator( + script: `if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents ${getTimesliceTargetComparator( slo.objective.timesliceTarget! - )} ${slo.objective.timesliceTarget} ? 1 : 0`, + )} ${slo.objective.timesliceTarget} ? 1 : 0 }`, }, }, }), diff --git a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/kql_custom.ts b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/kql_custom.ts index 1924bc1a4c344..0082e13968c80 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/kql_custom.ts +++ b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/kql_custom.ts @@ -94,9 +94,9 @@ export class KQLCustomTransformGenerator extends TransformGenerator { goodEvents: 'slo.numerator>_count', totalEvents: 'slo.denominator>_count', }, - script: `params.goodEvents / params.totalEvents ${getTimesliceTargetComparator( + script: `if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents ${getTimesliceTargetComparator( slo.objective.timesliceTarget! - )} ${slo.objective.timesliceTarget} ? 1 : 0`, + )} ${slo.objective.timesliceTarget} ? 1 : 0 }`, }, }, }), diff --git a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/metric_custom.ts b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/metric_custom.ts index 5717b05a466de..e96f252d5ed84 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/transform_generators/metric_custom.ts +++ b/x-pack/plugins/observability_solution/slo/server/services/transform_generators/metric_custom.ts @@ -105,9 +105,9 @@ export class MetricCustomTransformGenerator extends TransformGenerator { goodEvents: 'slo.numerator>value', totalEvents: 'slo.denominator>value', }, - script: `params.goodEvents / params.totalEvents ${getTimesliceTargetComparator( + script: `if (params.totalEvents == 0) { return 1 } else { return params.goodEvents / params.totalEvents ${getTimesliceTargetComparator( slo.objective.timesliceTarget! - )} ${slo.objective.timesliceTarget} ? 1 : 0`, + )} ${slo.objective.timesliceTarget} ? 1 : 0 }`, }, }, }),