diff --git a/agent/app/service/alert_helper.go b/agent/app/service/alert_helper.go index 62a5d6050f4b..9dcd08dc2bfe 100644 --- a/agent/app/service/alert_helper.go +++ b/agent/app/service/alert_helper.go @@ -580,7 +580,11 @@ func sendAlerts(alert dto.AlertDTO, alertType, quota, quotaType string, params [ AlertId: alert.ID, Count: todayCount + 1, } - _ = xpack.CreateSMSAlertLog(alertType, alert, create, quotaType, params, constant.SMS) + alertErr := xpack.CreateSMSAlertLog(alertType, alert, create, quotaType, params, constant.SMS) + if alertErr != nil { + global.LOG.Infof("%s alert sms push faild, err: %v", alertType, alertErr.Error()) + continue + } alertUtil.CreateNewAlertTask(quota, alertType, quotaType, constant.SMS) global.LOG.Infof("%s alert sms push successful", alertType) @@ -600,7 +604,11 @@ func sendAlerts(alert dto.AlertDTO, alertType, quota, quotaType string, params [ create.AlertDetail = alertUtil.ProcessAlertDetail(alertInfo, quotaType, params, constant.Email) transport := xpack.LoadRequestTransport() agentInfo, _ := xpack.GetAgentInfo() - _ = alertUtil.CreateEmailAlertLog(create, alertInfo, params, transport, agentInfo) + alertErr := alertUtil.CreateEmailAlertLog(create, alertInfo, params, transport, agentInfo) + if alertErr != nil { + global.LOG.Infof("%s alert email push faild, err: %v", alertType, alertErr.Error()) + continue + } alertUtil.CreateNewAlertTask(quota, alertType, quotaType, constant.Email) global.LOG.Infof("%s alert email push successful", alertType) } diff --git a/agent/utils/alert_push/alert_push.go b/agent/utils/alert_push/alert_push.go index 8ec4445f1c20..8ea04a9dce50 100644 --- a/agent/utils/alert_push/alert_push.go +++ b/agent/utils/alert_push/alert_push.go @@ -44,6 +44,7 @@ func PushAlert(pushAlert dto.PushAlert) error { } _ = xpack.CreateTaskScanSMSAlertLog(alert, alert.Type, create, pushAlert, constant.SMS) alertUtil.CreateNewAlertTask(strconv.Itoa(int(pushAlert.EntryID)), alertUtil.GetCronJobType(alert.Type), strconv.Itoa(int(pushAlert.EntryID)), constant.SMS) + global.LOG.Infof("%s %s alert push successful", alert.Type, constant.SMS) case constant.Email: todayCount, _, err := alertRepo.LoadTaskCount(alertUtil.GetCronJobType(alert.Type), strconv.Itoa(int(pushAlert.EntryID)), constant.Email) if err != nil || alert.SendCount <= todayCount { @@ -61,9 +62,9 @@ func PushAlert(pushAlert dto.PushAlert) error { return err } alertUtil.CreateNewAlertTask(strconv.Itoa(int(pushAlert.EntryID)), alertUtil.GetCronJobType(alert.Type), strconv.Itoa(int(pushAlert.EntryID)), constant.Email) + global.LOG.Infof("%s %s alert push successful", alert.Type, constant.Email) default: } } - global.LOG.Infof("%s alert push successful", alert.Type) return nil }