Merge pull request #12671 from zhaoxiangchun/bugfix/zxc-monitor

fix(monitor): 告警历史问题修复
This commit is contained in:
Zexi Li
2021-11-15 18:25:12 +08:00
committed by GitHub
4 changed files with 15 additions and 3 deletions
+1
View File
@@ -340,6 +340,7 @@ func (record *SAlertRecord) PostCreate(ctx context.Context, userCred mcclient.To
log.Errorf("Reconcile from alert record error: %v", err)
return
}
// err = GetAlertResourceManager().NotifyAlertResourceCount(ctx)
// if err != nil {
// log.Errorf("NotifyAlertResourceCount error: %v", err)
+1 -2
View File
@@ -537,5 +537,4 @@ func (manager *SAlertResourceManager) sendWebsocketInfo(uids []string, alertReso
log.Errorf("websocket send info err:%v", err)
}
}
}
*/
}*/
+5
View File
@@ -1346,6 +1346,11 @@ jointLoop:
continue jointLoop
}
}
// 排除近期有报警状态的情况:system.uptime
if joint.AlertState == monitor.MONITOR_RESOURCE_ALERT_STATUS_ALERTING && time.Now().Sub(joint.TriggerTime).
Minutes() < 30 {
continue
}
deleteJointIds = append(deleteJointIds, joint.RowId)
}
if len(resourceIds) == 0 {
+8 -1
View File
@@ -299,7 +299,7 @@ func (self *SMonitorResource) RealDelete(ctx context.Context, userCred mcclient.
if err != nil {
return err
}
return self.SVirtualResourceBase.Delete(ctx, userCred)
return self.SVirtualResourceBase.Delete(ctx, nil)
}
func (self *SMonitorResource) DetachJoint(ctx context.Context, userCred mcclient.TokenCredential) error {
@@ -433,6 +433,13 @@ func (self *SMonitorResource) UpdateAttachJoint(alertRecord *SAlertRecord, match
return errors.Wrapf(err, "SMonitorResource:%s UpdateAttachJoint err", self.Name)
}
errs := make([]error, 0)
// 报警时发现没有进行关联,增加attach
if len(joints) == 0 {
self.AttachAlert(context.Background(), nil, alertRecord.AlertId)
joints, _ = MonitorResourceAlertManager.GetJoinsByListInput(monitor.
MonitorResourceJointListInput{MonitorResourceId: self.
ResId, AlertId: alertRecord.AlertId})
}
for _, joint := range joints {
err := joint.UpdateAlertRecordData(alertRecord, &match)
if err != nil {