diff --git a/alert/dispatch/dispatch.go b/alert/dispatch/dispatch.go index dae95447..2ee59e01 100644 --- a/alert/dispatch/dispatch.go +++ b/alert/dispatch/dispatch.go @@ -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 } diff --git a/models/alert_subscribe.go b/models/alert_subscribe.go index 0c6d6145..7fade29c 100644 --- a/models/alert_subscribe.go +++ b/models/alert_subscribe.go @@ -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