F1 告警静默规则 [done]: - 后端 alert_silence.go: CRUD + Toggle (onetime/daily/weekly 三模式) - 告警引擎 isSilenced 集成 (alert_engine.go) - 前端 SilenceRuleTab + SilenceDialog - 路由 /alerts/silences 已注册 F2 审计日志导出 [done]: - 重写 ExportAuditLogs: 真正的 CSV 导出 (encoding/csv + UTF-8 BOM) - 支持 module/action/username/startTime/endTime 筛选 - 导出限制 10000 条防溢出,自动记录审计日志 - JSON 格式向后兼容 (format=json) - 前端 exportLogs 传递查询参数 同时包含累积的前期工作: - 目录重构 internal/ -> controller/model/router (v0.55-v0.57) - 后端分层架构 dto/repository/service/utils - 审计模块全功能 (终端审计/操作审计/登录日志) - asciicast v2 录制格式 - SFTP 文件浏览器 - StatStrip 紧凑统计条 - 在线会话自动刷新 - LiveMonitor WebSocket 诊断修复 验证: go build ✅ | npm run build ✅ | Docker 部署 ✅ | 10 回归端点 ✅ | CSV 导出 ✅ | 静默 CRUD ✅
85 lines
3.8 KiB
Go
85 lines
3.8 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
)
|
|
|
|
// AnsiblePlaybook Playbook 模型 // Logan.Li
|
|
type AnsiblePlaybook struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Name string `gorm:"size:255;not null" json:"name"`
|
|
Description string `gorm:"type:text" json:"description"`
|
|
Content string `gorm:"type:text;not null" json:"content"` // YAML 内容
|
|
Tags string `gorm:"size:500" json:"tags"` // 逗号分隔
|
|
Category string `gorm:"size:100" json:"category"` // deployment/maintenance/etc
|
|
CreatedBy string `gorm:"size:255" json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (AnsiblePlaybook) TableName() string { return "ops_ansible_playbooks" }
|
|
|
|
// AnsibleJob 执行任务记录 // Logan.Li
|
|
type AnsibleJob struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
PlaybookID uint `gorm:"not null" json:"playbook_id"`
|
|
PlaybookName string `gorm:"size:255" json:"playbook_name"`
|
|
Status string `gorm:"size:20;default:pending" json:"status"` // pending/running/success/failed
|
|
TargetHosts string `gorm:"type:text" json:"target_hosts"` // JSON 数组
|
|
Variables string `gorm:"type:text" json:"variables"` // JSON
|
|
Output string `gorm:"type:text" json:"output"`
|
|
Duration int64 `gorm:"default:0" json:"duration"` // 毫秒
|
|
TriggeredBy string `gorm:"size:255" json:"triggered_by"`
|
|
StartedAt *time.Time `json:"started_at"`
|
|
CompletedAt *time.Time `json:"completed_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (AnsibleJob) TableName() string { return "ops_ansible_jobs" }
|
|
|
|
// AnsibleInventory 主机清单 // Logan.Li
|
|
type AnsibleInventory struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Name string `gorm:"size:255;not null" json:"name"`
|
|
Description string `gorm:"type:text" json:"description"`
|
|
Hosts string `gorm:"type:text" json:"hosts"` // JSON 数组 [{name,ip,port,user,os}]
|
|
CreatedBy string `gorm:"size:255" json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (AnsibleInventory) TableName() string { return "ops_ansible_inventories" }
|
|
|
|
// LogSource 日志源 // Logan.Li
|
|
type LogSource struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Name string `gorm:"size:255;not null" json:"name"`
|
|
Type string `gorm:"size:50;not null" json:"type"` // application/syslog/docker/kubernetes
|
|
Status string `gorm:"size:20;default:active" json:"status"`
|
|
Config string `gorm:"type:text" json:"config"` // JSON {path/pattern}
|
|
LogCount int64 `gorm:"default:0" json:"log_count"`
|
|
LastSeen *time.Time `json:"last_seen"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (LogSource) TableName() string { return "sys_log_sources" }
|
|
|
|
// LogEntry 日志条目 // Logan.Li
|
|
type LogEntry struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
SourceID uint `gorm:"index" json:"source_id"`
|
|
Timestamp time.Time `gorm:"index" json:"timestamp"`
|
|
Level string `gorm:"size:20;index" json:"level"` // error/warn/info/debug
|
|
Service string `gorm:"size:255;index" json:"service"`
|
|
Host string `gorm:"size:255;index" json:"host"`
|
|
Message string `gorm:"type:text" json:"message"`
|
|
TraceID string `gorm:"size:100;index" json:"trace_id"`
|
|
Raw string `gorm:"type:text" json:"raw"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
func (LogEntry) TableName() string { return "sys_log_entries" }
|