From 896e0889ecc1b35f874464ea7a316bfd14491069 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Mon, 11 Nov 2024 16:09:35 +0800 Subject: [PATCH] fix(monitor): add metric content for email template (#21568) --- .../notify_templates/monitor/content@cn/DEFAULT.email | 4 +++- .../notify_templates/monitor/content@en/DEFAULT.email | 4 +++- pkg/monitor/alerting/notifiers/onecloud.go | 9 +++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build/monitor/root/opt/yunion/share/notify_templates/monitor/content@cn/DEFAULT.email b/build/monitor/root/opt/yunion/share/notify_templates/monitor/content@cn/DEFAULT.email index 35127eeb08..a05f63231e 100644 --- a/build/monitor/root/opt/yunion/share/notify_templates/monitor/content@cn/DEFAULT.email +++ b/build/monitor/root/opt/yunion/share/notify_templates/monitor/content@cn/DEFAULT.email @@ -108,6 +108,7 @@ 名称 IP 平台 + 指标 触发值 @@ -124,7 +125,8 @@ {{ index .tags "brand" }} - {{$Matche.value_str}} + {{ $Matche.metric }} + {{ $Matche.value_str }} {{end}} diff --git a/build/monitor/root/opt/yunion/share/notify_templates/monitor/content@en/DEFAULT.email b/build/monitor/root/opt/yunion/share/notify_templates/monitor/content@en/DEFAULT.email index 2906601ab9..251bb773d9 100644 --- a/build/monitor/root/opt/yunion/share/notify_templates/monitor/content@en/DEFAULT.email +++ b/build/monitor/root/opt/yunion/share/notify_templates/monitor/content@en/DEFAULT.email @@ -108,6 +108,7 @@ Name IP Brand + Metric Trigger value @@ -124,7 +125,8 @@ {{ index .tags "brand" }} - {{$Matche.value_str}} + {{ $Matche.metric }} + {{ $Matche.value_str }} {{end}} diff --git a/pkg/monitor/alerting/notifiers/onecloud.go b/pkg/monitor/alerting/notifiers/onecloud.go index 0386434dd0..7c745ff587 100644 --- a/pkg/monitor/alerting/notifiers/onecloud.go +++ b/pkg/monitor/alerting/notifiers/onecloud.go @@ -471,7 +471,8 @@ func (s *sendUserImpl) send() error { } func (s *sendUserImpl) execNotifyFunc() error { - return notifyclient.NotifyAllWithoutRobotWithCtx(s.Ctx, s.msg.Uid, false, notify.TNotifyPriority(s.msg.Priority), + return notifyclient.NotifyAllWithoutRobotWithCtx( + s.Ctx, s.msg.Uid, false, s.msg.Priority, "DEFAULT", jsonutils.Marshal(&s.config)) } @@ -484,7 +485,7 @@ func (s *sendSysImpl) send() error { } func (s *sendSysImpl) execNotifyFunc() error { - notifyclient.SystemNotifyWithCtx(s.Ctx, notify.TNotifyPriority(s.msg.Priority), "DEFAULT", + notifyclient.SystemNotifyWithCtx(s.Ctx, s.msg.Priority, "DEFAULT", jsonutils.Marshal(&s.config)) return nil } @@ -499,7 +500,7 @@ func (s *sendMobileImpl) send() error { return err } notifyclient.RawNotifyWithCtx(s.Ctx, s.msg.Uid, false, notify.TNotifyChannel(s.Setting.Channel), - notify.TNotifyPriority(s.msg.Priority), + s.msg.Priority, s.msg.Topic, msgObj) return nil @@ -514,7 +515,7 @@ func (s *sendRobotImpl) send() error { } func (s *sendRobotImpl) execNotifyFunc() error { - return notifyclient.NotifyRobotWithCtx(s.Ctx, s.msg.Robots, notify.TNotifyPriority(s.msg.Priority), + return notifyclient.NotifyRobotWithCtx(s.Ctx, s.msg.Robots, s.msg.Priority, "DEFAULT", jsonutils.Marshal(&s.config)) }