Files
aiops/backend/model/monitor_alert_rule.go
T
2026-07-09 14:16:56 +08:00

35 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import "time"
// MonitorAlertCategory 监控告警规则分类 // Logan.Li
type MonitorAlertCategory string
const (
MonitorAlertHost MonitorAlertCategory = "host"
MonitorAlertMiddleware MonitorAlertCategory = "middleware"
MonitorAlertSNMP MonitorAlertCategory = "snmp"
MonitorAlertSite MonitorAlertCategory = "site"
)
// MonitorAlertRule 中间件/站点拨测告警规则(主机规则仍用 AgentRule)// Logan.Li
type MonitorAlertRule struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
Category MonitorAlertCategory `gorm:"type:varchar(16);not null;index" json:"category"`
Name string `gorm:"type:varchar(128);not null" json:"name"`
TargetID uint `gorm:"default:0;index;comment:目标ID,0=全部" json:"target_id"`
Metric string `gorm:"type:varchar(64);not null" json:"metric"`
Operator string `gorm:"type:varchar(8);default:>" json:"operator"`
Threshold float64 `gorm:"type:decimal(12,4)" json:"threshold"`
Severity string `gorm:"type:varchar(16);default:warning" json:"severity"`
Enabled bool `gorm:"default:true" json:"enabled"`
DurationSec int `gorm:"default:0;comment:持续秒数(预留)" json:"duration_sec"`
Port int `gorm:"default:0" json:"port,omitempty"`
Description string `gorm:"type:varchar(256)" json:"description,omitempty"`
LastTriggered *time.Time `json:"last_triggered,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (MonitorAlertRule) TableName() string { return "monitor_probe_alert_rules" }