add table column: last_eval_time in alert_his_event

This commit is contained in:
Ulric Qin 2021-12-11 18:07:01 +08:00
parent d4c4257517
commit 7f0877bf28
3 changed files with 5 additions and 2 deletions

View File

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

View File

@ -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++ {

View File

@ -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++ {