From f0f585697cd47362ad30f1ce5961ea297c049595 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 24 Sep 2024 02:24:39 +1000 Subject: [PATCH] [8.15] [ML][Rules] Fixes deletion in Check interval input for anomaly detection rule (#193420) (#193730) # Backport This will backport the following commits from `main` to `8.15`: - [[ML][Rules] Fixes deletion in Check interval input for anomaly detection rule (#193420)](https://github.com/elastic/kibana/pull/193420) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com> --- .../alerting/anomaly_detection_rule/config_validator.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/config_validator.tsx b/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/config_validator.tsx index 88b1502ac3b99..04e96546196bb 100644 --- a/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/config_validator.tsx +++ b/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/config_validator.tsx @@ -32,13 +32,15 @@ export const ConfigValidator: FC = React.memo( ({ jobConfigs = [], alertInterval, alertParams, alertNotifyWhen, maxNumberOfBuckets }) => { if (jobConfigs.length === 0) return null; - const alertIntervalInSeconds = parseInterval(alertInterval)!.asSeconds(); + const alertIntervalInSeconds = parseInterval(alertInterval)?.asSeconds(); const lookbackIntervalInSeconds = !!alertParams.lookbackInterval && parseInterval(alertParams.lookbackInterval)?.asSeconds(); const isAlertIntervalTooHigh = - lookbackIntervalInSeconds && lookbackIntervalInSeconds < alertIntervalInSeconds; + lookbackIntervalInSeconds && + alertIntervalInSeconds && + lookbackIntervalInSeconds < alertIntervalInSeconds; const jobWithoutStartedDatafeed = jobConfigs .filter((job) => job.datafeed_config.state !== DATAFEED_STATE.STARTED) @@ -49,6 +51,7 @@ export const ConfigValidator: FC = React.memo( const notifyWhenWarning = alertNotifyWhen === 'onActiveAlert' && lookbackIntervalInSeconds && + alertIntervalInSeconds && alertIntervalInSeconds < lookbackIntervalInSeconds; const bucketSpanDuration = parseInterval(jobConfigs[0].analysis_config.bucket_span!);