mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.12`: - [[Custom Threshold Rule] Account for max alerts limits (#171960)](https://github.com/elastic/kibana/pull/171960) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2023-12-11T09:00:34Z","message":"[Custom Threshold Rule] Account for max alerts limits (#171960)","sha":"c1bab7b1f03bf355fd39ae20ea258a1effa0c410","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","Team:obs-ux-management","v8.13.0"],"number":171960,"url":"https://github.com/elastic/kibana/pull/171960","mergeCommit":{"message":"[Custom Threshold Rule] Account for max alerts limits (#171960)","sha":"c1bab7b1f03bf355fd39ae20ea258a1effa0c410"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/171960","number":171960,"mergeCommit":{"message":"[Custom Threshold Rule] Account for max alerts limits (#171960)","sha":"c1bab7b1f03bf355fd39ae20ea258a1effa0c410"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com>
This commit is contained in:
parent
92e4828f40
commit
59564402ab
1 changed files with 12 additions and 0 deletions
|
@ -99,6 +99,7 @@ export const createCustomThresholdExecutor = ({
|
|||
getAlertByAlertUuid,
|
||||
getAlertStartedDate,
|
||||
searchSourceClient,
|
||||
alertFactory: baseAlertFactory,
|
||||
} = services;
|
||||
|
||||
const alertFactory: CustomThresholdAlertFactory = (
|
||||
|
@ -177,8 +178,17 @@ export const createCustomThresholdExecutor = ({
|
|||
const hasGroups = !isEqual(groups, [UNGROUPED_FACTORY_KEY]);
|
||||
let scheduledActionsCount = 0;
|
||||
|
||||
const alertLimit = baseAlertFactory.alertLimit.getValue();
|
||||
let hasReachedLimit = false;
|
||||
|
||||
// The key of `groups` is the alert instance ID.
|
||||
for (const group of groups) {
|
||||
if (scheduledActionsCount >= alertLimit) {
|
||||
// need to set this so that warning is displayed in the UI and in the logs
|
||||
hasReachedLimit = true;
|
||||
break; // once limit is reached, we break out of the loop and don't schedule any more alerts
|
||||
}
|
||||
|
||||
// AND logic; all criteria must be across the threshold
|
||||
const shouldAlertFire = alertResults.every((result) => result[group]?.shouldFire);
|
||||
// AND logic; because we need to evaluate all criteria, if one of them reports no data then the
|
||||
|
@ -296,6 +306,8 @@ export const createCustomThresholdExecutor = ({
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
baseAlertFactory.alertLimit.setLimitReached(hasReachedLimit);
|
||||
const { getRecoveredAlerts } = services.alertFactory.done();
|
||||
const recoveredAlerts = getRecoveredAlerts();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue