- 修复 ops_repo_latency_histogram_buckets.go 中另一个函数的 WriteString 未检查错误 - 修复 ops_repo_request_details.go 和 ops_repo_trends.go 中的 Rows.Close 未检查错误 - 修复 ops_alert_models.go, ops_cleanup_service.go, ops_request_details.go 的格式化问题 - 移除 ops_retry.go 中未使用的 status 字段 - 修复 maxTime 函数重复声明(将测试文件中的函数重命名为 testMaxTime)
75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
package service
|
|
|
|
import "time"
|
|
|
|
// Ops alert rule/event models.
|
|
//
|
|
// NOTE: These are admin-facing DTOs and intentionally keep JSON naming aligned
|
|
// with the existing ops dashboard frontend (backup style).
|
|
|
|
const (
|
|
OpsAlertStatusFiring = "firing"
|
|
OpsAlertStatusResolved = "resolved"
|
|
)
|
|
|
|
type OpsAlertRule struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
|
|
Enabled bool `json:"enabled"`
|
|
Severity string `json:"severity"`
|
|
|
|
MetricType string `json:"metric_type"`
|
|
Operator string `json:"operator"`
|
|
Threshold float64 `json:"threshold"`
|
|
|
|
WindowMinutes int `json:"window_minutes"`
|
|
SustainedMinutes int `json:"sustained_minutes"`
|
|
CooldownMinutes int `json:"cooldown_minutes"`
|
|
|
|
NotifyEmail bool `json:"notify_email"`
|
|
|
|
Filters map[string]any `json:"filters,omitempty"`
|
|
|
|
LastTriggeredAt *time.Time `json:"last_triggered_at,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type OpsAlertEvent struct {
|
|
ID int64 `json:"id"`
|
|
RuleID int64 `json:"rule_id"`
|
|
Severity string `json:"severity"`
|
|
Status string `json:"status"`
|
|
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
|
|
MetricValue *float64 `json:"metric_value,omitempty"`
|
|
ThresholdValue *float64 `json:"threshold_value,omitempty"`
|
|
|
|
Dimensions map[string]any `json:"dimensions,omitempty"`
|
|
|
|
FiredAt time.Time `json:"fired_at"`
|
|
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
|
|
|
|
EmailSent bool `json:"email_sent"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type OpsAlertEventFilter struct {
|
|
Limit int
|
|
|
|
// Optional filters.
|
|
Status string
|
|
Severity string
|
|
|
|
StartTime *time.Time
|
|
EndTime *time.Time
|
|
|
|
// Dimensions filters (best-effort).
|
|
Platform string
|
|
GroupID *int64
|
|
}
|