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] Enable ESQL alerts from the Discover app #165973

Merged
merged 8 commits into from Sep 14, 2023

Conversation

stratoula
Copy link
Contributor

@stratoula stratoula commented Sep 7, 2023

Summary

Enables the Alerts menu in Discover nav for the ES|QL mode and defaults to ESQL alerts by carrying the query that the user has typed.

image

Checklist

@stratoula stratoula added Feature:Discover Discover Application release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) v8.11.0 Feature:ES|QL labels Sep 7, 2023
@stratoula stratoula marked this pull request as ready for review September 7, 2023 15:16
@stratoula stratoula requested a review from a team as a code owner September 7, 2023 15:16
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@ninoslavmiskovic
Copy link
Contributor

👏

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Great addition for ES|QL!

@@ -54,6 +60,13 @@ export function AlertsPopover({
* Provides the default parameters used to initialize the new rule
*/
const getParams = useCallback(() => {
if (isPlainRecord) {
return {
searchType: 'esqlQuery',
Copy link
Contributor

Choose a reason for hiding this comment

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

I am seeing this UI for the first time and "Alerts generated" label looks confusing when you are just creating a new alert. Can we remove or rephrase it?

Screenshot 2023-09-12 at 11 13 08

Copy link
Contributor Author

@stratoula stratoula Sep 12, 2023

Choose a reason for hiding this comment

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

This is not owned by us. If you have any recommendations for the alerting team it is better to create an issue for them cc @mikecote

@@ -188,6 +210,7 @@ export function openAlertsPopover({
stateContainer={stateContainer}
adHocDataViews={adHocDataViews}
services={services}
isPlainRecord={isPlainRecord}
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Not related to this line

"View in app" link seems to be not working for ES|QL alerts:

Screenshot 2023-09-12 at 11 15 08

I would expect it to open ES|QL view in Discover if possible instead of this error:
Screenshot 2023-09-12 at 11 14 37

Copy link
Contributor Author

@stratoula stratoula Sep 12, 2023

Choose a reason for hiding this comment

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

Also not related to us cc @mikecote maybe it makes sense to have a look on this when this PR is being merged

Copy link
Contributor

Choose a reason for hiding this comment

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

We have it configured so rules created from discover navigate to the following path whenever a user clicks "View in app": /app/discover#/viewAlert/${alert.id}.

Is there something that should change with the path for ES|QL rules? The code comes from here: https://github.com/elastic/kibana/blob/main/x-pack/plugins/stack_alerts/public/rule_types/es_query/index.ts#L51C15-L51C51.

cc @XavierM as he is working on changing this in the recent release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I can take a look to see if we can make it work from Discover side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed that 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thanks! Now the feature looks complete to me 🙂

@kertal Could you please also review this change 2800b2e if you have time?

Copy link
Member

Choose a reason for hiding this comment

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

thx Julia! Code looks good, but I wonder if it is used when generating the link to Discover? I've created a rule with a notification containing a {{context.link}} field:

Bildschirmfoto 2023-09-14 um 09 24 20

But what was ingested was the link to the alert rule:

Bildschirmfoto 2023-09-14 um 09 25 26

@stratoula we intend to link to Discover also in ES|QL cases right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This already exists in main unfortunately so better been handled on a separate PR. I synced with Matthias and we are going to open an issue on alerting.

@stratoula stratoula requested a review from a team as a code owner September 12, 2023 11:02
@stratoula
Copy link
Contributor Author

@jughosta thanx for the review. From all your comments only one was related to this PR and was a limitation from the Alerts ui. I changed it to get the timestamp info also on initialization when there is an existing query

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Changes related to enabling ES|QL alerts from Discover LGTM 👍

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
discover 551.0KB 551.7KB +689.0B
stackAlerts 203.0KB 203.0KB +30.0B
total +719.0B

History

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

cc @stratoula

Copy link
Contributor

@doakalexi doakalexi left a comment

Choose a reason for hiding this comment

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

ResponseOps changes LGTM!

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.

Using ES|QL in alerting 🥳 ... who could imagine this would be possible so quickly!

One thing I noticed when testing the preview, it also works with timestamp selection! Great! The preview table seems to ignore the custom timestamp, having selected the customer birth date as a timestamp, there seem to be lots of customers born in the last 5 minutes. While in theory this is not impossible, I think it's because in the request for the preview there's no time filter involved
Bildschirmfoto 2023-09-14 um 09 13 54

@stratoula
Copy link
Contributor Author

@kertal this is correct. In ESQL the users can write a where clause with a timefield on their own if there is no @timestamp detected. The same is happening in Discover too. Possibly the alerting team should disable the timefilter selection in these cases cc @doakalexi but it is irrelevant with this PR I think.

@stratoula stratoula merged commit 87dc64e into elastic:main Sep 14, 2023
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Discover Discover Application Feature:ES|QL release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants