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!);