Files
logs/internal/models/log_event.go
2026-03-30 18:03:40 +08:00

34 lines
1.4 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 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"`
// 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"
}