package models import "time" // LogEvent 表示一条归一化/存储后的日志事件。 type LogEvent struct { // 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"` // 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"` // 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"` } func (LogEvent) TableName() string { return "logs_events" }