refactor(alertmanager): move API handlers to signozapiserver#10941
Merged
Conversation
Extract Handler interface in pkg/alertmanager/handler.go and move the implementation from api.go to signozalertmanager/handler.go. Register all alertmanager routes (channels, route policies, alerts) in signozapiserver via handler.New() with OpenAPIDef. Remove AlertmanagerAPI injection from http_handler.go. This enables future AuditDef instrumentation on these routes.
therealpandey
commented
Apr 15, 2026
- Rename `am` to `alertmanagerService` in NewHandlers - Add /api/v1/channels/test as the canonical test endpoint - Mark /api/v1/testChannel as deprecated - Regenerate OpenAPI spec
therealpandey
commented
Apr 15, 2026
- PostableRoutePolicy: mark expression, name, channels as required - GettableRoutePolicy: change CreatedAt/UpdatedAt from pointer to value - Channel: mark name, type, data, orgId as required - ExpressionKind: add Enum() for rule/policy values - Regenerate OpenAPI spec and frontend clients
CreateChannel, UpdateChannelByID, TestChannel, and TestChannelDeprecated all read req.Body as a Receiver config. The OpenAPIDef must declare the request type so the generated SDK includes the body parameter.
srikanthccv
reviewed
Apr 15, 2026
srikanthccv
left a comment
Member
There was a problem hiding this comment.
Thanks, one role change. Shouldn't be a problem for backwards compatibility because channels was never accessible frontend. If someone had used API, then it would have been admin, under the assumption that create from API would also want to edit/delete so If they didn't run into that problem, they must have been an admin.
Aligns CreateChannel endpoint with the rest of the channel mutation endpoints (update/delete) which all require admin access. This is consistent with the frontend where notifications are not accessible to editors.
srikanthccv
approved these changes
Apr 15, 2026
AndersonFirmino
added a commit
to AndersonFirmino/signoz
that referenced
this pull request
Apr 18, 2026
The Edit Notification Channel page rendered Discord channels as Slack and
the Test button sent slack_configs with an empty api_url instead of
discord_configs with the webhook_url. Discord was missing end-to-end from
the UI even though the backend already supports discord_configs.
Bug 1 — Discord shown as Slack on Edit
prepChannelConfig in pages/ChannelsEdit only matched slack/msteams/pager/
opsgenie/email/webhook. discord_configs fell through to the default branch
which returned ChannelType.Slack, so the type selector (disabled in edit
mode) was stuck on Slack and the Slack settings form rendered.
Bug 2 — Test sent slack_configs with empty api_url
EditAlertChannels.performChannelTest had no Discord case. Combined with
Bug 1 the test fell through to testSlackApi, which posted slack_configs
with api_url="" (Discord payload uses webhook_url, not api_url) and the
alertmanager rejected it with "unsupported scheme".
Changes
* Extract prepChannelConfig as a pure, exported function for direct
testing (was a closure-bound function inside the component).
* Detect discord_configs first in prepChannelConfig and return
ChannelType.Discord.
* Add ChannelType.Discord and DiscordChannel interface to the channel
config types.
* Add api/channels/{create,edit,test}Discord.ts and matching request type
files. Test endpoint stays on /testChannel (the new
/api/v1/channels/test wired by PR SigNoz#10941 lands in v0.120).
* Add FormAlertChannels/Settings/Discord.tsx with webhook_url, title and
message fields, register it in renderSettings, and add the Discord
option to the type dropdown.
* Wire prepareDiscordRequest, onDiscordEditHandler, onDiscordHandler and
the Discord case in performChannelTest in both EditAlertChannels and
CreateAlertChannels.
Tests
* frontend/src/pages/ChannelsEdit/__tests__/prepChannelConfig.test.ts —
6 cases covering Discord detection, Slack/Webhook/MsTeams precedence,
legacy Slack fallback for unknown payloads, and discord-over-slack
determinism when both keys are present.
* frontend/src/api/channels/__tests__/testDiscord.test.ts — 2 cases
asserting the payload shape (discord_configs with webhook_url, no
slack_configs, no api_url leak).
* Verified red without the fix (2 failing assertions) and green with the
fix (8/8 passing). Existing 122 channel tests still pass.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Handlerinterface inpkg/alertmanager/handler.goand move implementation topkg/alertmanager/signozalertmanager/handler.gosignozapiserverviahandler.New()withOpenAPIDefAlertmanagerAPIinjection fromhttp_handler.goandserver.gorequired/nullable/Enum()tags to alertmanager types for accurate OpenAPI schemas/api/v1/channels/testendpoint, mark/api/v1/testChannelas deprecatedWhy?
http_handler.gointo the typedsignozapiserverwith fullOpenAPIDef, bringing us closer to fully deprecating https://signoz.io/api-reference/#/ — only rules and dashboards remain on the legacy pathrequired,nullable,Enum()), the Terraform provider can start generating resources for channels and route policies from the spechandler.New()supportWithAuditDef()injection — this is a prerequisite for instrumenting notification channel and route policy mutations with audit events (SigNoz/platform-pod#1938)Test plan
go build ./cmd/... ./pkg/... ./ee/...passes/api/v1/channels/testworks,/api/v1/testChannelstill works (deprecated)closes SigNoz/platform-pod#2087