提交 0e88f007 编写于 作者: U Ulric Qin

add recover_time

上级 2bfc6768
...@@ -318,6 +318,7 @@ CREATE TABLE `alert_his_event` ( ...@@ -318,6 +318,7 @@ CREATE TABLE `alert_his_event` (
`target_note` varchar(191) not null default '' comment 'target note', `target_note` varchar(191) not null default '' comment 'target note',
`trigger_time` bigint not null, `trigger_time` bigint not null,
`trigger_value` varchar(255) not null, `trigger_value` varchar(255) not null,
`recover_time` bigint not null default 0,
`tags` varchar(1024) not null default '' comment 'merge data_tags rule_tags, split by ,,', `tags` varchar(1024) not null default '' comment 'merge data_tags rule_tags, split by ,,',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY (`hash`), KEY (`hash`),
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
规则名称: {{.RuleName}}{{if .RuleNote}} 规则名称: {{.RuleName}}{{if .RuleNote}}
规则备注: {{.RuleNote}}{{end}} 规则备注: {{.RuleNote}}{{end}}
监控指标: {{.TagsJSON}} 监控指标: {{.TagsJSON}}
触发时间: {{timeformat .TriggerTime}} {{if .IsRecovered}}恢复时间:{{timeformat .LastEvalTime}}{{else}}触发时间: {{timeformat .TriggerTime}}
触发时值: {{.TriggerValue}} 触发时值: {{.TriggerValue}}{{end}}
\ No newline at end of file \ No newline at end of file
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
规则名称: {{.RuleName}}{{if .RuleNote}} 规则名称: {{.RuleName}}{{if .RuleNote}}
规则备注: {{.RuleNote}}{{end}} 规则备注: {{.RuleNote}}{{end}}
监控指标: {{.TagsJSON}} 监控指标: {{.TagsJSON}}
触发时间: {{timeformat .TriggerTime}} {{if .IsRecovered}}恢复时间:{{timeformat .LastEvalTime}}{{else}}触发时间: {{timeformat .TriggerTime}}
触发时值: {{.TriggerValue}} 触发时值: {{.TriggerValue}}{{end}}
\ No newline at end of file \ No newline at end of file
...@@ -162,6 +162,13 @@ ...@@ -162,6 +162,13 @@
<th>监控指标:</th> <th>监控指标:</th>
<td>{{.TagsJSON}}</td> <td>{{.TagsJSON}}</td>
</tr> </tr>
{{if .IsRecovered}}
<tr>
<th>恢复时间:</th>
<td>{{timeformat .LastEvalTime}}</td>
</tr>
{{else}}
<tr> <tr>
<th>触发时值:</th> <th>触发时值:</th>
<td>{{.TriggerValue}}</td> <td>{{.TriggerValue}}</td>
...@@ -172,6 +179,8 @@ ...@@ -172,6 +179,8 @@
{{timeformat .TriggerTime}} {{timeformat .TriggerTime}}
</td> </td>
</tr> </tr>
{{end}}
<tr> <tr>
<th>PromQL:</th> <th>PromQL:</th>
<td> <td>
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
**规则标题**: {{.RuleName}}{{if .RuleNote}} **规则标题**: {{.RuleName}}{{if .RuleNote}}
**规则备注**: {{.RuleNote}}{{end}} **规则备注**: {{.RuleNote}}{{end}}
**监控指标**: {{.TagsJSON}} **监控指标**: {{.TagsJSON}}
**触发时间**: {{timeformat .TriggerTime}} {{if .IsRecovered}}**恢复时间**:{{timeformat .LastEvalTime}}{{else}}**触发时间**: {{timeformat .TriggerTime}}
**触发时值**: {{.TriggerValue}} **触发时值**: {{.TriggerValue}}{{end}}
\ No newline at end of file \ No newline at end of file
...@@ -37,7 +37,7 @@ type AlertCurEvent struct { ...@@ -37,7 +37,7 @@ type AlertCurEvent struct {
TagsMap map[string]string `json:"-" gorm:"-"` // for internal usage TagsMap map[string]string `json:"-" gorm:"-"` // for internal usage
IsRecovered bool `json:"is_recovered" gorm:"-"` // for notify.py IsRecovered bool `json:"is_recovered" gorm:"-"` // for notify.py
NotifyUsersObj []*User `json:"notify_users_obj" gorm:"-"` // for notify.py NotifyUsersObj []*User `json:"notify_users_obj" gorm:"-"` // for notify.py
LastEvalTime int64 `json:"last_eval_time" gorm:"-"` // for internal usage LastEvalTime int64 `json:"last_eval_time" gorm:"-"` // for notify.py
} }
func (e *AlertCurEvent) TableName() string { func (e *AlertCurEvent) TableName() string {
...@@ -80,6 +80,7 @@ func (e *AlertCurEvent) ToHis() *AlertHisEvent { ...@@ -80,6 +80,7 @@ func (e *AlertCurEvent) ToHis() *AlertHisEvent {
TriggerTime: e.TriggerTime, TriggerTime: e.TriggerTime,
TriggerValue: e.TriggerValue, TriggerValue: e.TriggerValue,
Tags: e.Tags, Tags: e.Tags,
RecoverTime: e.LastEvalTime,
} }
} }
......
...@@ -31,6 +31,7 @@ type AlertHisEvent struct { ...@@ -31,6 +31,7 @@ type AlertHisEvent struct {
TargetNote string `json:"target_note"` TargetNote string `json:"target_note"`
TriggerTime int64 `json:"trigger_time"` TriggerTime int64 `json:"trigger_time"`
TriggerValue string `json:"trigger_value"` TriggerValue string `json:"trigger_value"`
RecoverTime int64 `json:"recover_time"`
Tags string `json:"-"` Tags string `json:"-"`
TagsJSON []string `json:"tags" gorm:"-"` TagsJSON []string `json:"tags" gorm:"-"`
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册