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
@@ -60,9 +60,10 @@ type AlertRule struct {
|
||||
Name string `gorm:"type:varchar(128);not null;comment:规则名称" json:"name"`
|
||||
Description string `gorm:"type:varchar(500);comment:规则描述" json:"description,omitempty"`
|
||||
// ====== 原 V1 兼容字段 ======
|
||||
Type string `gorm:"type:varchar(32);comment:规则类型: metric/log/event" json:"type,omitempty"`
|
||||
Source string `gorm:"type:varchar(64);comment:数据源: prometheus/zabbix/custom" json:"source,omitempty"`
|
||||
Expression string `gorm:"type:text;comment:PromQL/Zabbix表达式" json:"expression,omitempty"`
|
||||
Type string `gorm:"type:varchar(32);comment:规则类型: metric/log/event" json:"type,omitempty"`
|
||||
Source string `gorm:"type:varchar(64);comment:数据源: prometheus/zabbix/custom/loki/elasticsearch" json:"source,omitempty"`
|
||||
Expression string `gorm:"type:text;comment:PromQL/Zabbix/LogQL/Lucene表达式" json:"expression,omitempty"`
|
||||
DatasourceID uint `gorm:"index;comment:日志/指标数据源ID" json:"datasource_id,omitempty"`
|
||||
Severity string `gorm:"type:varchar(32);default:'warning';comment:告警级别" json:"severity"`
|
||||
Duration int `gorm:"comment:持续时间(秒)" json:"duration,omitempty"`
|
||||
Enabled bool `gorm:"default:true;comment:是否启用" json:"enabled"`
|
||||
@@ -360,6 +361,7 @@ type CreateAlertRuleRequest struct {
|
||||
Expression string `json:"expression" binding:"required"`
|
||||
Severity string `json:"severity" binding:"omitempty,oneof=info warning critical"`
|
||||
Duration int `json:"duration"`
|
||||
DatasourceID uint `json:"datasource_id"`
|
||||
Labels string `json:"labels"`
|
||||
Annotations string `json:"annotations"`
|
||||
NotifyChannels []string `json:"notify_channels"`
|
||||
@@ -372,6 +374,7 @@ type UpdateAlertRuleRequest struct {
|
||||
Expression string `json:"expression"`
|
||||
Severity string `json:"severity" binding:"omitempty,oneof=info warning critical"`
|
||||
Duration int `json:"duration"`
|
||||
DatasourceID uint `json:"datasource_id"`
|
||||
Enabled *bool `json:"enabled"`
|
||||
Labels string `json:"labels"`
|
||||
Annotations string `json:"annotations"`
|
||||
|
||||
@@ -55,9 +55,13 @@ type UpdateLogDSReq struct {
|
||||
}
|
||||
|
||||
// TestLogDSReq 测试连接 // Logan.Li
|
||||
// 支持两种模式:
|
||||
// 1. 新建/未保存场景:必须传 type + url + 认证参数;
|
||||
// 2. 已保存数据源场景:传 datasource_id,后端读取完整配置(含密码)再测试。// Logan.Li
|
||||
type TestLogDSReq struct {
|
||||
Type string `json:"type" binding:"required"`
|
||||
URL string `json:"url" binding:"required"`
|
||||
DatasourceID uint `json:"datasource_id"`
|
||||
Type string `json:"type"`
|
||||
URL string `json:"url"`
|
||||
BasicAuth bool `json:"basic_auth"`
|
||||
BasicAuthUser string `json:"basic_auth_user"`
|
||||
BasicAuthPass string `json:"basic_auth_pass"`
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// TraceDataSource 链路追踪数据源(Jaeger / Tempo) // Logan.Li
|
||||
type TraceDataSource struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement;comment:主键ID" json:"id"`
|
||||
Name string `gorm:"type:varchar(128);not null;uniqueIndex;comment:数据源名称" json:"name"`
|
||||
Type string `gorm:"type:varchar(32);not null;index;comment:类型 jaeger/tempo" json:"type"`
|
||||
URL string `gorm:"type:varchar(512);not null;comment:服务地址" json:"url"`
|
||||
BasicAuth bool `gorm:"default:false;comment:基础认证" json:"basic_auth"`
|
||||
BasicAuthUser string `gorm:"type:varchar(128);comment:认证用户名" json:"basic_auth_user,omitempty"`
|
||||
BasicAuthPass string `gorm:"type:varchar(256);comment:认证密码" json:"basic_auth_pass,omitempty"`
|
||||
SkipTLSVerify bool `gorm:"default:false;comment:跳过TLS验证" json:"skip_tls_verify"`
|
||||
IsDefault bool `gorm:"default:false;index;comment:是否默认" json:"is_default"`
|
||||
Status int `gorm:"default:1;comment:状态 1启用 0禁用" json:"status"`
|
||||
CreatedAt time.Time `gorm:"not null;comment:创建时间" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"not null;comment:更新时间" json:"updated_at"`
|
||||
DeletedAt *time.Time `gorm:"index;comment:删除时间" json:"deleted_at,omitempty"`
|
||||
}
|
||||
|
||||
func (TraceDataSource) TableName() string {
|
||||
return "monitor_trace_datasources"
|
||||
}
|
||||
|
||||
// CreateTraceDSReq 创建链路追踪数据源请求
|
||||
type CreateTraceDSReq struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Type string `json:"type" binding:"required"`
|
||||
URL string `json:"url" binding:"required"`
|
||||
BasicAuth bool `json:"basic_auth"`
|
||||
BasicAuthUser string `json:"basic_auth_user"`
|
||||
BasicAuthPass string `json:"basic_auth_pass"`
|
||||
SkipTLSVerify bool `json:"skip_tls_verify"`
|
||||
IsDefault bool `json:"is_default"`
|
||||
}
|
||||
|
||||
// UpdateTraceDSReq 更新链路追踪数据源请求(partial update)
|
||||
type UpdateTraceDSReq struct {
|
||||
Name *string `json:"name"`
|
||||
Type *string `json:"type"`
|
||||
URL *string `json:"url"`
|
||||
BasicAuth *bool `json:"basic_auth"`
|
||||
BasicAuthUser *string `json:"basic_auth_user"`
|
||||
BasicAuthPass *string `json:"basic_auth_pass"`
|
||||
SkipTLSVerify *bool `json:"skip_tls_verify"`
|
||||
IsDefault *bool `json:"is_default"`
|
||||
Status *int `json:"status"`
|
||||
}
|
||||
|
||||
// TestTraceDSReq 测试连接请求
|
||||
type TestTraceDSReq struct {
|
||||
URL string `json:"url" binding:"required"`
|
||||
Type string `json:"type"`
|
||||
BasicAuth bool `json:"basic_auth"`
|
||||
BasicAuthUser string `json:"basic_auth_user"`
|
||||
BasicAuthPass string `json:"basic_auth_pass"`
|
||||
SkipTLSVerify bool `json:"skip_tls_verify"`
|
||||
}
|
||||
Reference in new issue
Block a user