From 5c6cfb02618370d415c56c108102830a6e6eb6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E9=B8=BF=E9=A3=9E?= Date: Wed, 2 Aug 2023 17:37:27 +0800 Subject: [PATCH] fix(monitor): fix montior alert startTimeFormat --- pkg/monitor/alerting/eval_context.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/monitor/alerting/eval_context.go b/pkg/monitor/alerting/eval_context.go index f4bc980400..5e475b1055 100644 --- a/pkg/monitor/alerting/eval_context.go +++ b/pkg/monitor/alerting/eval_context.go @@ -27,6 +27,7 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" + "yunion.io/x/onecloud/pkg/monitor/options" ) // EvalContext is the context object for an alert evaluation. @@ -204,13 +205,14 @@ func (c *EvalContext) GetNotificationTemplateConfig() monitor.NotificationTempla } desc += "Error: " + c.Error.Error() } + tz, _ := time.LoadLocation(options.Options.TimeZone) return monitor.NotificationTemplateConfig{ Title: c.GetNotificationTitle(), Name: c.Rule.Name, ResourceName: c.GetResourceNameOfMathes(nil), Matches: c.GetEvalMatches(), - StartTime: c.StartTime.Format("2006-01-02 15:04:05"), - EndTime: c.EndTime.Format("2006-01-02 15:04:05"), + StartTime: c.StartTime.In(tz).Format("2006-01-02 15:04:05"), + EndTime: c.EndTime.In(tz).Format("2006-01-02 15:04:05"), Description: desc, Level: c.Rule.Level, NoDataFound: c.NoDataFound,