-
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
Merged
adcoelho
merged 32 commits into
elastic:main
from
adcoelho:alerting-v2-workflow-trigger-assign-episode
Jun 2, 2026
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c6ff65f
Introduce an event bus
cnasikas 6d07213
Event bus improvements
cnasikas 4eaaa3c
Add unit tests
cnasikas 80ac903
Merge branch 'main' into alerting_v2_event_bus
cnasikas c09ec2d
Changes from make api-docs
kibanamachine cd3fefd
Merge branch 'main' into alerting_v2_event_bus
cnasikas e43a1b4
Switch to setImmediate and EventEmitterAsyncResource
cnasikas 9afde85
PR feedback
cnasikas 28a9188
Create alert action publisher
cnasikas 0f8e5c0
Fix TS errors
cnasikas 068fedd
Merge branch 'alerting_v2_event_bus' into alerting-v2-workflow-trigge…
cnasikas 2714f6f
Create the alert action pub/sub
cnasikas 0c4978c
Adapting to the new bus.
adcoelho 1dd5101
Merge remote-tracking branch 'upstream/main' into alerting-v2-workflo…
adcoelho 94de798
Changes from node scripts/check
kibanamachine c06e33b
Type fixes
adcoelho 741b21f
Merge branch 'main' into alerting-v2-workflow-trigger-assign-episode
adcoelho e7a671b
fix test
adcoelho fe5bd86
Add logger.
adcoelho ee0a69f
Merge branch 'main' into alerting-v2-workflow-trigger-assign-episode
adcoelho 3aafc90
updating limits
adcoelho 7a15f24
Merge branch 'main' into alerting-v2-workflow-trigger-assign-episode
adcoelho a6569f5
Merge branch 'main' into alerting-v2-workflow-trigger-assign-episode
cnasikas a45ed7f
Fix limits
cnasikas 0a9a061
PR feedback
cnasikas 1a60880
Merge branch 'main' into alerting-v2-workflow-trigger-assign-episode
cnasikas 19b1d78
Merge branch 'main' into alerting-v2-workflow-trigger-assign-episode
elasticmachine c28445c
Merge branch 'main' into alerting-v2-workflow-trigger-assign-episode
cnasikas 7a89d3a
Change trigger ID
cnasikas 4aaa6dc
Add limits to the schema
cnasikas d8a8114
Merge branch 'alerting-v2-workflow-trigger-assign-episode' of github.…
cnasikas 11fbf49
Fix unit test
cnasikas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
x-pack/platform/plugins/shared/alerting_v2/common/workflows/triggers/episode_assigned.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| /* | ||
| * 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 = 'alerting.episodeAssigned' as const; | ||
|
|
||
| export const episodeAssignedPayloadSchema = z | ||
| .object({ | ||
| occurredAt: z.iso.datetime().describe( | ||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.occurredAt', { | ||
| defaultMessage: 'ISO timestamp of when the assignment occurred.', | ||
| }) | ||
| ), | ||
| groupHash: z | ||
| .string() | ||
| .min(1) | ||
| .max(128) | ||
| .describe( | ||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.groupHash', { | ||
| defaultMessage: 'Stable hash of the alert grouping the episode belongs to.', | ||
| }) | ||
| ), | ||
| episodeId: z | ||
| .string() | ||
| .min(1) | ||
| .max(256) | ||
| .describe( | ||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.episodeId', { | ||
| defaultMessage: 'Identifier of the alerting episode whose assignee changed.', | ||
| }) | ||
| ), | ||
| ruleId: z | ||
| .string() | ||
| .min(1) | ||
| .max(256) | ||
| .describe( | ||
| i18n.translate('xpack.alertingVTwo.triggers.episodeAssigned.schema.ruleId', { | ||
| defaultMessage: 'Identifier of the alerting rule the episode belongs to.', | ||
| }) | ||
| ), | ||
| spaceId: z | ||
| .string() | ||
| .min(1) | ||
| .max(256) | ||
| .describe( | ||
| 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
|
||
| .min(1) | ||
| .max(256) | ||
| .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
|
||
| .min(1) | ||
| .max(256) | ||
| .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, | ||
| 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, | ||
| }, | ||
| }), | ||
| ], | ||
| }, | ||
| snippets: { | ||
| condition: 'event.assigneeUid: "user-profile-uid"', | ||
| }, | ||
| }; | ||
|
cnasikas marked this conversation as resolved.
|
||
13 changes: 13 additions & 0 deletions
13
x-pack/platform/plugins/shared/alerting_v2/common/workflows/triggers/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...m/plugins/shared/alerting_v2/public/lib/workflow_extensions/triggers/episode_assigned.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * 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 React from 'react'; | ||
| import type { PublicTriggerDefinition } from '@kbn/workflows-extensions/public'; | ||
| import { episodeAssignedTriggerCommonDefinition } from '../../../../common/workflows/triggers'; | ||
|
|
||
| const EpisodeAssignedIcon = React.lazy(() => | ||
| // @ts-expect-error EUI does not ship `.d.ts` files for deep `icon/assets/*` | ||
| // subpaths. Other plugins work around this with an ambient `eui_icons.d.ts` | ||
| // (see e.g. x-pack/platform/plugins/shared/cases/public/workflows/eui_icons.d.ts). | ||
| import('@elastic/eui/es/components/icon/assets/user').then(({ icon }) => ({ | ||
| default: icon, | ||
| })) | ||
| ); | ||
|
|
||
| export const episodeAssignedTriggerPublicDefinition: PublicTriggerDefinition = { | ||
| ...episodeAssignedTriggerCommonDefinition, | ||
| icon: EpisodeAssignedIcon, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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