Skip to content
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

[Alerts] Uses aggregations in RulesClient.aggregate() method #119852

Merged
merged 12 commits into from
Nov 30, 2021

Conversation

claudiopro
Copy link
Contributor

@claudiopro claudiopro commented Nov 29, 2021

Summary

This PR ships a performance improvement of the RulesClient.aggregate() method to use aggregations instead of multiple find() queries.

This seems viable as #64002 has already been merged. Thanks to @ymao1 for advice on the aggregation fields to use!

public async aggregate({
options: { fields, ...options } = {},
}: { options?: AggregateOptions } = {}): Promise<AggregateResult> {
// Replace this when saved objects supports aggregations https://github.com/elastic/kibana/pull/64002
const alertExecutionStatus = await Promise.all(
AlertExecutionStatusValues.map(async (status: string) => {

Checklist

@claudiopro claudiopro requested a review from a team as a code owner November 29, 2021 15:21
@claudiopro claudiopro added release_note:skip Skip the PR/issue when compiling release notes v8.1.0 labels Nov 29, 2021
@ymao1 ymao1 added this to In Review in Kibana Alerting Nov 29, 2021
Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you for making this update! Just a comment about appropriately auditing authorization errors and a suggestion about null checking.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
alerting 255 257 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
triggersActionsUi 778.3KB 778.3KB +80.0B
Unknown metric groups

API count

id before after diff
alerting 263 265 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Verified the Rule Management page that currently uses this API still works as expected and that the aggregations only aggregate over rules the user has access to. Nice job

@claudiopro claudiopro merged commit 2949913 into elastic:main Nov 30, 2021
Kibana Alerting automation moved this from In Review to Done (Ordered by most recent) Nov 30, 2021
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Nov 30, 2021
@claudiopro
Copy link
Contributor Author

Thank you for advice and review feedback @ymao1! Looking forward to collaborating more on alerting framework and APIs 🚀

@claudiopro claudiopro deleted the alert_find_aggregations branch November 30, 2021 19:02
@claudiopro claudiopro added auto-backport Deprecated: Automatically backport this PR after it's merged v8.0.0 labels Dec 1, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 1, 2021
…#119852)

* Replaces multiple find requests with aggregations

* Updates unit tests

* Removes commented out code

* Removes unused import

* Adds muted and enabled aggregations

* Updates tests

* Updates snapshot

* Fixes functional test

* Fixes functional test

* Review feedback, fixes API tests

* Logs audit event and updates tests
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
8.0

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Dec 1, 2021
#120166)

* Replaces multiple find requests with aggregations

* Updates unit tests

* Removes commented out code

* Removes unused import

* Adds muted and enabled aggregations

* Updates tests

* Updates snapshot

* Fixes functional test

* Fixes functional test

* Review feedback, fixes API tests

* Logs audit event and updates tests

Co-authored-by: Claudio Procida <claudio.procida@elastic.co>
TinLe pushed a commit to TinLe/kibana that referenced this pull request Dec 22, 2021
…#119852)

* Replaces multiple find requests with aggregations

* Updates unit tests

* Removes commented out code

* Removes unused import

* Adds muted and enabled aggregations

* Updates tests

* Updates snapshot

* Fixes functional test

* Fixes functional test

* Review feedback, fixes API tests

* Logs audit event and updates tests
gbamparop pushed a commit to gbamparop/kibana that referenced this pull request Jan 12, 2022
…#119852)

* Replaces multiple find requests with aggregations

* Updates unit tests

* Removes commented out code

* Removes unused import

* Adds muted and enabled aggregations

* Updates tests

* Updates snapshot

* Fixes functional test

* Fixes functional test

* Review feedback, fixes API tests

* Logs audit event and updates tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated: Automatically backport this PR after it's merged backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes v8.0.0 v8.1.0
Projects
No open projects
Kibana Alerting
Done (Ordered by most recent)
Development

Successfully merging this pull request may close these issues.

[RAC] Add indicator about enabled / disabled rules on the alerts page
4 participants