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

Add context.alertDetailsUrl to connector template when configuring a Rule #142854

Conversation

CoenWarmer
Copy link
Contributor

@CoenWarmer CoenWarmer commented Oct 6, 2022

Summary

Adds the context.alertDetailsUrl variable when configuring a connector template.

Resolves #139923
Resolves #141497

Screenshot 2022-10-06 at 15 44 23

Screenshot 2022-10-06 at 15 44 39

Tested with sending an email:

Screenshot 2022-10-06 at 15 42 29

Screenshot 2022-10-06 at 15 42 59

Also in this PR:

  • Adjustment in create_lifecycle_executor: changed naming of alertId to alertInstanceId as that is actually what it is.

@CoenWarmer CoenWarmer requested a review from a team October 6, 2022 13:48
@CoenWarmer CoenWarmer requested review from a team as code owners October 6, 2022 13:48
@CoenWarmer CoenWarmer changed the title Add context.alertDetailsUrl to connector template Add context.alertDetailsUrl to connector template when configuring a Rule Oct 6, 2022
@CoenWarmer CoenWarmer added the release_note:skip Skip the PR/issue when compiling release notes label Oct 6, 2022
Copy link
Contributor

@fkanout fkanout left a comment

Choose a reason for hiding this comment

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

That is cool, @CoenWarmer. Did you consider Kibana spaces in the URL?

@CoenWarmer
Copy link
Contributor Author

That is cool, @CoenWarmer. Did you consider it with Kibana spaces?

Thanks @fkanout; re: spaces: Not yet, will do!

Copy link
Contributor

@benakansara benakansara left a comment

Choose a reason for hiding this comment

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

Should we include full URL in the notification which user can directly click and navigate? e.g. http://localhost:5601/abc/app/observability/alerts/24b3905c-5ae7-49b1-903f-e7510116af39

@benakansara
Copy link
Contributor

@CoenWarmer If I understood correctly, currently we are adding context.alertDetailsUrl for Infrastructure rules. Other rule types are not in scope for this PR, is that right?

@CoenWarmer
Copy link
Contributor Author

CoenWarmer commented Oct 6, 2022

@simianhacker We don't know the Alert UUID in the context of the executor function, right?

If I understand correctly, an instance of an Alert is created after the executor has run?

--Edit:

Turns out we do have it. PR updated with new approach.

@CoenWarmer CoenWarmer force-pushed the feat/139923-add-context-alertDetailsUrl-for-given-alert-as-an-action-variable branch 2 times, most recently from 53fe49b to f50f780 Compare October 10, 2022 12:11
@CoenWarmer CoenWarmer requested a review from a team as a code owner October 10, 2022 15:39
@CoenWarmer CoenWarmer force-pushed the feat/139923-add-context-alertDetailsUrl-for-given-alert-as-an-action-variable branch 2 times, most recently from daa7fd4 to d2a5272 Compare October 10, 2022 15:41
@simianhacker
Copy link
Member

@CoenWarmer What's your thoughts on alerts without UUIDs? Right now the the UUID gets created after the alert is scheduled (and after the alert detail link) is generated for "new" alerts. I wonder if we shouldn't create the UUID when getAlertUuid() is called. Basically when we call getAlertUuid(), if it doesn't exist, create a new map to track the alertUuids to alertIds that we needed to create and re-use them here:

const { alertUuid, started } = state.trackedAlerts[alertId] ?? {
alertUuid: v4(),
started: commonRuleFields[TIMESTAMP],
};

@CoenWarmer
Copy link
Contributor Author

@simianhacker Lets discuss this today in our 1 on 1.

@fkanout
Copy link
Contributor

fkanout commented Oct 11, 2022

@CoenWarmer, would please share the outcomes of your meeting with @simianhacker regarding the availability of alert UUID?

@CoenWarmer CoenWarmer force-pushed the feat/139923-add-context-alertDetailsUrl-for-given-alert-as-an-action-variable branch 3 times, most recently from 42f44c0 to ff8ff35 Compare October 12, 2022 16:18
@CoenWarmer CoenWarmer force-pushed the feat/139923-add-context-alertDetailsUrl-for-given-alert-as-an-action-variable branch from ae4d760 to 9de24d4 Compare October 25, 2022 12:29
Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

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

infra plugin changes LGTM, well done 👍 and thanks for adding the space awareness to the URLs

@CoenWarmer CoenWarmer removed the request for review from ymao1 October 26, 2022 08:27
Copy link
Member

@simianhacker simianhacker left a comment

Choose a reason for hiding this comment

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

LGTM

@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
ruleRegistry 202 204 +2
Unknown metric groups

API count

id before after diff
ruleRegistry 230 232 +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. Left one more nit about alertInstanceId. Thanks!

const alertId = hit._source ? hit._source[ALERT_INSTANCE_ID] : void 0;
if (alertId && hit._source) {
trackedAlertsDataMap[alertId] = {
const alertInstanceId = hit._source ? hit._source[ALERT_INSTANCE_ID] : void 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we change this back to alertId as well?

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 release_note:skip Skip the PR/issue when compiling release notes v8.6.0
Projects
None yet
9 participants