mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #12671 from zhaoxiangchun/bugfix/zxc-monitor
fix(monitor): 告警历史问题修复
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -537,5 +537,4 @@ func (manager *SAlertResourceManager) sendWebsocketInfo(uids []string, alertReso
|
||||
log.Errorf("websocket send info err:%v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}*/
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user