modify sql: add group_name for event

This commit is contained in:
Ulric Qin 2022-03-21 17:35:10 +08:00
parent f4388d36de
commit d45fdd50e7
4 changed files with 12 additions and 2 deletions

View File

@ -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,

View File

@ -10,6 +10,7 @@ type AlertCurEvent struct {
Id int64 `json:"id" gorm:"primaryKey"`
Cluster string `json:"cluster"`
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"`
@ -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,

View File

@ -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"`

View File

@ -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)