Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Centralize alert webhook labels

rcourtman98757dec6394
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index 491e1917eb..51ffa5b694 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -71,7 +71,7 @@ normalization fork.
The alert webhook service chooser also now derives its service set from the
backend webhook template registry, rather than keeping a second frontend-only
-list of services and descriptions.
+list of services, labels, and descriptions.
Frontend alert surfaces and backend alert-support files now require explicit
registry path-policy coverage, so new alert-owned runtime files must be mapped
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 1e61268954..f3dfcad07d 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -356,6 +356,10 @@ return the governed response envelope, but notifications-owned service-template
selection, safe header copying, and generic webhook-test payload fallback must
stay in `internal/notifications/` rather than becoming a second API-layer owner
for the same transport contract.
+The notifications API boundary also carries the canonical webhook template
+shape used by the frontend service chooser: `frontend-modern/src/api/notifications.ts`
+must expose the registry's service label and description metadata, and it may
+not invent a second frontend-only service taxonomy for the chooser.
That same notifications boundary must also canonicalize legacy service-specific
input aliases at ingress instead of leaving them as a live runtime contract:
Pushover `app_token` / `user_token` may be accepted only at config/API/UI input
diff --git a/docs/release-control/v6/internal/subsystems/notifications.md b/docs/release-control/v6/internal/subsystems/notifications.md
index 7169592c40..61b5000404 100644
--- a/docs/release-control/v6/internal/subsystems/notifications.md
+++ b/docs/release-control/v6/internal/subsystems/notifications.md
@@ -79,8 +79,8 @@ runtime.
The webhook template registry is also the canonical source of truth for the
alert webhook service set and the metadata the frontend uses to build its
service chooser. Frontend presentation may format the options, but it must
-derive the available services from the backend template registry instead of
-keeping a second hardcoded service list.
+derive the available services, labels, and descriptions from the backend
+template registry instead of keeping a second hardcoded service list.
Email single-alert, grouped, resolved, and HTML send paths must follow that
same ownership rule: they may expose different calling surfaces, but they must
all route through one canonical enhanced email executor instead of rebuilding
diff --git a/frontend-modern/src/api/__tests__/notifications.test.ts b/frontend-modern/src/api/__tests__/notifications.test.ts
index b4879d652e..0c4694589d 100644
--- a/frontend-modern/src/api/__tests__/notifications.test.ts
+++ b/frontend-modern/src/api/__tests__/notifications.test.ts
@@ -87,4 +87,31 @@ describe('NotificationsAPI', () => {
expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/notifications/webhooks');
expect(result).toEqual([]);
});
+
+ it('surfaces webhook template labels from the API', async () => {
+ apiFetchJSONMock.mockResolvedValueOnce([
+ {
+ service: 'discord',
+ label: 'Discord',
+ name: 'Discord Webhook',
+ description: 'Discord server webhook',
+ urlPattern: 'https://discord.com/api/webhooks/.../...',
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ payloadTemplate: '',
+ instructions: '',
+ },
+ ] as any);
+
+ const templates = await NotificationsAPI.getWebhookTemplates();
+
+ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/notifications/webhook-templates');
+ expect(templates).toEqual([
+ expect.objectContaining({
+ service: 'discord',
+ label: 'Discord',
+ description: 'Discord server webhook',
+ }),
+ ]);
+ });
});
diff --git a/frontend-modern/src/api/notifications.ts b/frontend-modern/src/api/notifications.ts
index 4171a2dc69..031a467ce0 100644
--- a/frontend-modern/src/api/notifications.ts
+++ b/frontend-modern/src/api/notifications.ts
@@ -24,6 +24,7 @@ export interface EmailProvider {
export interface WebhookTemplate {
id?: string;
service: string;
+ label?: string;
name: string;
urlPattern: string;
method: string;
diff --git a/frontend-modern/src/components/Alerts/WebhookConfig.test.tsx b/frontend-modern/src/components/Alerts/WebhookConfig.test.tsx
index 197efd9b5b..2f4d47cc9f 100644
--- a/frontend-modern/src/components/Alerts/WebhookConfig.test.tsx
+++ b/frontend-modern/src/components/Alerts/WebhookConfig.test.tsx
@@ -39,6 +39,7 @@ function makeWebhook(overrides: Partial<Webhook> = {}): Webhook {
const discordTemplate = {
service: 'discord',
+ label: 'Discord',
name: 'Discord Webhook',
description: 'Discord server webhook',
urlPattern: 'https://discord.com/api/webhooks/...',
@@ -50,6 +51,7 @@ const discordTemplate = {
const slackTemplate = {
service: 'slack',
+ label: 'Slack',
name: 'Slack Webhook',
description: 'Slack incoming webhook',
urlPattern: 'https://hooks.slack.com/services/...',
@@ -61,6 +63,7 @@ const slackTemplate = {
const genericTemplate = {
service: 'generic',
+ label: 'Generic',
name: 'Generic Webhook',
description: 'Custom webhook endpoint',
urlPattern: 'https://example.com/webhook',
@@ -72,6 +75,7 @@ const genericTemplate = {
const pushoverTemplate = {
service: 'pushover',
+ label: 'Pushover',
name: 'Pushover',
description: 'Mobile push notifications',
urlPattern: 'https://api.pushover.net/1/messages.json',
diff --git a/frontend-modern/src/components/Alerts/WebhookConfig.tsx b/frontend-modern/src/components/Alerts/WebhookConfig.tsx
index c2683cba47..ad57eec736 100644
--- a/frontend-modern/src/components/Alerts/WebhookConfig.tsx
+++ b/frontend-modern/src/components/Alerts/WebhookConfig.tsx
@@ -31,7 +31,7 @@ import {
getAlertWebhookMentionPlaceholder,
getAlertWebhookCustomFieldPresets,
getAlertWebhookNamePlaceholder,
- getAlertWebhookServiceLabel,
+ getAlertWebhookServiceLabelFromTemplates,
getAlertWebhookServices,
getAlertWebhookSetupInstructionsTitle,
getAlertWebhookSubmitLabel,
@@ -52,6 +52,7 @@ import {
interface WebhookTemplate {
service: string;
+ label?: string;
name: string;
description?: string;
urlPattern: string;
@@ -393,7 +394,7 @@ export function WebhookConfig(props: WebhookConfigProps) {
</div>
<div class="mt-2 flex flex-wrap gap-2 text-[11px] text-muted sm:text-xs">
<span class="rounded bg-surface-alt px-2 py-0.5 text-base-content">
- {getAlertWebhookServiceLabel(webhook.service || 'generic')}
+ {getAlertWebhookServiceLabelFromTemplates(webhook.service || 'generic', templates())}
</span>
<span class="rounded bg-surface-alt px-2 py-0.5 text-base-content">
{webhook.method}
@@ -441,7 +442,7 @@ export function WebhookConfig(props: WebhookConfigProps) {
onClick={() => setShowServiceDropdown(!showServiceDropdown())}
class="text-sm text-blue-600 hover:text-blue-700 dark:text-blue-400"
>
- {getAlertWebhookServiceLabel(formData().service)} →
+ {getAlertWebhookServiceLabelFromTemplates(formData().service, templates())} →
</button>
</div>
diff --git a/frontend-modern/src/utils/__tests__/alertWebhookPresentation.test.ts b/frontend-modern/src/utils/__tests__/alertWebhookPresentation.test.ts
index 8543af15d0..aabd73c5e1 100644
--- a/frontend-modern/src/utils/__tests__/alertWebhookPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/alertWebhookPresentation.test.ts
@@ -4,6 +4,7 @@ import {
ALERT_WEBHOOK_TEST_SUCCESS,
getAlertWebhookServices,
getAlertWebhookCustomFieldPresets,
+ getAlertWebhookServiceLabelFromTemplates,
getAlertWebhookTestFailure,
getAlertWebhookTestSuccess,
normalizeAlertWebhookCustomFields,
@@ -61,6 +62,7 @@ describe('alertWebhookPresentation', () => {
getAlertWebhookServices([
{
service: 'discord',
+ label: 'Discord',
name: 'Discord Webhook',
description: 'Discord server webhook',
urlPattern: 'https://discord.com/api/webhooks/.../...',
@@ -71,6 +73,7 @@ describe('alertWebhookPresentation', () => {
},
{
service: 'generic',
+ label: 'Generic',
name: 'Generic Webhook',
description: 'Custom webhook endpoint',
urlPattern: '',
@@ -93,4 +96,24 @@ describe('alertWebhookPresentation', () => {
},
]);
});
+
+ it('prefers backend template labels for service presentation', () => {
+ expect(
+ getAlertWebhookServiceLabelFromTemplates('discord', [
+ {
+ service: 'discord',
+ label: 'Discord',
+ name: 'Discord Webhook',
+ description: 'Discord server webhook',
+ urlPattern: 'https://discord.com/api/webhooks/.../...',
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ payloadTemplate: '',
+ instructions: '',
+ },
+ ]),
+ ).toBe('Discord');
+
+ expect(getAlertWebhookServiceLabelFromTemplates('custom-service', [])).toBe('custom-service');
+ });
});
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index b4f37fbe37..788b24b17a 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -2976,7 +2976,7 @@ describe('frontend resource type boundaries', () => {
it('keeps alert webhook service vocabulary and action copy in a shared presentation utility', () => {
expect(webhookConfigSource).toContain('getAlertWebhookServices(templates())');
- expect(webhookConfigSource).toContain('getAlertWebhookServiceLabel');
+ expect(webhookConfigSource).toContain('getAlertWebhookServiceLabelFromTemplates');
expect(webhookConfigSource).toContain('getAlertWebhookCustomFieldPresets');
expect(webhookConfigSource).toContain('normalizeAlertWebhookCustomFields');
expect(webhookConfigSource).toContain('getAlertWebhookSummaryLabel');
@@ -3001,7 +3001,7 @@ describe('frontend resource type boundaries', () => {
expect(webhookConfigSource).not.toContain('Disable All');
expect(webhookConfigSource).not.toContain('Enable this webhook');
expect(alertWebhookPresentationSource).toContain(
- 'export function getAlertWebhookServiceLabel',
+ 'export function getAlertWebhookServiceLabelFromTemplates',
);
expect(alertWebhookPresentationSource).toContain(
'export function getAlertWebhookServices',
diff --git a/frontend-modern/src/utils/alertWebhookPresentation.ts b/frontend-modern/src/utils/alertWebhookPresentation.ts
index 57d03e40e4..cf6b6c4914 100644
--- a/frontend-modern/src/utils/alertWebhookPresentation.ts
+++ b/frontend-modern/src/utils/alertWebhookPresentation.ts
@@ -153,7 +153,7 @@ export const ALERT_WEBHOOK_ENABLE_ALL_LABEL = 'Enable All';
export function getAlertWebhookServices(templates: AlertWebhookTemplate[] = []) {
return templates.map((template) => ({
id: template.service,
- label: getAlertWebhookServiceLabel(template.service),
+ label: template.label || getAlertWebhookServiceLabel(template.service),
description: template.description || template.name,
}));
}
@@ -162,6 +162,17 @@ export function getAlertWebhookServiceLabel(service: string) {
return ALERT_WEBHOOK_SERVICE_PRESENTATION[service as AlertWebhookService]?.label || service;
}
+export function getAlertWebhookServiceLabelFromTemplates(
+ service: string,
+ templates: AlertWebhookTemplate[] = [],
+) {
+ const template = templates.find((item) => item.service === service);
+ if (template?.label?.trim()) {
+ return template.label.trim();
+ }
+ return getAlertWebhookServiceLabel(service);
+}
+
export function getAlertWebhookCustomFieldPresets(service: string) {
return ALERT_WEBHOOK_CUSTOM_FIELD_PRESETS[service.trim().toLowerCase()];
}
diff --git a/internal/api/notifications_test.go b/internal/api/notifications_test.go
index 4eb4d38b71..9244563171 100644
--- a/internal/api/notifications_test.go
+++ b/internal/api/notifications_test.go
@@ -485,6 +485,9 @@ func TestNotificationHandlers(t *testing.T) {
w := httptest.NewRecorder()
h.GetWebhookTemplates(w, req)
assert.Equal(t, 200, w.Code)
+ body := w.Body.String()
+ assert.Contains(t, body, `"label":"Discord"`)
+ assert.Contains(t, body, `"label":"Generic"`)
})
t.Run("GetWebhookHistory", func(t *testing.T) {
diff --git a/internal/notifications/templates_test.go b/internal/notifications/templates_test.go
index 29bc14dfd8..afc615b28e 100644
--- a/internal/notifications/templates_test.go
+++ b/internal/notifications/templates_test.go
@@ -179,6 +179,11 @@ func TestGetWebhookTemplates(t *testing.T) {
t.Errorf("Template %q has empty Name", tmpl.Service)
}
+ // Label must be non-empty so the frontend can derive the canonical service chooser
+ if tmpl.Label == "" {
+ t.Errorf("Template %q has empty Label", tmpl.Service)
+ }
+
// Description must be non-empty so the frontend can derive the service chooser
if tmpl.Description == "" {
t.Errorf("Template %q has empty Description", tmpl.Service)
@@ -257,6 +262,9 @@ func TestGetWebhookTemplates_DiscordSettings(t *testing.T) {
t.Fatal("Discord template not found")
}
+ if discord.Label != "Discord" {
+ t.Errorf("Discord Label = %q, want Discord", discord.Label)
+ }
if !strings.Contains(discord.URLPattern, "discord.com") {
t.Errorf("Discord URLPattern should contain discord.com, got %q", discord.URLPattern)
}
@@ -287,6 +295,9 @@ func TestGetWebhookTemplates_SlackSettings(t *testing.T) {
t.Fatal("Slack template not found")
}
+ if slack.Label != "Slack" {
+ t.Errorf("Slack Label = %q, want Slack", slack.Label)
+ }
if !strings.Contains(slack.URLPattern, "hooks.slack.com") {
t.Errorf("Slack URLPattern should contain hooks.slack.com, got %q", slack.URLPattern)
}
@@ -314,6 +325,9 @@ func TestGetWebhookTemplates_TelegramSettings(t *testing.T) {
t.Fatal("Telegram template not found")
}
+ if telegram.Label != "Telegram" {
+ t.Errorf("Telegram Label = %q, want Telegram", telegram.Label)
+ }
if !strings.Contains(telegram.URLPattern, "api.telegram.org") {
t.Errorf("Telegram URLPattern should contain api.telegram.org, got %q", telegram.URLPattern)
}
@@ -344,6 +358,9 @@ func TestGetWebhookTemplates_PagerDutySettings(t *testing.T) {
t.Fatal("PagerDuty template not found")
}
+ if pagerduty.Label != "PagerDuty" {
+ t.Errorf("PagerDuty Label = %q, want PagerDuty", pagerduty.Label)
+ }
if !strings.Contains(pagerduty.URLPattern, "pagerduty.com") {
t.Errorf("PagerDuty URLPattern should contain pagerduty.com, got %q", pagerduty.URLPattern)
}
@@ -384,6 +401,9 @@ func TestGetWebhookTemplates_GenericSettings(t *testing.T) {
t.Fatal("Generic template not found")
}
+ if generic.Label != "Generic" {
+ t.Errorf("Generic Label = %q, want Generic", generic.Label)
+ }
// Generic should have empty URL pattern (user fills it in)
if generic.URLPattern != "" {
t.Errorf("Generic URLPattern = %q, want empty", generic.URLPattern)
@@ -458,6 +478,7 @@ func TestEmailProviderConfig_Fields(t *testing.T) {
func TestWebhookTemplate_Fields(t *testing.T) {
tmpl := WebhookTemplate{
Service: "test",
+ Label: "Test",
Name: "Test Webhook",
URLPattern: "https://example.com/webhook",
Method: "POST",
@@ -469,6 +490,9 @@ func TestWebhookTemplate_Fields(t *testing.T) {
if tmpl.Service != "test" {
t.Errorf("Service = %q, want test", tmpl.Service)
}
+ if tmpl.Label != "Test" {
+ t.Errorf("Label = %q, want Test", tmpl.Label)
+ }
if tmpl.Name != "Test Webhook" {
t.Errorf("Name = %q, want Test Webhook", tmpl.Name)
}
diff --git a/internal/notifications/webhook_templates.go b/internal/notifications/webhook_templates.go
index 924f1e6767..21f9247dac 100644
--- a/internal/notifications/webhook_templates.go
+++ b/internal/notifications/webhook_templates.go
@@ -3,6 +3,7 @@ package notifications
// WebhookTemplate represents a webhook template for popular services
type WebhookTemplate struct {
Service string `json:"service"`
+ Label string `json:"label"`
Name string `json:"name"`
Description string `json:"description"`
URLPattern string `json:"urlPattern"`
@@ -18,6 +19,7 @@ func GetWebhookTemplates() []WebhookTemplate {
return []WebhookTemplate{
{
Service: "discord",
+ Label: "Discord",
Name: "Discord Webhook",
Description: "Discord server webhook",
URLPattern: "https://discord.com/api/webhooks/{webhook_id}/{webhook_token}",
@@ -67,6 +69,7 @@ func GetWebhookTemplates() []WebhookTemplate {
},
{
Service: "telegram",
+ Label: "Telegram",
Name: "Telegram Bot",
Description: "Telegram bot notifications",
URLPattern: "https://api.telegram.org/bot{bot_token}/sendMessage",
@@ -88,6 +91,7 @@ func GetWebhookTemplates() []WebhookTemplate {
},
{
Service: "slack",
+ Label: "Slack",
Name: "Slack Incoming Webhook",
Description: "Slack incoming webhook",
URLPattern: "https://hooks.slack.com/services/{webhook_path}",
@@ -183,6 +187,7 @@ func GetWebhookTemplates() []WebhookTemplate {
},
{
Service: "teams",
+ Label: "Microsoft Teams",
Name: "Microsoft Teams",
Description: "Microsoft Teams webhook",
URLPattern: "https://{tenant}.webhook.office.com/webhookb2/{webhook_path}",
@@ -239,6 +244,7 @@ func GetWebhookTemplates() []WebhookTemplate {
},
{
Service: "pagerduty",
+ Label: "PagerDuty",
Name: "PagerDuty Events API v2",
Description: "PagerDuty Events API v2",
URLPattern: "https://events.pagerduty.com/v2/enqueue",
@@ -284,6 +290,7 @@ func GetWebhookTemplates() []WebhookTemplate {
},
{
Service: "teams-adaptive",
+ Label: "Teams (Adaptive)",
Name: "Microsoft Teams (Adaptive Card)",
Description: "Teams with Adaptive Cards",
URLPattern: "https://{tenant}.webhook.office.com/webhookb2/{webhook_path}",
@@ -373,6 +380,7 @@ func GetWebhookTemplates() []WebhookTemplate {
},
{
Service: "pushover",
+ Label: "Pushover",
Name: "Pushover",
Description: "Mobile push notifications",
URLPattern: "https://api.pushover.net/1/messages.json",
@@ -401,6 +409,7 @@ func GetWebhookTemplates() []WebhookTemplate {
},
{
Service: "gotify",
+ Label: "Gotify",
Name: "Gotify",
Description: "Self-hosted push notifications",
URLPattern: "https://{your-gotify-server}/message?token={your-app-token}",
@@ -449,6 +458,7 @@ func GetWebhookTemplates() []WebhookTemplate {
},
{
Service: "ntfy",
+ Label: "ntfy",
Name: "ntfy.sh",
Description: "Push notifications via ntfy.sh",
URLPattern: "https://ntfy.sh/{topic}",
@@ -476,6 +486,7 @@ View in Pulse: {{.Instance}}`,
},
{
Service: "mattermost",
+ Label: "Mattermost",
Name: "Mattermost Incoming Webhook",
Description: "Mattermost incoming webhook",
URLPattern: "https://{your-mattermost-server}/hooks/{webhook_id}",
@@ -495,6 +506,7 @@ View in Pulse: {{.Instance}}`,
},
{
Service: "generic",
+ Label: "Generic",
Name: "Generic JSON Webhook",
Description: "Custom webhook endpoint",
URLPattern: "",