Skip to content

Commit

Permalink
[8.x] [ML][Rules] Fixes deletion in Check interval input for anomaly …
Browse files Browse the repository at this point in the history
…detection rule (#193420) (#193731)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML][Rules] Fixes deletion in Check interval input for anomaly
detection rule (#193420)](#193420)

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

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

<!--BACKPORT [{"author":{"name":"Robert
Jaszczurek","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-23T14:27:01Z","message":"[ML][Rules]
Fixes deletion in Check interval input for anomaly detection rule
(#193420)\n\n## Summary\r\n\r\nIt was trying to parse `null`
values.\r\nAfter:\r\n\r\n![image](https://github.com/user-attachments/assets/82d24663-a895-4ad4-bc01-fb76b883bc66)\r\n\r\nFixes
[#190732](https://github.com/elastic/kibana/issues/190732)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"65b7bf9586480b522393905ff21324f473ee90ed","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","v9.0.0","Team:ML","backport:prev-major"],"title":"[ML][Rules]
Fixes deletion in Check interval input for anomaly detection
rule","number":193420,"url":"https://github.com/elastic/kibana/pull/193420","mergeCommit":{"message":"[ML][Rules]
Fixes deletion in Check interval input for anomaly detection rule
(#193420)\n\n## Summary\r\n\r\nIt was trying to parse `null`
values.\r\nAfter:\r\n\r\n![image](https://github.com/user-attachments/assets/82d24663-a895-4ad4-bc01-fb76b883bc66)\r\n\r\nFixes
[#190732](https://github.com/elastic/kibana/issues/190732)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"65b7bf9586480b522393905ff21324f473ee90ed"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193420","number":193420,"mergeCommit":{"message":"[ML][Rules]
Fixes deletion in Check interval input for anomaly detection rule
(#193420)\n\n## Summary\r\n\r\nIt was trying to parse `null`
values.\r\nAfter:\r\n\r\n![image](https://github.com/user-attachments/assets/82d24663-a895-4ad4-bc01-fb76b883bc66)\r\n\r\nFixes
[#190732](https://github.com/elastic/kibana/issues/190732)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"65b7bf9586480b522393905ff21324f473ee90ed"}}]}]
BACKPORT-->

Co-authored-by: Robert Jaszczurek <[email protected]>
  • Loading branch information
kibanamachine and rbrtj authored Sep 23, 2024
1 parent 1143a10 commit 49051ea
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ export const ConfigValidator: FC<ConfigValidatorProps> = 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)
Expand All @@ -49,6 +51,7 @@ export const ConfigValidator: FC<ConfigValidatorProps> = React.memo(
const notifyWhenWarning =
alertNotifyWhen === 'onActiveAlert' &&
lookbackIntervalInSeconds &&
alertIntervalInSeconds &&
alertIntervalInSeconds < lookbackIntervalInSeconds;

const bucketSpanDuration = parseInterval(jobConfigs[0].analysis_config.bucket_span!);
Expand Down

0 comments on commit 49051ea

Please sign in to comment.