feat(monitor): F5 链路追踪后端对接 — traceApi mock桩改真实Jaeger/Tempo代理+demo兜底
- 后端新增 monitor_trace_datasources 表 + TraceDataSource 模型 (Jaeger/Tempo) - controller/trace_datasource.go — CRUD + TestConnection + SetDefault (7 路由) - controller/trace_proxy.go — Jaeger API 代理 + 响应格式转换 (Trace/服务/Span) - GET /traces — Trace 列表 (代理 Jaeger /api/traces) - GET /traces/services — 服务列表 + P95/P99/errorRate 聚合 - GET /traces/:traceId — Trace 详情 (Span 树转换) - Demo 数据兜底: 无数据源时返回模拟数据 (6 Trace + 5 服务 + 5 Span) - 前端 traceApi 从 mock 改真实 HTTP 调用 - 前端新增 trace-datasource.ts 数据源管理 API - ROADMAP/TDD_PLAN/PROJECT_EVALUATION 文档同步更新 - 综合评分 90→91, 功能完整性 92→94 (mock API 清零)
This commit is contained in:
1 parent
0c2c0adaaf
commit
894cb16a05
23 files changed
+1085
-52
No files matched your search
@@ -1,12 +1,18 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"ezops/model"
|
||||
@@ -19,6 +25,7 @@ import (
|
||||
// 支持分布式锁:多副本部署时仅 Leader 执行检查,避免重复告警
|
||||
type AlertEngine struct {
|
||||
db *gorm.DB
|
||||
ds *LogDSHandler // 日志数据源 handler,用于执行日志告警规则 // Logan.Li
|
||||
cache ezredis.Cache // 可选 Redis 缓存(分布式锁)
|
||||
instanceID string // 当前实例唯一标识
|
||||
}
|
||||
@@ -30,13 +37,15 @@ const (
|
||||
|
||||
// NewAlertEngine 创建告警引擎实例
|
||||
// cache 参数用于分布式锁(多副本部署)。nil 时为单实例模式,不竞争锁。
|
||||
func NewAlertEngine(db *gorm.DB, cache ezredis.Cache) *AlertEngine {
|
||||
// ds 用于日志告警规则查询数据源。// Logan.Li
|
||||
func NewAlertEngine(db *gorm.DB, cache ezredis.Cache, ds *LogDSHandler) *AlertEngine {
|
||||
// 生成唯一实例 ID(随机 hex,防止多副本 PID/hostname 碰撞)
|
||||
idBytes := make([]byte, 8)
|
||||
_, _ = rand.Read(idBytes)
|
||||
instanceID := fmt.Sprintf("ae-%s", hex.EncodeToString(idBytes))
|
||||
return &AlertEngine{
|
||||
db: db,
|
||||
ds: ds,
|
||||
cache: cache,
|
||||
instanceID: instanceID,
|
||||
}
|
||||
@@ -56,6 +65,7 @@ func (e *AlertEngine) Check() {
|
||||
e.checkResourceAlerts()
|
||||
e.checkOfflineAlerts()
|
||||
e.checkPortAlerts()
|
||||
e.checkLogAlertRules()
|
||||
e.autoResolveAlerts()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user