Browse Source

fix: sub rule filter

main
ning 2 years ago
parent
commit
f1ee7d24a6
2 changed files with 14 additions and 1 deletions
  1. +10
    -1
      alert/dispatch/dispatch.go
  2. +4
    -0
      models/alert_subscribe.go

+ 10
- 1
alert/dispatch/dispatch.go View File

@@ -170,9 +170,18 @@ func (e *Dispatch) handleSubs(event *models.AlertCurEvent) {

// handleSub 处理订阅规则的event,注意这里event要使用值传递,因为后面会修改event的状态
func (e *Dispatch) handleSub(sub *models.AlertSubscribe, event models.AlertCurEvent) {
if sub.IsDisabled() || !sub.MatchCluster(event.DatasourceId) {
if sub.IsDisabled() {
return
}

if !sub.MatchCluster(event.DatasourceId) {
return
}

if !sub.MatchProd(event.RuleProd) {
return
}

if !common.MatchTags(event.TagsMap, sub.ITags) {
return
}


+ 4
- 0
models/alert_subscribe.go View File

@@ -336,6 +336,10 @@ func AlertSubscribeGetsAll(ctx *ctx.Context) ([]*AlertSubscribe, error) {
return lst, err
}

func (s *AlertSubscribe) MatchProd(prod string) bool {
return s.Prod == prod
}

func (s *AlertSubscribe) MatchCluster(dsId int64) bool {
// 没有配置数据源, 或者事件不需要关联数据源
// do not match any datasource or event not related to datasource


Loading…
Cancel
Save