feat(audit): F1+F2 告警静默规则标记完成 + 审计日志CSV导出实现
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 ✅
This commit is contained in:
1 parent
e57718998a
commit
77c234b060
314 files changed
+10050
-4065
No files matched your search
@@ -9,8 +9,8 @@ import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"ezops/internal/config"
|
||||
"ezops/internal/models"
|
||||
"ezops/config"
|
||||
"ezops/model"
|
||||
"ezops/pkg/database"
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ func main() {
|
||||
}
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
var clusters []models.KubernetesCluster
|
||||
var clusters []model.KubernetesCluster
|
||||
db.Find(&clusters)
|
||||
if len(clusters) == 0 {
|
||||
fmt.Println("No clusters found — run mock.go first")
|
||||
@@ -54,7 +54,7 @@ func main() {
|
||||
for _, cluster := range clusters {
|
||||
// Skip if pods already exist for this cluster
|
||||
var podCount int64
|
||||
db.Model(&models.KubernetesPod{}).Where("cluster_id = ?", cluster.ID).Count(&podCount)
|
||||
db.Model(&model.KubernetesPod{}).Where("cluster_id = ?", cluster.ID).Count(&podCount)
|
||||
if podCount > 0 {
|
||||
fmt.Printf("Cluster %s already has %d pods, skipping\n", cluster.Name, podCount)
|
||||
continue
|
||||
@@ -79,7 +79,7 @@ func main() {
|
||||
if available < 0 {
|
||||
available = 0
|
||||
}
|
||||
db.Create(&models.KubernetesDeployment{
|
||||
db.Create(&model.KubernetesDeployment{
|
||||
ClusterID: cluster.ID,
|
||||
Namespace: namespaces[rand.Intn(len(namespaces))],
|
||||
Name: depNames[d],
|
||||
@@ -94,7 +94,7 @@ func main() {
|
||||
// Pods
|
||||
numPods := 12 + rand.Intn(18)
|
||||
for p := 0; p < numPods; p++ {
|
||||
db.Create(&models.KubernetesPod{
|
||||
db.Create(&model.KubernetesPod{
|
||||
ClusterID: cluster.ID,
|
||||
Namespace: namespaces[rand.Intn(len(namespaces))],
|
||||
Name: fmt.Sprintf("%s-pod-%d", cluster.Code, p+1),
|
||||
@@ -126,7 +126,7 @@ func main() {
|
||||
default:
|
||||
ports = `[{"port":3306,"protocol":"TCP","targetPort":3306}]`
|
||||
}
|
||||
svc := models.KubernetesService{
|
||||
svc := model.KubernetesService{
|
||||
ClusterID: cluster.ID,
|
||||
Namespace: namespaces[rand.Intn(len(namespaces))],
|
||||
Name: svcNames[s],
|
||||
@@ -150,7 +150,7 @@ func main() {
|
||||
numIngs = len(ingNames)
|
||||
}
|
||||
for ig := 0; ig < numIngs; ig++ {
|
||||
db.Create(&models.KubernetesIngress{
|
||||
db.Create(&model.KubernetesIngress{
|
||||
ClusterID: cluster.ID,
|
||||
Namespace: namespaces[rand.Intn(len(namespaces))],
|
||||
Name: ingNames[ig],
|
||||
@@ -162,9 +162,9 @@ func main() {
|
||||
|
||||
// Update cluster counts to match actual data
|
||||
var depCnt, podCnt, svcCnt int64
|
||||
db.Model(&models.KubernetesDeployment{}).Where("cluster_id = ?", cluster.ID).Count(&depCnt)
|
||||
db.Model(&models.KubernetesPod{}).Where("cluster_id = ?", cluster.ID).Count(&podCnt)
|
||||
db.Model(&models.KubernetesService{}).Where("cluster_id = ?", cluster.ID).Count(&svcCnt)
|
||||
db.Model(&model.KubernetesDeployment{}).Where("cluster_id = ?", cluster.ID).Count(&depCnt)
|
||||
db.Model(&model.KubernetesPod{}).Where("cluster_id = ?", cluster.ID).Count(&podCnt)
|
||||
db.Model(&model.KubernetesService{}).Where("cluster_id = ?", cluster.ID).Count(&svcCnt)
|
||||
db.Model(&cluster).Updates(map[string]interface{}{
|
||||
"deployment_count": depCnt,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user