feat: 监控告警体系统一重构 + 自动化任务调度引擎 + 监控大屏拆分
告警中心 - 新增统一告警(alert_unified)、监控告警规则(monitor_alert_rule)、指标目录(alert_metric_catalog) - 通知策略与消息分发(alert_notify_policy/dispatch/message)、静默规则 - 告警引擎按阈值/SNMP 拆分(alert_engine_monitor/snmp) 监控采集 - SNMP 常量/模板与历史指标(snmp templates/constants、snmp_metrics_history、snmp_collect) - 中间件监控 Redis 采集与种子(middleware_monitor_redis/seed) - 站点探测 pkg(siteprobe) + 站点视图(site_view) 自动化任务 - cron 调度器(cronscheduler)、脚本运行器(scriptrunner)、系统任务(systask)及运行记录(cron_job_run、system_task) 审计与凭证 - 审计设置(audit_setting) + 历史清理(auditcleaner) 前端 - 监控页面(host/middleware/site/snmp)拆分为子模块并大屏化 - 告警中心多 Tab(规则/指标目录/通知策略/静默)、任务管理组件重构、Agent CLI Markdown 渲染 - 移除旧脚本卡片/详情/日志组件,统一为 ScriptTable/ScriptCodeEditor/TerminalOutput Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
092d0e4b9e
commit
471353e3d7
190 files changed
+16640
-3484
No files matched your search
@@ -176,16 +176,67 @@ func writeSSEError(c *gin.Context, code int, message string) {
|
||||
c.Writer.Flush()
|
||||
}
|
||||
|
||||
// TestLLMConnection 测试 LLM 连接(询问模型身份并返回回答) // Logan.Li
|
||||
// llmConfigFromTestRequest 将测试请求转为运行时配置(脱敏 Key 回退已保存值) // Logan.Li
|
||||
func (h *LLMHandler) llmConfigFromTestRequest(req model.SaveLLMConfigRequest) (model.LLMConfig, string) {
|
||||
cfg := model.LLMConfig{
|
||||
Provider: req.Provider,
|
||||
Model: req.Model,
|
||||
APIKey: req.APIKey,
|
||||
Endpoint: req.Endpoint,
|
||||
Temperature: req.Temperature,
|
||||
MaxTokens: req.MaxTokens,
|
||||
ReasoningEnabled: req.ReasoningEnabled,
|
||||
}
|
||||
if cfg.Temperature == 0 {
|
||||
cfg.Temperature = 0.7
|
||||
}
|
||||
if cfg.MaxTokens == 0 {
|
||||
cfg.MaxTokens = 8192
|
||||
}
|
||||
if strings.Contains(req.APIKey, "****") {
|
||||
var saved model.LLMConfig
|
||||
if err := h.db.First(&saved).Error; err != nil {
|
||||
if !isLocalLLMProvider(req.Provider) {
|
||||
return cfg, "请填写 API Key"
|
||||
}
|
||||
} else {
|
||||
cfg.APIKey = saved.APIKey
|
||||
}
|
||||
}
|
||||
if cfg.Provider == "" {
|
||||
return cfg, "请选择提供商"
|
||||
}
|
||||
if cfg.Model == "" {
|
||||
return cfg, "请填写模型名"
|
||||
}
|
||||
if cfg.APIKey == "" && !isLocalLLMProvider(cfg.Provider) {
|
||||
return cfg, "请填写 API Key"
|
||||
}
|
||||
return cfg, ""
|
||||
}
|
||||
|
||||
// TestLLMConnection 测试 LLM 连接(支持草稿配置,保存前即可验证) // Logan.Li
|
||||
// POST /api/v1/aiops/llm-config/test
|
||||
func (h *LLMHandler) TestLLMConnection(c *gin.Context) {
|
||||
var req model.SaveLLMConfigRequest
|
||||
_ = c.ShouldBindJSON(&req) // 空 body 时回退已保存配置 // Logan.Li
|
||||
|
||||
var cfg model.LLMConfig
|
||||
if err := h.db.First(&cfg).Error; err != nil {
|
||||
c.JSON(http.StatusOK, model.Response{Code: 400, Message: "请先保存配置"})
|
||||
return
|
||||
var errMsg string
|
||||
if req.Provider != "" {
|
||||
cfg, errMsg = h.llmConfigFromTestRequest(req)
|
||||
} else {
|
||||
if err := h.db.First(&cfg).Error; err != nil {
|
||||
c.JSON(http.StatusOK, model.Response{Code: 400, Message: "请先填写配置并测试连接"})
|
||||
return
|
||||
}
|
||||
if cfg.APIKey == "" && !isLocalLLMProvider(cfg.Provider) {
|
||||
c.JSON(http.StatusOK, model.Response{Code: 400, Message: "请填写 API Key"})
|
||||
return
|
||||
}
|
||||
}
|
||||
if !cfg.Enabled {
|
||||
c.JSON(http.StatusOK, model.Response{Code: 400, Message: "请先启用 LLM 服务"})
|
||||
if errMsg != "" {
|
||||
c.JSON(http.StatusOK, model.Response{Code: 400, Message: errMsg})
|
||||
return
|
||||
}
|
||||
resp, err := buildLLMClientFromConfig(cfg).Complete(c.Request.Context(), &llm.CompletionRequest{
|
||||
@@ -196,10 +247,10 @@ func (h *LLMHandler) TestLLMConnection(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, model.Response{Code: 200, Message: "连接成功", Data: gin.H{
|
||||
"answer": resp.Message.Content,
|
||||
"model": resp.Model,
|
||||
"tokens_used": resp.Usage.TotalTokens,
|
||||
"provider": cfg.Provider,
|
||||
"answer": resp.Message.Content,
|
||||
"model": resp.Model,
|
||||
"tokens_used": resp.Usage.TotalTokens,
|
||||
"provider": cfg.Provider,
|
||||
"reasoning_enabled": cfg.ReasoningEnabled,
|
||||
}})
|
||||
}
|
||||
Reference in new issue
Block a user