From adf642581e684fbb5291cd687a588036e2d42943 Mon Sep 17 00:00:00 2001 From: liugq Date: Thu, 2 Nov 2023 11:37:20 +0800 Subject: [PATCH] add 60 seconds before and after the alert time (#213) Reviewed-on: https://git.infini.ltd/infini/console/pulls/213 Co-authored-by: liugq Co-committed-by: liugq --- service/alerting/elasticsearch/engine.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/service/alerting/elasticsearch/engine.go b/service/alerting/elasticsearch/engine.go index 65f1421b..2c00f658 100644 --- a/service/alerting/elasticsearch/engine.go +++ b/service/alerting/elasticsearch/engine.go @@ -946,9 +946,12 @@ func newParameterCtx(rule *alerting.Rule, checkResults *alerting.ConditionResult min = checkResults.QueryResult.Min 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") } 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") } }