feat(数据库): 添加运维监控数据模型和数据库迁移脚本
- 新增 ops 监控数据库迁移脚本(表结构定义) - 定义核心数据模型(ops_models.go) - 定义告警相关模型(ops_alert_models.go) - 定义仪表板数据模型(ops_dashboard_models.go) - 定义实时监控数据模型(ops_realtime_models.go) - 定义配置相关模型(ops_settings_models.go) - 定义趋势分析数据模型(ops_trend_models.go)
This commit is contained in:
70
backend/internal/service/ops_settings_models.go
Normal file
70
backend/internal/service/ops_settings_models.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package service
|
||||
|
||||
// Ops settings models stored in DB `settings` table (JSON blobs).
|
||||
|
||||
type OpsEmailNotificationConfig struct {
|
||||
Alert OpsEmailAlertConfig `json:"alert"`
|
||||
Report OpsEmailReportConfig `json:"report"`
|
||||
}
|
||||
|
||||
type OpsEmailAlertConfig struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Recipients []string `json:"recipients"`
|
||||
MinSeverity string `json:"min_severity"`
|
||||
RateLimitPerHour int `json:"rate_limit_per_hour"`
|
||||
BatchingWindowSeconds int `json:"batching_window_seconds"`
|
||||
IncludeResolvedAlerts bool `json:"include_resolved_alerts"`
|
||||
}
|
||||
|
||||
type OpsEmailReportConfig struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Recipients []string `json:"recipients"`
|
||||
DailySummaryEnabled bool `json:"daily_summary_enabled"`
|
||||
DailySummarySchedule string `json:"daily_summary_schedule"`
|
||||
WeeklySummaryEnabled bool `json:"weekly_summary_enabled"`
|
||||
WeeklySummarySchedule string `json:"weekly_summary_schedule"`
|
||||
ErrorDigestEnabled bool `json:"error_digest_enabled"`
|
||||
ErrorDigestSchedule string `json:"error_digest_schedule"`
|
||||
ErrorDigestMinCount int `json:"error_digest_min_count"`
|
||||
AccountHealthEnabled bool `json:"account_health_enabled"`
|
||||
AccountHealthSchedule string `json:"account_health_schedule"`
|
||||
AccountHealthErrorRateThreshold float64 `json:"account_health_error_rate_threshold"`
|
||||
}
|
||||
|
||||
// OpsEmailNotificationConfigUpdateRequest allows partial updates, while the
|
||||
// frontend can still send the full config shape.
|
||||
type OpsEmailNotificationConfigUpdateRequest struct {
|
||||
Alert *OpsEmailAlertConfig `json:"alert"`
|
||||
Report *OpsEmailReportConfig `json:"report"`
|
||||
}
|
||||
|
||||
type OpsDistributedLockSettings struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Key string `json:"key"`
|
||||
TTLSeconds int `json:"ttl_seconds"`
|
||||
}
|
||||
|
||||
type OpsAlertSilenceEntry struct {
|
||||
RuleID *int64 `json:"rule_id,omitempty"`
|
||||
Severities []string `json:"severities,omitempty"`
|
||||
|
||||
UntilRFC3339 string `json:"until_rfc3339"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
type OpsAlertSilencingSettings struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
GlobalUntilRFC3339 string `json:"global_until_rfc3339"`
|
||||
GlobalReason string `json:"global_reason"`
|
||||
|
||||
Entries []OpsAlertSilenceEntry `json:"entries,omitempty"`
|
||||
}
|
||||
|
||||
type OpsAlertRuntimeSettings struct {
|
||||
EvaluationIntervalSeconds int `json:"evaluation_interval_seconds"`
|
||||
|
||||
DistributedLock OpsDistributedLockSettings `json:"distributed_lock"`
|
||||
Silencing OpsAlertSilencingSettings `json:"silencing"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user