fix: 修复Agent指标时区查询
- 统一Agent报告存储与查询的UTC时间边界 - 修复监控大屏、历史图表及离线判断取不到最新数据 - 增加UTC与UTC+8场景回归测试
This commit is contained in:
1 parent
d9106dde6e
commit
7bc416d22a
6 files changed
+83
-9
No files matched your search
@@ -167,9 +167,9 @@ func (h *AgentTaskHandler) QuickSetupRules(c *gin.Context) {
|
||||
Pluck("hostname", &onlineHosts)
|
||||
|
||||
if len(onlineHosts) == 0 {
|
||||
// 如果没有在线主机,尝试从 agent_reports 中获取最近 3 分钟活跃的主机名
|
||||
// 如果没有在线主机,使用 UTC 边界从 Agent 报告中查找最近 3 分钟活跃主机。 // Logan.Li
|
||||
h.db.Model(&model.AgentReport{}).
|
||||
Where("report_time >= ?", time.Now().Add(-3*time.Minute)).
|
||||
Where("report_time >= ?", time.Now().UTC().Add(-3*time.Minute)).
|
||||
Distinct("hostname").
|
||||
Pluck("hostname", &onlineHosts)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user