-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EventLog] Added event log API to get events for multiple saved objects. #87596
[EventLog] Added event log API to get events for multiple saved objects. #87596
Conversation
…ed to findEventsBySavedObjectIds
…for non existing id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it's headed in the right direction. We'll have more work to do to get to the point where we can use this to get all active instances - this isn't all of it. So I think the title should be changed to "Added event log API to get events for multiple saved objects".
? Promise.all( | ||
objects.map(async (objectItem) => await (await client).get({ id: objectItem.id })) | ||
) | ||
: new Promise(() => []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
: new Promise(() => []); | |
: Promise.resolve([]) |
I don't think the new Promise(() => [])
is doing what we want - it seems to return a promise that never resolves, but I think we want a promise that resolves to an empty array instead.
Same pattern is in the alerts plugin ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better, current PR can close the opened issue #70856 and the alerting related work will be a separate PR
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
const objects = ids.reduce( | ||
(prev: Array<{ type: string; id: string }>, id) => [...prev, { type, id }], | ||
[] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: might be clearer to use a map
instead of a reduce
const objects = ids.map((id: string) => ({ type, id }));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
…ts. (elastic#87596) * Added alerting API to get all active instances * modofied event log findEventsBySavedObject to support bulk ids, renamed to findEventsBySavedObjectIds * fixed faling typechecks * fixed crash on zpd/api/event_log/alert/84c00970-5130-11eb-9fa7/_find for non existing id * fixed faling typechecks * fixed faling typechecks * fixed due to comments * fixed due to comments * fixed failing test * fixed due to comments
…ts. (#87596) (#88116) * Added alerting API to get all active instances * modofied event log findEventsBySavedObject to support bulk ids, renamed to findEventsBySavedObjectIds * fixed faling typechecks * fixed crash on zpd/api/event_log/alert/84c00970-5130-11eb-9fa7/_find for non existing id * fixed faling typechecks * fixed faling typechecks * fixed due to comments * fixed due to comments * fixed failing test * fixed due to comments
Added support for getting events by the object type and multiple ids: exposed by EventLogClient and find_by_ids REST API
Resolve #70856