-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Alerting V2] Register "assign episode" workflow trigger #268915
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
Changes from 22 commits
c6ff65f
6d07213
4eaaa3c
80ac903
c09ec2d
cd3fefd
e43a1b4
9afde85
28a9188
0f8e5c0
068fedd
2714f6f
0c4978c
1dd5101
94de798
c06e33b
741b21f
e7a671b
fe5bd86
ee0a69f
3aafc90
7a15f24
a6569f5
a45ed7f
0a9a061
1a60880
19b1d78
c28445c
7a89d3a
4aaa6dc
d8a8114
11fbf49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { i18n } from '@kbn/i18n'; | ||
| import { z } from '@kbn/zod/v4'; | ||
| import type { CommonTriggerDefinition } from '@kbn/workflows-extensions/common'; | ||
|
|
||
| export const EPISODE_ASSIGNED_TRIGGER_ID = 'alertingV2.episodeAssigned' as const; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need to specify
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to distinguish between the existing alerting and the new one (v2) in case we want to introduce triggers for the v1 alerting in the future. Any suggestions?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't have any suggestions atm, maybe @tinnytintin10 could help
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed briefly this one with @tinnytintin10, suggestion is to remove
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tiamliu based on our recent conversations around how to cater to "mixed experiences" effectively, please check my thinking here? I think we should call these kinds of events/triggers "alerting.[event_name]" and as much as possible make them version-agnostic. For events that apply to both, we can send them through the same flow, and include "version" as a payload discriminator for people who only want to handle one or the other for some reason (likely suggested by a consultant, support, etc). Very rough examples: for {
"rule.id": "some-id-for-rule",
"alerting.version": 2,
"timestamp": //...
// ...etc
}for Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we actually want event-driven triggers for v1? maybe we can make a deliberate product choice that event driven triggers are v2-only. v1 users still have the run workflow action, so they can invoke workflows when alerts fire or recover. event-driven triggers would only come with v2, and only show up once v2 features are enabled. If users want event driven triggers, that's a reason to move to v2. i think this would enable us to:
wdyt @jasonrhodes @tiamliu
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My first instinct is to say I think this is a really good idea. We need to support v1 rules and alerts for a long time, likely, as users will want to continue using their existing rules and put off migration as long as possible even if we make it easy, but that doesn't mean we need to give v1 rules every new thing. If we do get pressure to add these down the road, let's let those events bear the burden of naming with something like alerting.classic.{trigger_name} or alerting.legacy.{trigger_name} depending on how far down the road we are when we decide we want it. I may be missing some context that makes this not work, so I'll check with Tia and others on our side, but on first glance I think this is a nice solution.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good middle ground. We can deliberately choose to support event triggers in alerting v2 only. In alerting v1, workflows can be attached as an action and can already be triggered per execution. If we make this a v2 only thing , it also gives users incentive to migrate. Thanks for all your thorough considerations @cnasikas @jasonrhodes @tinnytintin10
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you all! I also agree. I will go with
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yngrdyn @tinnytintin10 I pushed the changes. Could you plz take another look? |
||
|
|
||
| export const episodeAssignedPayloadSchema = z | ||
| .object({ | ||
| occurredAt: z.string().describe( | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.occurredAt', { | ||
| defaultMessage: 'ISO timestamp of when the assignment occurred.', | ||
| }) | ||
| ), | ||
| groupHash: z.string().describe( | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.groupHash', { | ||
| defaultMessage: 'Stable hash of the alert grouping the episode belongs to.', | ||
| }) | ||
| ), | ||
| episodeId: z.string().describe( | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.episodeId', { | ||
| defaultMessage: 'Identifier of the alerting episode whose assignee changed.', | ||
| }) | ||
| ), | ||
| ruleId: z.string().describe( | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.ruleId', { | ||
| defaultMessage: 'Identifier of the alerting rule the episode belongs to.', | ||
| }) | ||
| ), | ||
| spaceId: z.string().describe( | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.spaceId', { | ||
| defaultMessage: 'Kibana space the episode lives in.', | ||
| }) | ||
| ), | ||
| actorUid: z | ||
| .string() | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| .nullable() | ||
| .describe( | ||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.actorUid', { | ||
| defaultMessage: | ||
| 'User-profile uid of the actor who changed the assignee, or null when performed by an internal/system context.', | ||
| }) | ||
| ), | ||
| assigneeUid: z | ||
| .string() | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| .nullable() | ||
| .describe( | ||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.assigneeUid', { | ||
| defaultMessage: | ||
| 'User-profile uid of the new assignee, or null when the episode was unassigned.', | ||
| }) | ||
| ), | ||
| }) | ||
| .strict(); | ||
|
|
||
| export type EpisodeAssignedPayload = z.infer<typeof episodeAssignedPayloadSchema>; | ||
|
|
||
| export const episodeAssignedTriggerCommonDefinition: CommonTriggerDefinition< | ||
| typeof episodeAssignedPayloadSchema | ||
| > = { | ||
| id: EPISODE_ASSIGNED_TRIGGER_ID, | ||
| eventSchema: episodeAssignedPayloadSchema, | ||
| }; | ||
|
cnasikas marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| export { | ||
| EPISODE_ASSIGNED_TRIGGER_ID, | ||
| episodeAssignedPayloadSchema, | ||
| episodeAssignedTriggerCommonDefinition, | ||
| } from './episode_assigned'; | ||
| export type { EpisodeAssignedPayload } from './episode_assigned'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { EuiIcon } from '@elastic/eui'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import React from 'react'; | ||
| import type { PublicTriggerDefinition } from '@kbn/workflows-extensions/public'; | ||
| import { | ||
| EPISODE_ASSIGNED_TRIGGER_ID, | ||
| episodeAssignedTriggerCommonDefinition, | ||
| } from '../../../../common/workflows/triggers'; | ||
|
|
||
| const EpisodeAssignedIcon = () => React.createElement(EuiIcon, { type: 'user' }); | ||
|
cnasikas marked this conversation as resolved.
Outdated
|
||
|
|
||
| export const episodeAssignedTriggerPublicDefinition: PublicTriggerDefinition = { | ||
| ...episodeAssignedTriggerCommonDefinition, | ||
| icon: EpisodeAssignedIcon, | ||
|
cnasikas marked this conversation as resolved.
Outdated
|
||
| title: i18n.translate('xpack.alertingVTwo.workflowTriggers.episodeAssigned.title', { | ||
| defaultMessage: 'Alerting - Episode assigned', | ||
| }), | ||
| description: i18n.translate('xpack.alertingVTwo.workflowTriggers.episodeAssigned.description', { | ||
| defaultMessage: 'Emitted when an alerting episode is assigned to a user.', | ||
| }), | ||
| documentation: { | ||
| details: i18n.translate( | ||
| 'xpack.alertingVTwo.workflowTriggers.episodeAssigned.documentation.details', | ||
| { | ||
| defaultMessage: | ||
| 'Emitted after an episode assign action is persisted with a non-null assignee. The payload includes event.episodeId, event.ruleId, event.spaceId, and event.assigneeUid for trigger conditions.', | ||
| } | ||
| ), | ||
| examples: [ | ||
| i18n.translate('xpack.alertingVTwo.workflowTriggers.episodeAssigned.documentation.example', { | ||
| defaultMessage: `## Run for a specific rule | ||
| \`\`\`yaml | ||
| triggers: | ||
| - type: {triggerId} | ||
| on: | ||
| condition: 'event.ruleId: "my-rule-id"' | ||
| \`\`\``, | ||
| values: { | ||
| triggerId: EPISODE_ASSIGNED_TRIGGER_ID, | ||
|
adcoelho marked this conversation as resolved.
Outdated
|
||
| }, | ||
| }), | ||
| ], | ||
| }, | ||
| snippets: { | ||
| condition: 'event.assigneeUid: "user-profile-uid"', | ||
| }, | ||
| }; | ||
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.
You probably need to change this as well