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) (elastic#120669)

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Marshall Main <[email protected]>
  • Loading branch information
kibanamachine and marshallmain authored Dec 7, 2021
1 parent 7f292d6 commit 66594bb
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 @@ -97,14 +97,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 66594bb

Please sign in to comment.