Skip to content

[Alerting v2] Create workflow extension service#267924

Merged
adcoelho merged 3 commits into
elastic:mainfrom
adcoelho:alerting-v2-workflow-triggers
May 6, 2026
Merged

[Alerting v2] Create workflow extension service#267924
adcoelho merged 3 commits into
elastic:mainfrom
adcoelho:alerting-v2-workflow-triggers

Conversation

@adcoelho
Copy link
Copy Markdown
Contributor

@adcoelho adcoelho commented May 6, 2026

Closes https://github.com/elastic/rna-program/issues/446

Summary

This PR creates a new WorkflowExtensionsService and does the wiring for registering workflow triggers and steps in the alerting v2 plugin.

How registration works

I created a README with this information, but:

  1. Define a shared trigger definition in common (id + eventSchema) with Zod.
  2. Register it on the server in server/lib/workflow_extensions/register_trigger_definitions.ts via registerTriggerDefinitions(service), which calls WorkflowExtensionsService.registerTriggerDefinitions(...).
  3. Define a public trigger definition (PublicTriggerDefinition) with UI metadata (title, description, icon, docs).
  4. Register it on the public side in public/lib/workflow_extensions/register_trigger_definitions.ts via registerTriggerDefinitions(service).
  5. Add/update the trigger schema hash in:
    • src/platform/plugins/shared/workflows_extensions/test/scout/api/fixtures/approved_trigger_definitions.ts

To confirm a trigger was created correctly:

How to visualize this in the UI

  1. Start Kibana normally (your local dev workflow).
  2. Go to Management -> Workflows.
  3. Create/edit a workflow and open trigger selection.
  4. Look for your trigger title
  5. Open its docs panel; you should see the configured description/example from translations.ts.

@adcoelho adcoelho requested a review from kdelemme May 6, 2026 09:58
@adcoelho adcoelho self-assigned this May 6, 2026
@adcoelho adcoelho requested a review from a team as a code owner May 6, 2026 09:58
@adcoelho adcoelho added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// Feature:AlertingV2 labels May 6, 2026
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

Pinging @elastic/response-ops (Team:ResponseOps)

Copy link
Copy Markdown
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

I'm very confused by the duplicated services

) {}

