Skip to content

[alerter]feature: add Microsoft Teams as an alert notification channel - #4347

Open
Rangsh wants to merge 5 commits into
apache:masterfrom
Rangsh:feature-ms-teams-notify
Open

Rangsh wants to merge 5 commits into
apache:masterfrom
Rangsh:feature-ms-teams-notify

Conversation

@Rangsh

@Rangsh Rangsh commented Aug 24, 2026 •

Copy link
Copy Markdown

Support Teams Workflows webhook with Adaptive Card payload (type=17), URI-safe sending for Power Automate URLs, React receiver form/i18n, default template, docs, and unit tests. Fixes #4346.

What's changed?

Add Microsoft Teams as an independent alert notification channel.

Office 365 Incoming Webhooks have been retired. This PR integrates Teams Workflows (Power Automate) webhooks and sends alerts as Adaptive Cards.

The change is rebased onto current master and the receiver UI is rebuilt on the React frontend. Type 16 is already used by WPUSH, so Microsoft Teams is type 17.

  • Add TeamsAlertNotifyHandlerImpl (type = 17) in alerter
  • Add teamsWebHookUrl on NoticeReceiver (@Size(max = 1000))
  • Send HTTP requests via java.net.URI so pre-encoded Power Automate query params are not re-encoded (same issue as fix(alerter): keep webhook query params intact #4249)
  • Render Adaptive Cards with severity-based colors (Attention / Warning / Default / Good)
  • Mask the Teams webhook URL in NoticeReceiverMaskUtil and the receiver contract
  • React frontend: receiver catalog, draft/schema, type labels, i18n (en / zh-CN / zh-TW / ja / pt-BR)
  • Default template: 17-MicrosoftTeamsTemplate.txt
  • Docs: alert_teams.md (EN/zh-CN), guide, and sidebar
  • Unit tests for success / non-2xx / URL validation / URI verbatim sending / color mapping

Fixes #4346

Checklist

  • I have read the Contributing Guide
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Add or update API

  • I have added the necessary e2e tests and all cases have passed.

@github-actions github-actions Bot added doc Improvements or additions to documentation backend webapp labels Aug 24, 2026
@thefullgc

Copy link
Copy Markdown
Member

The alerter/backend side still looks mergeable after a rebase, but the frontend part (NoticeReceiver.ts, alert-notice components, the i18n json files) is on the old Angular app that no longer exists on master. The UI side needs to be redone on the new React frontend before this can land.

@Rangsh
Rangsh force-pushed the feature-ms-teams-notify branch from 5408854 to 490cbc8 Compare October 12, 2026 01:55
@Rangsh

Rangsh commented Oct 12, 2026

Copy link
Copy Markdown
Author

@tomsun28 Thanks for the review. The frontend has been rebuilt on the current React app, and the branch is now based on the latest master.

The old Angular files (NoticeReceiver.ts, alert-notice components, and the old i18n JSON) are no longer part of this change. The receiver form now comes from the React notice-receiver catalog, including the type label, secret field, draft/schema mapping, and the five current locale files.

One necessary adjustment: type 16 is already used by WPUSH on master, so Microsoft Teams is now type 17 (microsoft-teams) instead of the original type 16. The backend handler, contract mapper, secret masking, default template, docs, and tests are updated to match.

Please take another look when you have time.

Rangsh and others added 4 commits December 5, 2026 10:13
Move the Teams Workflows channel onto current master as type 17, because type 16 is already used by WPUSH, and rebuild the receiver form on the React catalog instead of the removed Angular UI.
Signed-off-by: Logic <zqr10159@126.com>
Signed-off-by: Logic <zqr10159@126.com>
Keep existing V201 databases additive and fresh installs aligned with NoticeReceiver.teamsWebHookUrl.
@Rangsh
Rangsh force-pushed the feature-ms-teams-notify branch from 5fe8485 to e3ba119 Compare December 5, 2026 02:18
@Rangsh

Rangsh commented Dec 5, 2026

Copy link
Copy Markdown
Author

@tomsun28 @thefullgc Could you approve the pending workflows for this update?

Rebased onto current master. The previous backend failure was hzb_notice_receiver.teams_web_hook_url missing from the V201 baseline. This push adds the nullable varchar(1000) column to the MySQL and PostgreSQL B201 baselines (H2 loads the MySQL baseline) and an additive ALTER in the H2, MySQL, and PostgreSQL V201 migrations. The old AlertTemplateUtil.render compile error is already gone after the rebase; the handler uses NoticeTemplateRenderer.

Fork workflows are waiting on maintainer approval, so CI has not run yet. A review is still needed after the checks pass.

@zqr10159

zqr10159 commented Dec 5, 2026

Copy link
Copy Markdown
Member

Thanks for the update. Please align the schema version with the HertzBeat release version. All SQL scripts shipping with HertzBeat 2.0.0 use schema version 200 (B200 / V200), not 201. Please update the Teams schema changes accordingly across H2, MySQL, and PostgreSQL, and keep SQL from earlier releases unchanged.

Align Teams DDL with HertzBeat 2.0.0 schema version 200 per review: add the column in V200/B200 for h2, mysql, and postgresql, and remove additive changes from V201 while keeping the current B201 baseline column for fresh installs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Rangsh

Rangsh commented Dec 5, 2026

Copy link
Copy Markdown
Author

Thanks for the review @zqr10159 — schema versioning is aligned with 2.0.0 now.

Changes

  • Added teams_web_hook_url to the V200 migrations (h2 / mysql / postgresql), including the idempotent ApplyV200Alterations path on MySQL.
  • Added the column to B200__current_schema.sql (mysql / postgresql; h2 pins the updated B200 SHA).
  • Removed the Teams-related DDL from V201__create_agent_workflow_state.sql across all dialects.
  • Left V190 and earlier scripts unchanged.
  • The B201 current baseline still declares teams_web_hook_url on hzb_notice_receiver for fresh installs (B201 baseline only — no Teams DDL in V201).

Verification

  • MigrationInventoryTest, AgentWorkflowSchemaUpgradeTest, EmbeddedH2BaselineResourceTest, and TargetSchemaBaselineResourceTest pass locally on JDK 25.

Pushed in ce45529. Please let me know if anything else should be adjusted.

@zqr10159

zqr10159 commented Dec 5, 2026

Copy link
Copy Markdown
Member

Thanks for updating the Teams migrations, @Rangsh. Could you hold off on rebasing until #4598 is merged? It consolidates the 2.0.0 schema into B200 for fresh installs and V200 for upgrades. Once it lands, please rebase onto master, keep the Teams SQL in B200/V200 only across H2, MySQL, and PostgreSQL, and refresh the H2 baseline checksum. Let us know when that’s ready and we’ll take another look at the diff and CI.

@Rangsh

Rangsh commented Dec 6, 2026

Copy link
Copy Markdown
Author

Thanks @zqr10159 — understood. I’ll wait for #4598 to land before rebasing onto master. After that I’ll keep the Teams DDL in B200/V200 only (H2, MySQL, PostgreSQL), refresh the H2 baseline checksum, and ping you once the rebase is done and CI is green.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend doc Improvements or additions to documentation webapp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add Microsoft Teams as an alert notification channel

3 participants