Skip to content

Commit a5816f1

Browse files
authored
fix: Fix alert log issues (#11637)
1 parent 95a613f commit a5816f1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

agent/app/service/alert_helper.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,11 @@ func sendAlerts(alert dto.AlertDTO, alertType, quota, quotaType string, params [
580580
AlertId: alert.ID,
581581
Count: todayCount + 1,
582582
}
583-
_ = xpack.CreateSMSAlertLog(alertType, alert, create, quotaType, params, constant.SMS)
583+
alertErr := xpack.CreateSMSAlertLog(alertType, alert, create, quotaType, params, constant.SMS)
584+
if alertErr != nil {
585+
global.LOG.Infof("%s alert sms push faild, err: %v", alertType, alertErr.Error())
586+
continue
587+
}
584588
alertUtil.CreateNewAlertTask(quota, alertType, quotaType, constant.SMS)
585589
global.LOG.Infof("%s alert sms push successful", alertType)
586590

@@ -600,7 +604,11 @@ func sendAlerts(alert dto.AlertDTO, alertType, quota, quotaType string, params [
600604
create.AlertDetail = alertUtil.ProcessAlertDetail(alertInfo, quotaType, params, constant.Email)
601605
transport := xpack.LoadRequestTransport()
602606
agentInfo, _ := xpack.GetAgentInfo()
603-
_ = alertUtil.CreateEmailAlertLog(create, alertInfo, params, transport, agentInfo)
607+
alertErr := alertUtil.CreateEmailAlertLog(create, alertInfo, params, transport, agentInfo)
608+
if alertErr != nil {
609+
global.LOG.Infof("%s alert email push faild, err: %v", alertType, alertErr.Error())
610+
continue
611+
}
604612
alertUtil.CreateNewAlertTask(quota, alertType, quotaType, constant.Email)
605613
global.LOG.Infof("%s alert email push successful", alertType)
606614
}

agent/utils/alert_push/alert_push.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func PushAlert(pushAlert dto.PushAlert) error {
4444
}
4545
_ = xpack.CreateTaskScanSMSAlertLog(alert, alert.Type, create, pushAlert, constant.SMS)
4646
alertUtil.CreateNewAlertTask(strconv.Itoa(int(pushAlert.EntryID)), alertUtil.GetCronJobType(alert.Type), strconv.Itoa(int(pushAlert.EntryID)), constant.SMS)
47+
global.LOG.Infof("%s %s alert push successful", alert.Type, constant.SMS)
4748
case constant.Email:
4849
todayCount, _, err := alertRepo.LoadTaskCount(alertUtil.GetCronJobType(alert.Type), strconv.Itoa(int(pushAlert.EntryID)), constant.Email)
4950
if err != nil || alert.SendCount <= todayCount {
@@ -61,9 +62,9 @@ func PushAlert(pushAlert dto.PushAlert) error {
6162
return err
6263
}
6364
alertUtil.CreateNewAlertTask(strconv.Itoa(int(pushAlert.EntryID)), alertUtil.GetCronJobType(alert.Type), strconv.Itoa(int(pushAlert.EntryID)), constant.Email)
65+
global.LOG.Infof("%s %s alert push successful", alert.Type, constant.Email)
6466
default:
6567
}
6668
}
67-
global.LOG.Infof("%s alert push successful", alert.Type)
6869
return nil
6970
}

0 commit comments

Comments
 (0)