Skip to content

Commit

Permalink
AlertWithPersistence return only alerts that were actually indexed (e…
Browse files Browse the repository at this point in the history
…lastic#120439)

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
2 people authored and TinLe committed Dec 22, 2021
1 parent 46759f7 commit e28a383
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class RuleDataClient implements IRuleDataClient {
return clusterClient.bulk(requestWithDefaultParameters).then((response) => {
if (response.body.errors) {
const error = new errors.ResponseError(response);
throw error;
this.options.logger.error(error);
}
return response;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,16 @@ export const createPersistenceRuleTypeWrapper: CreatePersistenceRuleTypeWrapper
}

return {
createdAlerts: augmentedAlerts.map((alert, idx) => {
const responseItem = response.body.items[idx].create;
return {
_id: responseItem?._id ?? '',
_index: responseItem?._index ?? '',
...alert._source,
};
}),
createdAlerts: augmentedAlerts
.map((alert, idx) => {
const responseItem = response.body.items[idx].create;
return {
_id: responseItem?._id ?? '',
_index: responseItem?._index ?? '',
...alert._source,
};
})
.filter((_, idx) => response.body.items[idx].create?.status === 201),
};
} else {
logger.debug('Writing is disabled.');
Expand Down

0 comments on commit e28a383

Please sign in to comment.