diff --git a/docker/initsql/a-n9e.sql b/docker/initsql/a-n9e.sql index c0cc8020..6661835a 100644 --- a/docker/initsql/a-n9e.sql +++ b/docker/initsql/a-n9e.sql @@ -345,6 +345,7 @@ CREATE TABLE `alert_his_event` ( `trigger_time` bigint not null, `trigger_value` varchar(255) not null, `recover_time` bigint not null default 0, + `last_eval_time` bigint not null default 0 comment 'for time filter', `tags` varchar(1024) not null default '' comment 'merge data_tags rule_tags, split by ,,', PRIMARY KEY (`id`), KEY (`hash`), diff --git a/src/models/alert_cur_event.go b/src/models/alert_cur_event.go index ffb10692..26c7f1f3 100644 --- a/src/models/alert_cur_event.go +++ b/src/models/alert_cur_event.go @@ -83,6 +83,7 @@ func (e *AlertCurEvent) ToHis() *AlertHisEvent { TriggerValue: e.TriggerValue, Tags: e.Tags, RecoverTime: recoverTime, + LastEvalTime: e.LastEvalTime, } } @@ -192,7 +193,7 @@ func AlertCurEventGets(bgid, stime, etime int64, severity int, clusters []string } var lst []AlertCurEvent - err := session.Order("trigger_time desc").Limit(limit).Offset(offset).Find(&lst).Error + err := session.Order("id desc").Limit(limit).Offset(offset).Find(&lst).Error if err == nil { for i := 0; i < len(lst); i++ { diff --git a/src/models/alert_his_event.go b/src/models/alert_his_event.go index 507c1a5c..e64a433b 100644 --- a/src/models/alert_his_event.go +++ b/src/models/alert_his_event.go @@ -32,6 +32,7 @@ type AlertHisEvent struct { TriggerTime int64 `json:"trigger_time"` TriggerValue string `json:"trigger_value"` RecoverTime int64 `json:"recover_time"` + LastEvalTime int64 `json:"last_eval_time"` Tags string `json:"-"` TagsJSON []string `json:"tags" gorm:"-"` } @@ -135,7 +136,7 @@ func AlertHisEventGets(bgid, stime, etime int64, severity int, recovered int, cl } var lst []AlertHisEvent - err := session.Order("trigger_time desc").Limit(limit).Offset(offset).Find(&lst).Error + err := session.Order("id desc").Limit(limit).Offset(offset).Find(&lst).Error if err == nil { for i := 0; i < len(lst); i++ {