-
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
[SAVED_OBJECTS] [AGGS] Step I to add aggregations in the find of saved objects #64002
Conversation
Pinging @elastic/kibana-platform (Team:Platform) |
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.
Some architectural questions:
src/core/server/saved_objects/service/lib/saved_object_aggs_types/bucket_aggs/index.ts
Outdated
Show resolved
Hide resolved
src/core/server/saved_objects/service/lib/saved_object_aggs_types/bucket_aggs/index.ts
Outdated
Show resolved
Hide resolved
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.
I think the io-ts types are "scalable" enough to be able to construct a whitelist for excluding aggregation scripts.
However, we need a scalable solution to prevent aggregations on invalid fields (fields from other saved object types). So I think the next step should be to add the adjacency matrix bucket aggregation and find a way to prevent invalid aggregation fields that wouldn't result in a lot of complexity once we cover the entire aggregation API surface. We can use the alternative aggregation syntax #64002 (comment)
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.
Along with the feedback in #64137 I'm happy with this approach 👍
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.
Left some initial comments but will take a deeper look later
115b939
to
16de875
Compare
💚 Build SucceededMetrics [docs]Distributable file count
Page load bundle
History
To update your PR or re-run it, just comment with: |
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.
We are getting very close! Got a few questions (most significant one being #64002 (comment)) and some NITs:
src/core/server/saved_objects/service/lib/saved_objects_aggs_types/metrics_aggs/index.ts
Show resolved
Hide resolved
src/core/server/saved_objects/service/lib/saved_objects_aggs_types/index.ts
Show resolved
Hide resolved
console.log('body', JSON.stringify(resp.body)); | ||
expect(resp.body).to.eql({ | ||
error: 'Bad Request', | ||
message: 'This type dashboard is not allowed: Bad Request', |
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: slightly misleading message. I would rather have something like cannot perform aggregation on dashboard type as it was not included in the search
or something if possible.
Since we're past 7.11.0 FF, and this isn't a bug fix, should probably bump to 7.12.0. |
Summary
This is a baby step to add aggregations in the
find
of saved objects, as we knowfind
is a get, therefore, there is some limitation. I am hoping that I will be able to create a later PR to remove some limitations of this PR by having a post forfind
.Anyway, the idea in this PR is that engineers who will need to add new aggregation types in
src/core/server/saved_objects/service/lib/saved_object_aggs_types/*
. I am usingio-ts
to validate the schema sinceio-ts
allow recursive type and aggregations are recursive like the doc can show.Dev Docs
SavedObjectsClient.find now supports aggregations, with the caveat that your field from the aggregation will have the attribute from your type saved object, it should look like this:
savedObjectType.attributes.field
. However, If you use a direct attribute of a saved object likeupdatedAt
, you will have to define your filter like this:savedObjectType.updatedAt
.Checklist
For maintainers