add 60 seconds before and after the alert time (#213)

Reviewed-on: https://git.infini.ltd/infini/console/pulls/213
Co-authored-by: liugq <silenceqi@hotmail.com>
Co-committed-by: liugq <silenceqi@hotmail.com>
This commit is contained in:
liugq 2023-11-02 11:37:20 +08:00 committed by medcl
parent 57bf0976f1
commit adf642581e
1 changed files with 3 additions and 0 deletions

View File

@ -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")
}
}