feat: add webhook notification service and refactor data management
Some checks failed
CI / test (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
Security Scan / backend-security (push) Has been cancelled
Security Scan / frontend-security (push) Has been cancelled

## Backend Changes
- Add WebhookService for sending alert notifications via HTTP webhooks
- Implement HMAC-SHA256 signature for webhook payload authentication
- Add webhook configuration API endpoints and settings
- Integrate webhook calls into OpsAlertEvaluatorService
- Fix routes/common.go string conversion (use strconv.Itoa)
- Add comprehensive webhook service tests

## Frontend Changes
- Add webhook notification configuration UI in OpsSettingsDialog
- Add WebhookNotificationConfig types and API functions
- Add i18n translations for webhook features (zh/en)
- Refactor DataManagementView.vue into modular components:
  - PostgresProfilesCard.vue (356 lines)
  - RedisProfilesCard.vue (331 lines)
  - S3ProfilesCard.vue (363 lines)
  - BackupJobsCard.vue (216 lines)
  - DataManagementView.vue (94 lines)
- Add OpsSettingsDialog component tests

## Testing
- All backend tests pass
- All frontend tests pass
- Webhook service tests cover signature, HTTP, timeout, error handling
This commit is contained in:
User
2026-04-15 23:03:48 +08:00
parent d96a9f384a
commit eb5d32553d
30 changed files with 3360 additions and 27 deletions

View File

@@ -804,6 +804,25 @@ export interface EmailNotificationConfig {
}
}
export interface WebhookNotificationConfig {
alert: {
enabled: boolean
urls: string[]
secret?: string
min_severity: AlertSeverity | ''
timeout_seconds: number
include_resolved: boolean
rate_limit_per_hour: number
}
report: {
enabled: boolean
urls: string[]
secret?: string
daily_enabled: boolean
daily_schedule: string
}
}
export interface OpsMetricThresholds {
sla_percent_min?: number | null // SLA低于此值变红
ttft_p99_ms_max?: number | null // TTFT P99高于此值变红
@@ -1300,6 +1319,17 @@ export async function updateEmailNotificationConfig(config: EmailNotificationCon
return data
}
// Webhook notification config (DB-backed)
export async function getWebhookNotificationConfig(): Promise<WebhookNotificationConfig> {
const { data } = await apiClient.get<WebhookNotificationConfig>('/admin/ops/webhook-notification/config')
return data
}
export async function updateWebhookNotificationConfig(config: WebhookNotificationConfig): Promise<WebhookNotificationConfig> {
const { data } = await apiClient.put<WebhookNotificationConfig>('/admin/ops/webhook-notification/config', config)
return data
}
// Runtime settings (DB-backed)
export async function getAlertRuntimeSettings(): Promise<OpsAlertRuntimeSettings> {
const { data } = await apiClient.get<OpsAlertRuntimeSettings>('/admin/ops/runtime/alert')
@@ -1407,6 +1437,8 @@ export const opsAPI = {
createAlertSilence,
getEmailNotificationConfig,
updateEmailNotificationConfig,
getWebhookNotificationConfig,
updateWebhookNotificationConfig,
getAlertRuntimeSettings,
updateAlertRuntimeSettings,
getRuntimeLogConfig,