diff --git a/pkg/monitor/alerting/conditions/nodataquery.go b/pkg/monitor/alerting/conditions/nodataquery.go index ee607e4220..96c0996c64 100644 --- a/pkg/monitor/alerting/conditions/nodataquery.go +++ b/pkg/monitor/alerting/conditions/nodataquery.go @@ -209,11 +209,10 @@ func (c *NoDataQueryCondition) NewNoDataEvalMatch(context *alerting.EvalContext, queryKeyInfo = evalMatch.Metric } evalMatch.Unit = alertDetails.FieldDescription.Unit - msg := fmt.Sprintf("%s.%s %s %s", alertDetails.Measurement, alertDetails.Field, - alertDetails.Comparator, alerting.RationalizeValueFromUnit(alertDetails.Threshold, evalMatch.Unit, "")) - if len(context.Rule.Message) == 0 { - context.Rule.Message = msg - } + msg := fmt.Sprintf("%s.%s %s ", alertDetails.Measurement, alertDetails.Field, + alertDetails.Comparator) + context.Rule.Message = msg + //evalMatch.Condition = c.GenerateFormatCond(meta, queryKeyInfo).String() evalMatch.ValueStr = NO_DATA return evalMatch, nil diff --git a/pkg/monitor/alerting/notifiers/onecloud.go b/pkg/monitor/alerting/notifiers/onecloud.go index 02683a28a3..849a336e3a 100644 --- a/pkg/monitor/alerting/notifiers/onecloud.go +++ b/pkg/monitor/alerting/notifiers/onecloud.go @@ -336,7 +336,7 @@ type sendnotifyBase struct { } func (s *sendnotifyBase) send() error { - notifyclient.RawNotifyWithCtx(s.Ctx, s.Setting.UserIds, false, notify.TNotifyChannel(s.Setting.Channel), + notifyclient.RawNotifyWithCtx(s.Ctx, s.msg.Uid, false, notify.TNotifyChannel(s.Setting.Channel), notify.TNotifyPriority(s.msg.Priority), "DEFAULT", jsonutils.Marshal(&s.config)) @@ -349,7 +349,7 @@ type sendUserImpl struct { } func (s *sendUserImpl) send() error { - return notifyclient.NotifyAllWithoutRobotWithCtx(s.Ctx, s.Setting.UserIds, false, notify.TNotifyPriority(s.msg.Priority), + return notifyclient.NotifyAllWithoutRobotWithCtx(s.Ctx, s.msg.Uid, false, notify.TNotifyPriority(s.msg.Priority), "DEFAULT", jsonutils.Marshal(&s.config)) } diff --git a/pkg/monitor/models/commonalert.go b/pkg/monitor/models/commonalert.go index 223580f93c..f19b46ce5f 100644 --- a/pkg/monitor/models/commonalert.go +++ b/pkg/monitor/models/commonalert.go @@ -103,9 +103,10 @@ func (man *SCommonAlertManager) ValidateCreateData( } if len(data.Channel) == 0 { data.Channel = []string{monitor.DEFAULT_SEND_NOTIFY_CHANNEL} - } else { - data.Channel = append(data.Channel, monitor.DEFAULT_SEND_NOTIFY_CHANNEL) } + //else { + // data.Channel = append(data.Channel, monitor.DEFAULT_SEND_NOTIFY_CHANNEL) + //} if !utils.IsInStringArray(data.Level, monitor.CommonAlertLevels) { return data, httperrors.NewInputParameterError("Invalid level format: %s", data.Level) } @@ -738,16 +739,16 @@ func (alert *SCommonAlert) ValidateUpdateData( data.Set("frequency", jsonutils.NewInt(freqSpec)) } } - if recipients, _ := data.GetArray("recipients"); len(recipients) > 0 { - channelStr, _ := data.GetString("channel") - channel, _ := data.GetArray("channel") - if !strings.Contains(channelStr, monitor.DEFAULT_SEND_NOTIFY_CHANNEL) { - channels := jsonutils.NewArray() - channels.Add(channel...) - channels.Add(jsonutils.NewString(monitor.DEFAULT_SEND_NOTIFY_CHANNEL)) - data.Set("channel", channels) - } - } + //if recipients, _ := data.GetArray("recipients"); len(recipients) > 0 { + // channelStr, _ := data.GetString("channel") + // channel, _ := data.GetArray("channel") + // if !strings.Contains(channelStr, monitor.DEFAULT_SEND_NOTIFY_CHANNEL) { + // channels := jsonutils.NewArray() + // channels.Add(channel...) + // channels.Add(jsonutils.NewString(monitor.DEFAULT_SEND_NOTIFY_CHANNEL)) + // data.Set("channel", channels) + // } + //} tmp := jsonutils.NewArray() if metric_query, _ := data.GetArray("metric_query"); len(metric_query) > 0 { for i := range metric_query {