From ca546bd503619914b7292018720b435f858bcfd3 Mon Sep 17 00:00:00 2001 From: liugq Date: Tue, 21 May 2024 16:09:07 +0800 Subject: [PATCH] fix: wrong alerting time range --- service/alerting/elasticsearch/engine.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/service/alerting/elasticsearch/engine.go b/service/alerting/elasticsearch/engine.go index 2ef65b1e..85afb49f 100644 --- a/service/alerting/elasticsearch/engine.go +++ b/service/alerting/elasticsearch/engine.go @@ -949,12 +949,10 @@ func newParameterCtx(rule *alerting.Rule, checkResults *alerting.ConditionResult max = checkResults.QueryResult.Max if v, ok := min.(int64); ok { //expand 60s - v = v - int64(time.Second * 60) - min = time.Unix(v/1000, v%1000 * 1e5).UTC().Format("2006-01-02T15:04:05.999Z") + min = time.UnixMilli(v).Add(-time.Second*60).UTC().Format("2006-01-02T15:04:05.999Z") } if v, ok := max.(int64); ok { - v = v + int64(time.Second * 60) - max = time.Unix(v/1000, v%1000 * 1e5).UTC().Format("2006-01-02T15:04:05.999Z") + max = time.UnixMilli(v).Add(time.Second*60).UTC().Format("2006-01-02T15:04:05.999Z") } } paramsCtx := util.MapStr{