diff --git a/x-pack/plugins/rule_registry/server/utils/create_lifecycle_executor.ts b/x-pack/plugins/rule_registry/server/utils/create_lifecycle_executor.ts index abdffd2aa03cc..dfd7848e4c442 100644 --- a/x-pack/plugins/rule_registry/server/utils/create_lifecycle_executor.ts +++ b/x-pack/plugins/rule_registry/server/utils/create_lifecycle_executor.ts @@ -178,19 +178,17 @@ export const createLifecycleExecutor = ( const allAlertIds = [...new Set(currentAlertIds.concat(trackedAlertIds))]; - const trackedAlertStatesOfRecovered = Object.values(state.trackedAlerts).filter( - (trackedAlertState) => !currentAlerts[trackedAlertState.alertId] - ); + const trackedAlertStates = Object.values(state.trackedAlerts); logger.debug( - `Tracking ${allAlertIds.length} alerts (${newAlertIds.length} new, ${trackedAlertStatesOfRecovered.length} recovered)` + `Tracking ${allAlertIds.length} alerts (${newAlertIds.length} new, ${trackedAlertStates.length} previous)` ); const alertsDataMap: Record> = { ...currentAlerts, }; - if (trackedAlertStatesOfRecovered.length) { + if (trackedAlertStates.length) { const { hits } = await ruleDataClient.getReader().search({ body: { query: { @@ -203,7 +201,7 @@ export const createLifecycleExecutor = ( }, { terms: { - [ALERT_UUID]: trackedAlertStatesOfRecovered.map( + [ALERT_UUID]: trackedAlertStates.map( (trackedAlertState) => trackedAlertState.alertUuid ), }, @@ -211,7 +209,7 @@ export const createLifecycleExecutor = ( ], }, }, - size: trackedAlertStatesOfRecovered.length, + size: trackedAlertStates.length, collapse: { field: ALERT_UUID, },