Skip to content

Commit

Permalink
[Response Ops][Alerting] Only load maintenance windows when there are…
Browse files Browse the repository at this point in the history
… alerts during rule execution and caching loaded maintenance windows (#192573)

Resolves #184324

## Summary

This PR moves the loading of maintenance windows further down in rule
execution so maintenance windows are only loaded when a rule execution
generates alerts. Also caches maintenance windows per space to reduce
the number of requests.

## To Verify

1. Add some logging to
x-pack/plugins/alerting/server/task_runner/maintenance_windows/maintenance_windows_service.ts
to indicate when windows are being fetched and when they're returning
from the cache.
2. Create and run some rules in different spaces with and without alerts
to see that the maintenance windows are only loaded when there are
alerts and that the windows are returned from the cache when the cache
has not expired.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 26, 2024
1 parent c8a77b5 commit 93414a6
Show file tree
Hide file tree
Showing 49 changed files with 1,619 additions and 634 deletions.
2 changes: 0 additions & 2 deletions x-pack/plugins/alerting/server/alert/create_alert_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ export function createAlertFactory<
autoRecoverAlerts,
// flappingSettings.enabled is false, as we only want to use this function to get the recovered alerts
flappingSettings: DISABLE_FLAPPING_SETTINGS,
// no maintenance window IDs are passed as we only want to use this function to get recovered alerts
maintenanceWindowIds: [],
});
return Object.keys(currentRecoveredAlerts ?? {}).map(
(alertId: string) => currentRecoveredAlerts[alertId]
Expand Down
Loading

0 comments on commit 93414a6

Please sign in to comment.