Skip to content

Commit

Permalink
preserve lifecycle changes for active alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
mgiota committed Aug 25, 2021
1 parent 48d8944 commit 094f35a
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Partial<ParsedTechnicalFields>> = {
...currentAlerts,
};

if (trackedAlertStatesOfRecovered.length) {
if (trackedAlertStates.length) {
const { hits } = await ruleDataClient.getReader().search({
body: {
query: {
Expand All @@ -203,15 +201,15 @@ export const createLifecycleExecutor = (
},
{
terms: {
[ALERT_UUID]: trackedAlertStatesOfRecovered.map(
[ALERT_UUID]: trackedAlertStates.map(
(trackedAlertState) => trackedAlertState.alertUuid
),
},
},
],
},
},
size: trackedAlertStatesOfRecovered.length,
size: trackedAlertStates.length,
collapse: {
field: ALERT_UUID,
},
Expand Down

0 comments on commit 094f35a

Please sign in to comment.