Skip to content

feat(alertd): KAM-483: re-implement slack integration via webhook targets#269

Merged
passcod merged 4 commits intomainfrom
feat/kam-483/alertd-slack-integration
Mar 17, 2026
Merged

feat(alertd): KAM-483: re-implement slack integration via webhook targets#269
passcod merged 4 commits intomainfrom
feat/kam-483/alertd-slack-integration

Conversation

@passcod
Copy link
Copy Markdown
Member

@passcod passcod commented Mar 16, 2026

Summary

Re-implements Slack integration in alertd. Slack targets are configured in _targets.yml with a webhook URL and optional custom fields. Multiple target types can share the same ID, so an alert can notify both email and Slack simultaneously.

Context

KAM-483 — Slack alerts were removed along with Zendesk in an earlier simplification, but it turns out at least one deployment (Aspen) relied on Slack alerts because email alerts to Zendesk didn't work properly. This caused confusion where alerts appeared to be working (email) while support couldn't see them (Slack).

Changes

  • targets/slack.rs: New TargetSlack struct with webhook URL and configurable fields, adapted from the legacy bestool tamanu alerts implementation
  • targets.rs: Introduce TargetConnection enum (Email | Slack) replacing the email-only ExternalTarget.conn; target type is auto-detected from YAML fields (addresses → email, webhook → slack)
  • alert.rs / daemon.rs: Add http_client: reqwest::Client to InternalContext for webhook POSTs
  • scheduler.rs / events.rs: Pass HTTP client through to ResolvedTarget::send()
  • Remove facet dependency: Was only used in derives, not needed
  • Add url crate with serde feature for webhook URL parsing
  • Documentation: Updated TARGETS.md and ALERTS.md

No breaking changes

Existing email-only _targets.yml configurations continue to work unchanged. Slack is purely additive.

Example _targets.yml

targets:
  # Email and Slack with the same ID — alerts go to both
  - id: ops-team
    addresses:
      - ops@example.com

  - id: ops-team
    webhook: https://hooks.slack.com/services/T.../B.../xxx

KAM-483

Adds Slack as a target type alongside email in alertd. Slack targets
are configured in _targets.yml with a webhook URL and optional custom
fields. Multiple target types can share the same ID, so an alert can
notify both email and Slack simultaneously.

Changes:
- Add targets/slack.rs with TargetSlack (webhook + fields)
- Introduce TargetConnection enum (Email | Slack) to replace the
  previous email-only ExternalTarget.conn
- Add http_client to InternalContext for Slack webhook POSTs
- Update ResolvedTarget::send() to dispatch by target type
- Remove facet dependency (unused outside derives)
- Add url crate with serde feature for webhook URL parsing
- Update TARGETS.md and ALERTS.md documentation

No breaking changes to existing email-only configurations.

Generated-With: Claude
@passcod passcod changed the title feat(alertd): re-implement slack integration via webhook targets (KAM-483) feat(alertd): KAM-483: re-implement slack integration via webhook targets Mar 16, 2026
@passcod passcod merged commit 7cc44e3 into main Mar 17, 2026
15 checks passed
@passcod passcod deleted the feat/kam-483/alertd-slack-integration branch March 17, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant