Skip to content

Commit

Permalink
[Inventory rule] Fix alerts not being visible when number of alerts a…
Browse files Browse the repository at this point in the history
…re more than max alert limit (elastic#178019)

Fixes elastic#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
elastic#171960.


![image](https://github.com/elastic/kibana/assets/12370520/e99c05b0-20c3-4ee9-8500-ffb6f8975d19)


![image](https://github.com/elastic/kibana/assets/12370520/5ee856e2-1af1-41bb-b5a3-4008f089be78)
  • Loading branch information
maryam-saeidi authored Mar 5, 2024
1 parent 4cc38e7 commit f2de742
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const createInventoryMetricThresholdExecutor = (libs: InfraBackendLibs) =
getAlertStartedDate,
getAlertUuid,
getAlertByAlertUuid,
alertFactory: baseAlertFactory,
} = services;
const alertFactory: InventoryMetricThresholdAlertFactory = (
id,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -300,6 +308,7 @@ export const createInventoryMetricThresholdExecutor = (libs: InfraBackendLibs) =
}
}

baseAlertFactory.alertLimit.setLimitReached(hasReachedLimit);
const { getRecoveredAlerts } = services.alertFactory.done();
const recoveredAlerts = getRecoveredAlerts();

Expand Down

0 comments on commit f2de742

Please sign in to comment.