public registerStepDefinitions(stepDefintions: ServerStepDefinitionOrLoader[]): void {
stepDefintions.forEach((stepDefinition) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
stepDefintions.forEach((stepDefinition) =>
stepDefinitions.forEach((stepDefinition) =>

registerPublicTriggerDefinitions(triggerDefinitions: PublicTriggerDefinition[]): void;
}

export class WorkflowExtensionsService implements WorkflowExtensionsPublicServiceContract {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't understand we have two WorkflowExtensionsService ?

@@ -0,0 +1,42 @@
# Alerting V2 workflows_extensions integration
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we add an entry for defining a step definition?

Copy link
Copy Markdown
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

Sorry I missed the obvious public/server shenanigans. Would love a full example in the readme for the step definition but not blocking. I think #266668 will use this.

@adcoelho
Copy link
Copy Markdown
Contributor Author

adcoelho commented May 6, 2026

Sorry I missed the obvious public/server shenanigans. Would love a full example in the readme for the step definition but not blocking. I think #266668 will use this.

I tested this with a mock trigger but did not include that code in the PR. I will open a PR next for an "assign user to episode trigger registration". That should also help. Thanks for the review!

@adcoelho adcoelho enabled auto-merge (squash) May 6, 2026 12:54
@kibanamachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
alertingVTwo 981 983 +2

Page load bundle

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

id before after diff
alertingVTwo 43.6KB 44.0KB +396.0B

History

cc @adcoelho

@adcoelho adcoelho merged commit f743eb6 into elastic:main May 6, 2026
66 checks passed
@cnasikas
Copy link
Copy Markdown
Member

cnasikas commented May 6, 2026

I take a look at the PR, and I would like to discuss/suggest some changes:

  • I think we should separate the setup from the emitting in the service. It is ok to have only functions for setup, as we do with registerSavedObjects and registerFeaturePrivileges.
  • The service should have only the emitEvent: (triggerId: string, payload: Record<string, unknown>) => Promise<void>.
  • The constructor should accept the workflow client already instantiated with @inject as we do with the ES and SO client in the other services.
  • Put one README in x-pack/platform/plugins/shared/alerting_v2/public/lib/workflow_extensions for public and one in x-pack/platform/plugins/shared/alerting_v2/server/lib/services/workflow_extensions_service/tokens.ts for server. You can update the x-pack/platform/plugins/shared/alerting_v2/README.md with a paragraph that points to the two files and explains why and how they wire together.

ersin-erdal pushed a commit to ersin-erdal/kibana that referenced this pull request May 6, 2026
Closes elastic/rna-program#446

## Summary

This PR creates a new `WorkflowExtensionsService` and does the wiring
for registering workflow triggers and steps in the alerting v2 plugin.

## How registration works

I created a README with this information, but:

1. Define a shared trigger definition in `common` (`id` + `eventSchema`)
with Zod.
2. Register it on the server in
`server/lib/workflow_extensions/register_trigger_definitions.ts` via
`registerTriggerDefinitions(service)`, which calls
`WorkflowExtensionsService.registerTriggerDefinitions(...)`.
3. Define a public trigger definition (`PublicTriggerDefinition`) with
UI metadata (title, description, icon, docs).
4. Register it on the public side in
`public/lib/workflow_extensions/register_trigger_definitions.ts` via
`registerTriggerDefinitions(service)`.
5. Add/update the trigger schema hash in:
-
`src/platform/plugins/shared/workflows_extensions/test/scout/api/fixtures/approved_trigger_definitions.ts`
   
To confirm a trigger was created correctly:

How to visualize this in the UI
1. Start Kibana normally (your local dev workflow).
2. Go to Management -> Workflows.
3. Create/edit a workflow and open trigger selection.
4. Look for your trigger title
5. Open its docs panel; you should see the configured
description/example from translations.ts.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
adcoelho added a commit that referenced this pull request May 8, 2026
## Summary

[This PR addresses this
comment.](#267924 (comment))

> - I think we should separate the setup from the emitting in the
service. It is ok to have only functions for setup, as we do with
registerSavedObjects and registerFeaturePrivileges.
> - The service should have only the emitEvent: (triggerId: string,
payload: Record<string, unknown>) => Promise<void>.
> - The constructor should accept the workflow client already
instantiated with @Inject as we do with the ES and SO client in the
other services.
> - Put one README in
x-pack/platform/plugins/shared/alerting_v2/public/lib/workflow_extensions
for public and one in
x-pack/platform/plugins/shared/alerting_v2/server/lib/services/workflow_extensions_service/tokens.ts
for server. You can update the
x-pack/platform/plugins/shared/alerting_v2/README.md with a paragraph
that points to the two files and explains why and how they wire
together.
js-jankisalvi pushed a commit to js-jankisalvi/kibana that referenced this pull request May 12, 2026
## Summary

[This PR addresses this
comment.](elastic#267924 (comment))

> - I think we should separate the setup from the emitting in the
service. It is ok to have only functions for setup, as we do with
registerSavedObjects and registerFeaturePrivileges.
> - The service should have only the emitEvent: (triggerId: string,
payload: Record<string, unknown>) => Promise<void>.
> - The constructor should accept the workflow client already
instantiated with @Inject as we do with the ES and SO client in the
other services.
> - Put one README in
x-pack/platform/plugins/shared/alerting_v2/public/lib/workflow_extensions
for public and one in
x-pack/platform/plugins/shared/alerting_v2/server/lib/services/workflow_extensions_service/tokens.ts
for server. You can update the
x-pack/platform/plugins/shared/alerting_v2/README.md with a paragraph
that points to the two files and explains why and how they wire
together.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:AlertingV2 release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants