mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Inventory rule] Fix alerts not being visible when number of alerts are more than max alert limit (#178019)
Fixes #171976 ## Summary Fixes issue when the number of alerts is more than the max number in the inventory rule similar to what was done in https://github.com/elastic/kibana/pull/171960.  
This commit is contained in:
parent
4cc38e7025
commit
f2de74259f
1 changed files with 9 additions and 0 deletions
|
@ -104,6 +104,7 @@ export const createInventoryMetricThresholdExecutor = (libs: InfraBackendLibs) =
|
|||
getAlertStartedDate,
|
||||
getAlertUuid,
|
||||
getAlertByAlertUuid,
|
||||
alertFactory: baseAlertFactory,
|
||||
} = services;
|
||||
const alertFactory: InventoryMetricThresholdAlertFactory = (
|
||||
id,
|
||||
|
@ -194,8 +195,15 @@ export const createInventoryMetricThresholdExecutor = (libs: InfraBackendLibs) =
|
|||
);
|
||||
|
||||
let scheduledActionsCount = 0;
|
||||
const alertLimit = baseAlertFactory.alertLimit.getValue();
|
||||
let hasReachedLimit = false;
|
||||
const inventoryItems = Object.keys(first(results)!);
|
||||
for (const group of inventoryItems) {
|
||||
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 = results.every((result) => result[group]?.shouldFire);
|
||||
const shouldAlertWarn = results.every((result) => result[group]?.shouldWarn);
|
||||
|
@ -300,6 +308,7 @@ export const createInventoryMetricThresholdExecutor = (libs: InfraBackendLibs) =
|
|||
}
|
||||
}
|
||||
|
||||
baseAlertFactory.alertLimit.setLimitReached(hasReachedLimit);
|
||||
const { getRecoveredAlerts } = services.alertFactory.done();
|
||||
const recoveredAlerts = getRecoveredAlerts();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue