feat: add webhook notification service and refactor data management
## 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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user