2026-03-30 15:26:16 +08:00
|
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
2026-03-30 18:03:40 +08:00
|
|
|
|
// LogEvent 表示一条归一化/存储后的日志事件。
|
2026-03-30 15:26:16 +08:00
|
|
|
|
type LogEvent struct {
|
2026-03-30 18:03:40 +08:00
|
|
|
|
// ID 是数据库主键。
|
|
|
|
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
|
|
|
|
// CreatedAt 记录创建时间(写入日志事件时)。
|
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
|
// SourceKind 表示日志来源类型(例如 trap/syslog 等)。
|
|
|
|
|
|
SourceKind string `gorm:"size:16;index" json:"source_kind"`
|
|
|
|
|
|
// RemoteAddr 表示日志发送方地址。
|
|
|
|
|
|
RemoteAddr string `gorm:"size:64" json:"remote_addr"`
|
|
|
|
|
|
// RawPayload 保存原始负载内容。
|
|
|
|
|
|
RawPayload string `gorm:"type:text" json:"raw_payload"`
|
|
|
|
|
|
// NormalizedSummary 保存归一化后的摘要信息。
|
|
|
|
|
|
NormalizedSummary string `gorm:"type:text" json:"normalized_summary"`
|
|
|
|
|
|
// NormalizedDetail 保存归一化后的详细信息。
|
|
|
|
|
|
NormalizedDetail string `gorm:"type:text" json:"normalized_detail"`
|
|
|
|
|
|
// DeviceName 表示关联设备名称。
|
|
|
|
|
|
DeviceName string `gorm:"size:512;index" json:"device_name"`
|
2026-04-27 19:26:57 +08:00
|
|
|
|
// SourceIP 表示原始来源 IP(不含端口)。
|
|
|
|
|
|
SourceIP string `gorm:"size:64;index" json:"source_ip"`
|
|
|
|
|
|
// ResourceType 表示关联到的资源类型。
|
|
|
|
|
|
ResourceType string `gorm:"size:32;index" json:"resource_type"`
|
|
|
|
|
|
// ResourceID 表示关联到的资源 ID。
|
|
|
|
|
|
ResourceID string `gorm:"size:128;index" json:"resource_id"`
|
|
|
|
|
|
// ResourceName 表示关联到的资源名称。
|
|
|
|
|
|
ResourceName string `gorm:"size:256" json:"resource_name"`
|
|
|
|
|
|
// MatchMethod 表示资源命中方式(ip/hostname/none)。
|
|
|
|
|
|
MatchMethod string `gorm:"size:32" json:"match_method"`
|
|
|
|
|
|
// DispatchStatus 表示告警分发状态(not_applicable/pending/retrying/sent/dead)。
|
|
|
|
|
|
DispatchStatus string `gorm:"size:32;index" json:"dispatch_status"`
|
2026-03-30 18:03:40 +08:00
|
|
|
|
// SeverityCode 表示告警/严重度编码。
|
|
|
|
|
|
SeverityCode string `gorm:"size:32" json:"severity_code"`
|
|
|
|
|
|
// TrapOID 表示关联的 Trap OID(若来源为 trap)。
|
|
|
|
|
|
TrapOID string `gorm:"size:512;index" json:"trap_oid"`
|
|
|
|
|
|
// AlertSent 表示是否已将告警发送出去。
|
|
|
|
|
|
AlertSent bool `json:"alert_sent"`
|
2026-03-30 15:26:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (LogEvent) TableName() string {
|
|
|
|
|
|
return "logs_events"
|
|
|
|
|
|
}
|