🪄mutelabel生成
This commit is contained in:
		
							parent
							
								
									e5704157e3
								
							
						
					
					
						commit
						b444a94a06
					
				@ -165,8 +165,8 @@ func checkStatus() {
 | 
				
			|||||||
					go SendTriggerTasks(alert.FailTriggerTasks, curServer.ID)
 | 
										go SendTriggerTasks(alert.FailTriggerTasks, curServer.ID)
 | 
				
			||||||
					go SendNotification(alert.NotificationTag, message, NotificationMuteLabel.ServerIncident(server.ID, alert.ID), &curServer)
 | 
										go SendNotification(alert.NotificationTag, message, NotificationMuteLabel.ServerIncident(server.ID, alert.ID), &curServer)
 | 
				
			||||||
					// 清除恢复通知的静音缓存
 | 
										// 清除恢复通知的静音缓存
 | 
				
			||||||
					resolvedMuteLabel := fmt.Sprintf("%s:%s", *NotificationMuteLabel.ServerIncidentResolved(server.ID, alert.ID), alert.NotificationTag)
 | 
										resolvedMuteLabel := NotificationMuteLabel.AppendNotificationTag(NotificationMuteLabel.ServerIncidentResolved(server.ID, alert.ID), alert.NotificationTag)
 | 
				
			||||||
					Cache.Delete(resolvedMuteLabel)
 | 
										Cache.Delete(*resolvedMuteLabel)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				// 本次通过检查但上一次的状态为失败,则发送恢复通知
 | 
									// 本次通过检查但上一次的状态为失败,则发送恢复通知
 | 
				
			||||||
@ -177,8 +177,8 @@ func checkStatus() {
 | 
				
			|||||||
					go SendTriggerTasks(alert.RecoverTriggerTasks, curServer.ID)
 | 
										go SendTriggerTasks(alert.RecoverTriggerTasks, curServer.ID)
 | 
				
			||||||
					go SendNotification(alert.NotificationTag, message, NotificationMuteLabel.ServerIncidentResolved(server.ID, alert.ID), &curServer)
 | 
										go SendNotification(alert.NotificationTag, message, NotificationMuteLabel.ServerIncidentResolved(server.ID, alert.ID), &curServer)
 | 
				
			||||||
					// 清除失败通知的静音缓存
 | 
										// 清除失败通知的静音缓存
 | 
				
			||||||
					incidentMuteLabel := fmt.Sprintf("%s:%s", *NotificationMuteLabel.ServerIncident(server.ID, alert.ID), alert.NotificationTag)
 | 
										incidentMuteLabel := NotificationMuteLabel.AppendNotificationTag(NotificationMuteLabel.ServerIncident(server.ID, alert.ID), alert.NotificationTag)
 | 
				
			||||||
					Cache.Delete(incidentMuteLabel)
 | 
										Cache.Delete(*incidentMuteLabel)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				alertsPrevState[alert.ID][server.ID] = _RuleCheckPass
 | 
									alertsPrevState[alert.ID][server.ID] = _RuleCheckPass
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
				
			|||||||
@ -106,7 +106,7 @@ func OnDeleteNotification(id uint64) {
 | 
				
			|||||||
func SendNotification(notificationTag string, desc string, muteLabel *string, ext ...*model.Server) {
 | 
					func SendNotification(notificationTag string, desc string, muteLabel *string, ext ...*model.Server) {
 | 
				
			||||||
	if muteLabel != nil {
 | 
						if muteLabel != nil {
 | 
				
			||||||
		// 将通知方式组名称加入静音标志
 | 
							// 将通知方式组名称加入静音标志
 | 
				
			||||||
		muteLabel := fmt.Sprintf("%s:%s", *muteLabel, notificationTag)
 | 
							muteLabel := *NotificationMuteLabel.AppendNotificationTag(muteLabel, notificationTag)
 | 
				
			||||||
		// 通知防骚扰策略
 | 
							// 通知防骚扰策略
 | 
				
			||||||
		var flag bool
 | 
							var flag bool
 | 
				
			||||||
		if cacheN, has := Cache.Get(muteLabel); has {
 | 
							if cacheN, has := Cache.Get(muteLabel); has {
 | 
				
			||||||
@ -179,6 +179,11 @@ func (_NotificationMuteLabel) ServerIncidentResolved(alertId uint64, serverId ui
 | 
				
			|||||||
	return &label
 | 
						return &label
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (_NotificationMuteLabel) AppendNotificationTag(label *string, notificationTag string) *string {
 | 
				
			||||||
 | 
						newLabel := fmt.Sprintf("%s:%s", *label, notificationTag)
 | 
				
			||||||
 | 
						return &newLabel
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (_NotificationMuteLabel) ServiceLatencyMin(serviceId uint64) *string {
 | 
					func (_NotificationMuteLabel) ServiceLatencyMin(serviceId uint64) *string {
 | 
				
			||||||
	label := fmt.Sprintf("bf::sln-%d", serviceId)
 | 
						label := fmt.Sprintf("bf::sln-%d", serviceId)
 | 
				
			||||||
	return &label
 | 
						return &label
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user