移除无用代码
This commit is contained in:
1 parent
00b01c7ad9
commit
9489c7b552
3 files changed
-56
No files matched your search
@@ -193,7 +193,6 @@ func setupApi(app *orz.App, components *AppComponents) {
|
||||
publicApiWithOptionalAuth.GET("/monitors/:id/stats", components.MonitorHandler.GetStatsByID)
|
||||
publicApiWithOptionalAuth.GET("/monitors/:id/agents", components.MonitorHandler.GetAgentStatsByID)
|
||||
publicApiWithOptionalAuth.GET("/monitors/:id/history", components.MonitorHandler.GetHistoryByID)
|
||||
publicApiWithOptionalAuth.GET("/monitors/:id", components.MonitorHandler.GetDetail) // 整合版接口
|
||||
|
||||
// Logo(公开访问)- 用于公共页面只获取 Logo
|
||||
publicApiWithOptionalAuth.GET("/logo", components.PropertyHandler.GetLogo)
|
||||
|
||||
@@ -160,24 +160,6 @@ func (h *MonitorHandler) GetStatsByID(c echo.Context) error {
|
||||
return orz.Ok(c, stats)
|
||||
}
|
||||
|
||||
// GetDetail 获取监控详情(整合版,公开接口,已登录返回全部,未登录返回公开可见)
|
||||
func (h *MonitorHandler) GetDetail(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
ctx := c.Request().Context()
|
||||
|
||||
// 验证监控任务访问权限
|
||||
if _, err := h.monitorService.GetMonitorByAuth(ctx, id, utils.IsAuthenticated(c)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
detail, err := h.monitorService.GetMonitorDetail(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return orz.Ok(c, detail)
|
||||
}
|
||||
|
||||
// GetAgentStatsByID 获取指定监控任务各探针的统计数据(公开接口,已登录返回全部,未登录返回公开可见)
|
||||
func (h *MonitorHandler) GetAgentStatsByID(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
|
||||
@@ -404,43 +404,6 @@ func (s *MonitorService) GetMonitorStatsByID(ctx context.Context, monitorID stri
|
||||
return &overview, nil
|
||||
}
|
||||
|
||||
// GetMonitorDetail 获取监控详情(整合stats和agents)
|
||||
func (s *MonitorService) GetMonitorDetail(ctx context.Context, monitorID string) (*metric.MonitorDetailResponse, error) {
|
||||
// 查询监控任务
|
||||
monitor, err := s.MonitorRepo.FindById(ctx, monitorID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 查询聚合统计
|
||||
stats := s.metricService.GetMonitorStats(monitorID)
|
||||
|
||||
// 查询各探针数据
|
||||
agents := s.metricService.GetMonitorAgentStats(monitorID)
|
||||
|
||||
// 根据 ShowTargetPublic 字段决定是否返回真实的 Target
|
||||
target := monitor.Target
|
||||
if !monitor.ShowTargetPublic {
|
||||
target = "******"
|
||||
}
|
||||
|
||||
// 构建响应
|
||||
detail := &metric.MonitorDetailResponse{
|
||||
ID: monitor.ID,
|
||||
Name: monitor.Name,
|
||||
Type: monitor.Type,
|
||||
Target: target,
|
||||
ShowTargetPublic: monitor.ShowTargetPublic,
|
||||
Description: monitor.Description,
|
||||
Enabled: monitor.Enabled,
|
||||
Interval: monitor.Interval,
|
||||
Stats: stats,
|
||||
Agents: agents,
|
||||
}
|
||||
|
||||
return detail, nil
|
||||
}
|
||||
|
||||
// GetMonitorHistory 获取监控任务的历史时序数据
|
||||
// 直接返回 VictoriaMetrics 的原始时序数据,包含所有探针的独立序列
|
||||
// 支持时间范围:15m, 30m, 1h, 3h, 6h, 12h, 1d, 3d, 7d
|
||||
|
||||
Reference in new issue
Block a user