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

[ES|QL] Starred queries in the editor #198362

Merged
merged 70 commits into from
Nov 18, 2024

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Oct 30, 2024

Summary

close #194165
close https://github.com/elastic/kibana-team/issues/1245

User-facing

image

This PRs adds a new tab in the editor history component. You can star your query from the history and then you will see it in the Starred list. The started queries are scoped to a user and a space.

Server

To allow starring ESQL query, this PR extends favorites service with ability to store metadata in addition to an id. To make metadata strict and in future to support proper metadata migrations if needed, metadata needs to be defined as schema:

plugins.contentManagement.favorites.registerFavoriteType('esql_query', {
       typeMetadataSchema: schema.object({ query: schema.string(), timeRange:...., etc... }),
})

Notable changes:

  • Add support for registering a favorite type and a schema for favorite type metadata. Previosly the dashboard type was the only supported type and was hardcoded
  • Add favoriteMetadata property to a saved object mapping and make it enabled:false we don't want to index it, but just want to store metadata in addition to an id. code
  • Add a 100 favorite items limit (per type per space per user). Just do it for sanity to prevent too large objects due to metadata stored in addtion to ids.

@Dosant Dosant requested a review from rudolf November 14, 2024 13:07
Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Codeowner changes LGMT, tested locally in 2 browsers with the same account, starred queries show up in both. Works as expected.

2 non blocking questions:

  • What's the reason we add those new tests to x-pack?
  • Should we add this nice new feature to our serverless tests?
    🙇

@stratoula
Copy link
Contributor

Codeowner changes LGMT, tested locally in 2 browsers with the same account, starred queries show up in both. Works as expected.

2 non blocking questions:

  • What's the reason we add those new tests to x-pack?
  • Should we add this nice new feature to our serverless tests?
    🙇

@kertal why in x-pack I explain it here #198362 (comment)

Should we add this nice new feature to our serverless tests?

Hmmm we could possibly on a follow - up PR, wdyt @Dosant ? (although I am trying to be conversative on our FTs). If the backend service is being tested in serverless maybe is not needed. But I will evaluate with Anton

Copy link
Contributor

@eokoneyo eokoneyo left a comment

Choose a reason for hiding this comment

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

Tested locally, feature works as advertised.

@Dosant
Copy link
Contributor Author

Dosant commented Nov 18, 2024

Hmmm we could possibly on a follow - up PR, wdyt @Dosant ? (although I am trying to be conversative on our FTs). If the backend service is being tested in serverless maybe is not needed. But I will evaluate with Anton

thanks, I agree, I'd like to follow up (also for dashboard favorites). I'll create an issue and will work on it shortly

Copy link
Member

@qn895 qn895 left a comment

Choose a reason for hiding this comment

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

Tested and LGTM 🎉

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
esql 99 112 +13
lens 1479 1492 +13
stackAlerts 169 182 +13
total +39

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
@kbn/content-management-favorites-common - 1 +1
@kbn/content-management-favorites-public 44 42 -2
@kbn/content-management-favorites-server 7 13 +6
contentManagement 125 126 +1
total +6

Async chunks

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

id before after diff
dashboard 647.0KB 647.1KB +139.0B
esql 185.5KB 195.9KB +10.4KB
eventAnnotationListing 229.5KB 229.6KB +74.0B
filesManagement 123.3KB 123.3KB +74.0B
graph 415.9KB 415.9KB +74.0B
maps 3.0MB 3.0MB +74.0B
visualizations 318.2KB 318.3KB +74.0B
total +10.9KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/content-management-favorites-public 0 1 +1
@kbn/content-management-favorites-server 0 1 +1
total +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
esql 6.5KB 6.9KB +445.0B
Unknown metric groups

API count

id before after diff
@kbn/content-management-favorites-common - 1 +1
@kbn/content-management-favorites-public 45 43 -2
@kbn/content-management-favorites-server 7 13 +6
contentManagement 149 150 +1
total +6

async chunk count

id before after diff
esql 3 4 +1

ESLint disabled line counts

id before after diff
@kbn/content-management-favorites-server 0 1 +1
@kbn/esql-editor 5 6 +1
contentManagement 6 5 -1
total +1

miscellaneous assets size

