58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
// shared/lib/alert/types.ts — 告警类型定义
|
|
export type AlertLevel = 'critical' | 'warning' | 'info'
|
|
export type ServiceStatus = 'normal' | 'abnormal' | 'unknown'
|
|
export type CheckType = 'http' | 'docker' | 'ssh'
|
|
export type AlertType = 'alert' | 'recovery' | 'flapping'
|
|
|
|
export interface HealthCheckConfig {
|
|
type: CheckType
|
|
url?: string
|
|
expectedStatus?: number
|
|
expectedBody?: string
|
|
containerName?: string
|
|
sshHost?: string
|
|
sshCommand?: string
|
|
}
|
|
|
|
export interface MonitoredService {
|
|
id: number
|
|
name: string
|
|
category: 'container' | 'endpoint' | 'custom'
|
|
alertLevel: AlertLevel
|
|
checks: HealthCheckConfig[]
|
|
checkInterval: number
|
|
checkTimeout: number
|
|
enabled: boolean
|
|
currentStatus: ServiceStatus
|
|
statusSince: string
|
|
}
|
|
|
|
export interface CheckResult {
|
|
success: boolean
|
|
status: ServiceStatus
|
|
error?: string
|
|
latency: number
|
|
checkType: CheckType
|
|
}
|
|
|
|
export interface AlertDecision {
|
|
shouldPush: boolean
|
|
reason?: string
|
|
}
|
|
|
|
export interface AlertChannelConfig {
|
|
id: number
|
|
name: string
|
|
channelType: 'wechat' | 'email'
|
|
webhookUrl: string
|
|
enabled: boolean
|
|
levelCritical: boolean
|
|
levelWarning: boolean
|
|
levelInfo: boolean
|
|
quietEnabled: boolean
|
|
quietStart: string
|
|
quietEnd: string
|
|
quietBypassCritical: boolean
|
|
cooldownMinutes: number
|
|
}
|