diff --git a/docker/initsql/a-n9e.sql b/docker/initsql/a-n9e.sql index 1fb76388..10b1080e 100644 --- a/docker/initsql/a-n9e.sql +++ b/docker/initsql/a-n9e.sql @@ -300,6 +300,7 @@ CREATE TABLE `alert_cur_event` ( `id` bigint unsigned not null comment 'use alert_his_event.id', `cluster` varchar(128) not null, `group_id` bigint unsigned not null comment 'busi group id of rule', + `group_name` varchar(255) not null default '' comment 'busi group name', `hash` varchar(64) not null comment 'rule_id + vector_pk', `rule_id` bigint unsigned not null, `rule_name` varchar(255) not null, @@ -331,6 +332,7 @@ CREATE TABLE `alert_his_event` ( `is_recovered` tinyint(1) not null, `cluster` varchar(128) not null, `group_id` bigint unsigned not null comment 'busi group id of rule', + `group_name` varchar(255) not null default '' comment 'busi group name', `hash` varchar(64) not null comment 'rule_id + vector_pk', `rule_id` bigint unsigned not null, `rule_name` varchar(255) not null, diff --git a/src/models/alert_cur_event.go b/src/models/alert_cur_event.go index 138d4bad..64dc47d8 100644 --- a/src/models/alert_cur_event.go +++ b/src/models/alert_cur_event.go @@ -9,8 +9,9 @@ import ( type AlertCurEvent struct { Id int64 `json:"id" gorm:"primaryKey"` Cluster string `json:"cluster"` - GroupId int64 `json:"group_id"` // busi group id - Hash string `json:"hash"` // rule_id + vector_key + GroupId int64 `json:"group_id"` // busi group id + GroupName string `json:"group_name"` // busi group name + Hash string `json:"hash"` // rule_id + vector_key RuleId int64 `json:"rule_id"` RuleName string `json:"rule_name"` RuleNote string `json:"rule_note"` @@ -65,6 +66,7 @@ func (e *AlertCurEvent) ToHis() *AlertHisEvent { IsRecovered: isRecovered, Cluster: e.Cluster, GroupId: e.GroupId, + GroupName: e.GroupName, Hash: e.Hash, RuleId: e.RuleId, RuleName: e.RuleName, diff --git a/src/models/alert_his_event.go b/src/models/alert_his_event.go index 037808cf..d6010700 100644 --- a/src/models/alert_his_event.go +++ b/src/models/alert_his_event.go @@ -10,6 +10,7 @@ type AlertHisEvent struct { IsRecovered int `json:"is_recovered"` Cluster string `json:"cluster"` GroupId int64 `json:"group_id"` + GroupName string `json:"group_name"` // busi group name Hash string `json:"hash"` RuleId int64 `json:"rule_id"` RuleName string `json:"rule_name"` diff --git a/src/server/engine/worker.go b/src/server/engine/worker.go index 2d3583fb..15fa5ab2 100644 --- a/src/server/engine/worker.go +++ b/src/server/engine/worker.go @@ -230,6 +230,11 @@ func (r RuleEval) judge(vectors []Vector) { GroupId: r.rule.GroupId, } + bg := memsto.BusiGroupCache.GetByBusiGroupId(r.rule.GroupId) + if bg != nil { + event.GroupName = bg.Name + } + // isMuted only need TriggerTime and TagsMap if isMuted(event) { logger.Infof("event_muted: rule_id=%d %s", r.rule.Id, vectors[i].Key)