id before after diff
esql 0.0B 225.5KB ⚠️ +225.5KB
lens 931.7KB 1.1MB ⚠️ +225.5KB
stackAlerts 0.0B 225.5KB ⚠️ +225.5KB
total +676.6KB

Total ESLint disabled count

id before after diff
@kbn/content-management-favorites-server 0 1 +1
@kbn/esql-editor 5 6 +1
contentManagement 6 5 -1
total +1

History

cc @Dosant @stratoula

@stratoula stratoula merged commit 4597237 into elastic:main Nov 18, 2024
40 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11900903246

@stratoula
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

stratoula pushed a commit to stratoula/kibana that referenced this pull request Nov 19, 2024
## Summary

close elastic#194165
close elastic/kibana-team#1245

### User-facing

<img width="1680" alt="image"
src="https://github.com/user-attachments/assets/6df4ee9f-1b4d-404c-a764-592998a1d430">

This PRs adds a new tab in the editor history component. You can star
your query from the history and then you will see it in the Starred
list. The started queries are scoped to a user and a space.

### Server

To allow starring ESQL query, this PR extends [favorites
service](elastic#189285) with ability to
store metadata in addition to an id. To make metadata strict and in
future to support proper metadata migrations if needed, metadata needs
to be defined as schema:

```
plugins.contentManagement.favorites.registerFavoriteType('esql_query', {
       typeMetadataSchema: schema.object({ query: schema.string(), timeRange:...., etc... }),
})
```

Notable changes:

- Add support for registering a favorite type and a schema for favorite
type metadata. Previosly the `dashboard` type was the only supported
type and was hardcoded
- Add `favoriteMetadata` property to a saved object mapping and make it
`enabled:false` we don't want to index it, but just want to store
metadata in addition to an id.
[code](https://github.com/elastic/kibana/pull/198362/files#diff-d1a39e36f1de11a1110520d7607e6aee7d506c76626993842cb58db012b760a2R74-R87)
- Add a 100 favorite items limit (per type per space per user). Just do
it for sanity to prevent too large objects due to metadata stored in
addtion to ids.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Stratoula Kalafateli <stratoula1@gmail.com>
(cherry picked from commit 4597237)

# Conflicts:
#	.github/CODEOWNERS
stratoula added a commit that referenced this pull request Nov 19, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] Starred queries in the editor
(#198362)](#198362)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Anton
Dosov","email":"anton.dosov@elastic.co"},"sourceCommit":{"committedDate":"2024-11-18T20:53:46Z","message":"[ES|QL]
Starred queries in the editor (#198362)\n\n## Summary\r\n\r\nclose
https://github.com/elastic/kibana/issues/194165\r\nclose
https://github.com/elastic/kibana-team/issues/1245\r\n\r\n###
User-facing\r\n\r\n<img width=\"1680\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/6df4ee9f-1b4d-404c-a764-592998a1d430\">\r\n\r\nThis
PRs adds a new tab in the editor history component. You can star\r\nyour
query from the history and then you will see it in the Starred\r\nlist.
The started queries are scoped to a user and a space.\r\n\r\n\r\n###
Server\r\n\r\nTo allow starring ESQL query, this PR extends
[favorites\r\nservice](#189285)
with ability to\r\nstore metadata in addition to an id. To make metadata
strict and in\r\nfuture to support proper metadata migrations if needed,
metadata needs\r\nto be defined as
schema:\r\n\r\n```\r\nplugins.contentManagement.favorites.registerFavoriteType('esql_query',
{\r\n typeMetadataSchema: schema.object({ query: schema.string(),
timeRange:...., etc... }),\r\n})\r\n```\r\n\r\nNotable changes:
\r\n\r\n- Add support for registering a favorite type and a schema for
favorite\r\ntype metadata. Previosly the `dashboard` type was the only
supported\r\ntype and was hardcoded\r\n- Add `favoriteMetadata` property
to a saved object mapping and make it\r\n`enabled:false` we don't want
to index it, but just want to store\r\nmetadata in addition to an
id.\r\n[code](https://github.com/elastic/kibana/pull/198362/files#diff-d1a39e36f1de11a1110520d7607e6aee7d506c76626993842cb58db012b760a2R74-R87)\r\n-
Add a 100 favorite items limit (per type per space per user). Just
do\r\nit for sanity to prevent too large objects due to metadata stored
in\r\naddtion to ids.\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>\r\nCo-authored-by: Stratoula
Kalafateli
<stratoula1@gmail.com>","sha":"45972374f06a6189ec9e225fd00b191838f33e52","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["v9.0.0","release_note:feature","Team:SharedUX","Feature:ES|QL","Team:ESQL","backport:version","v8.17.0"],"number":198362,"url":"https://github.com/elastic/kibana/pull/198362","mergeCommit":{"message":"[ES|QL]
Starred queries in the editor (#198362)\n\n## Summary\r\n\r\nclose
https://github.com/elastic/kibana/issues/194165\r\nclose
https://github.com/elastic/kibana-team/issues/1245\r\n\r\n###
User-facing\r\n\r\n<img width=\"1680\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/6df4ee9f-1b4d-404c-a764-592998a1d430\">\r\n\r\nThis
PRs adds a new tab in the editor history component. You can star\r\nyour
query from the history and then you will see it in the Starred\r\nlist.
The started queries are scoped to a user and a space.\r\n\r\n\r\n###
Server\r\n\r\nTo allow starring ESQL query, this PR extends
[favorites\r\nservice](#189285)
with ability to\r\nstore metadata in addition to an id. To make metadata
strict and in\r\nfuture to support proper metadata migrations if needed,
metadata needs\r\nto be defined as
schema:\r\n\r\n```\r\nplugins.contentManagement.favorites.registerFavoriteType('esql_query',
{\r\n typeMetadataSchema: schema.object({ query: schema.string(),
timeRange:...., etc... }),\r\n})\r\n```\r\n\r\nNotable changes:
\r\n\r\n- Add support for registering a favorite type and a schema for
favorite\r\ntype metadata. Previosly the `dashboard` type was the only
supported\r\ntype and was hardcoded\r\n- Add `favoriteMetadata` property
to a saved object mapping and make it\r\n`enabled:false` we don't want
to index it, but just want to store\r\nmetadata in addition to an
id.\r\n[code](https://github.com/elastic/kibana/pull/198362/files#diff-d1a39e36f1de11a1110520d7607e6aee7d506c76626993842cb58db012b760a2R74-R87)\r\n-
Add a 100 favorite items limit (per type per space per user). Just
do\r\nit for sanity to prevent too large objects due to metadata stored
in\r\naddtion to ids.\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>\r\nCo-authored-by: Stratoula
Kalafateli
<stratoula1@gmail.com>","sha":"45972374f06a6189ec9e225fd00b191838f33e52"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198362","number":198362,"mergeCommit":{"message":"[ES|QL]
Starred queries in the editor (#198362)\n\n## Summary\r\n\r\nclose
https://github.com/elastic/kibana/issues/194165\r\nclose
https://github.com/elastic/kibana-team/issues/1245\r\n\r\n###
User-facing\r\n\r\n<img width=\"1680\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/6df4ee9f-1b4d-404c-a764-592998a1d430\">\r\n\r\nThis
PRs adds a new tab in the editor history component. You can star\r\nyour
query from the history and then you will see it in the Starred\r\nlist.
The started queries are scoped to a user and a space.\r\n\r\n\r\n###
Server\r\n\r\nTo allow starring ESQL query, this PR extends
[favorites\r\nservice](#189285)
with ability to\r\nstore metadata in addition to an id. To make metadata
strict and in\r\nfuture to support proper metadata migrations if needed,
metadata needs\r\nto be defined as
schema:\r\n\r\n```\r\nplugins.contentManagement.favorites.registerFavoriteType('esql_query',
{\r\n typeMetadataSchema: schema.object({ query: schema.string(),
timeRange:...., etc... }),\r\n})\r\n```\r\n\r\nNotable changes:
\r\n\r\n- Add support for registering a favorite type and a schema for
favorite\r\ntype metadata. Previosly the `dashboard` type was the only
supported\r\ntype and was hardcoded\r\n- Add `favoriteMetadata` property
to a saved object mapping and make it\r\n`enabled:false` we don't want
to index it, but just want to store\r\nmetadata in addition to an
id.\r\n[code](https://github.com/elastic/kibana/pull/198362/files#diff-d1a39e36f1de11a1110520d7607e6aee7d506c76626993842cb58db012b760a2R74-R87)\r\n-
Add a 100 favorite items limit (per type per space per user). Just
do\r\nit for sanity to prevent too large objects due to metadata stored
in\r\naddtion to ids.\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>\r\nCo-authored-by: Stratoula
Kalafateli
<stratoula1@gmail.com>","sha":"45972374f06a6189ec9e225fd00b191838f33e52"}},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
Dosant added a commit that referenced this pull request Nov 27, 2024
## Summary

close #200701

As a follow-up to #198362 would
like to add very basic serverless test that check that the favorites
(starred) API works
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 27, 2024
…00985)

## Summary

close elastic#200701

As a follow-up to elastic#198362 would
like to add very basic serverless test that check that the favorites
(starred) API works

(cherry picked from commit 38fab2d)
kibanamachine added a commit that referenced this pull request Nov 27, 2024
…0985) (#201946)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Add smoke serverless tests for favorites (starred) feature
(#200985)](#200985)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Anton
Dosov","email":"anton.dosov@elastic.co"},"sourceCommit":{"committedDate":"2024-11-27T11:30:49Z","message":"Add
smoke serverless tests for favorites (starred) feature (#200985)\n\n##
Summary\r\n\r\nclose
https://github.com/elastic/kibana/issues/200701\r\n\r\nAs a follow-up to
#198362 would\r\nlike to add very
basic serverless test that check that the favorites\r\n(starred) API
works","sha":"38fab2df6ca857e5f03b1392c63bfd8a353430ea","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:SharedUX","backport:prev-minor"],"title":"Add
smoke serverless tests for favorites (starred)
feature","number":200985,"url":"https://github.com/elastic/kibana/pull/200985","mergeCommit":{"message":"Add
smoke serverless tests for favorites (starred) feature (#200985)\n\n##
Summary\r\n\r\nclose
https://github.com/elastic/kibana/issues/200701\r\n\r\nAs a follow-up to
#198362 would\r\nlike to add very
basic serverless test that check that the favorites\r\n(starred) API
works","sha":"38fab2df6ca857e5f03b1392c63bfd8a353430ea"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200985","number":200985,"mergeCommit":{"message":"Add
smoke serverless tests for favorites (starred) feature (#200985)\n\n##
Summary\r\n\r\nclose
https://github.com/elastic/kibana/issues/200701\r\n\r\nAs a follow-up to
#198362 would\r\nlike to add very
basic serverless test that check that the favorites\r\n(starred) API
works","sha":"38fab2df6ca857e5f03b1392c63bfd8a353430ea"}}]}] BACKPORT-->

Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
## Summary

close elastic#194165
close elastic/kibana-team#1245

### User-facing

<img width="1680" alt="image"
src="https://github.com/user-attachments/assets/6df4ee9f-1b4d-404c-a764-592998a1d430">

This PRs adds a new tab in the editor history component. You can star
your query from the history and then you will see it in the Starred
list. The started queries are scoped to a user and a space.


### Server

To allow starring ESQL query, this PR extends [favorites
service](elastic#189285) with ability to
store metadata in addition to an id. To make metadata strict and in
future to support proper metadata migrations if needed, metadata needs
to be defined as schema:

```
plugins.contentManagement.favorites.registerFavoriteType('esql_query', {
       typeMetadataSchema: schema.object({ query: schema.string(), timeRange:...., etc... }),
})
```

Notable changes: 

- Add support for registering a favorite type and a schema for favorite
type metadata. Previosly the `dashboard` type was the only supported
type and was hardcoded
- Add `favoriteMetadata` property to a saved object mapping and make it
`enabled:false` we don't want to index it, but just want to store
metadata in addition to an id.
[code](https://github.com/elastic/kibana/pull/198362/files#diff-d1a39e36f1de11a1110520d7607e6aee7d506c76626993842cb58db012b760a2R74-R87)
- Add a 100 favorite items limit (per type per space per user). Just do
it for sanity to prevent too large objects due to metadata stored in
addtion to ids.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Stratoula Kalafateli <stratoula1@gmail.com>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
…00985)

## Summary

close elastic#200701

As a follow-up to elastic#198362 would
like to add very basic serverless test that check that the favorites
(starred) API works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels Feature:ES|QL ES|QL related features in Kibana release_note:feature Makes this part of the condensed release notes Team:ESQL ES|QL related features in Kibana Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhanced ES|QL Query History incl. starring a query