modify alert rule verify

This commit is contained in:
Ulric Qin 2022-05-31 13:08:09 +08:00
parent ece263ea45
commit ce35e23a0f
2 changed files with 3 additions and 3 deletions

View File

@ -230,7 +230,7 @@ CREATE TABLE `alert_rule` (
`algorithm` varchar(255) not null default '', `algorithm` varchar(255) not null default '',
`algo_params` varchar(255), `algo_params` varchar(255),
`delay` int not null default 0, `delay` int not null default 0,
`severity` tinyint(1) not null comment '0:Emergency 1:Warning 2:Notice', `severity` tinyint(1) not null comment '1:Emergency 2:Warning 3:Notice',
`disabled` tinyint(1) not null comment '0:enabled 1:disabled', `disabled` tinyint(1) not null comment '0:enabled 1:disabled',
`prom_for_duration` int not null comment 'prometheus for, unit:s', `prom_for_duration` int not null comment 'prometheus for, unit:s',
`prom_ql` varchar(8192) not null comment 'promql', `prom_ql` varchar(8192) not null comment 'promql',

View File

@ -24,7 +24,7 @@ type AlertRule struct {
AlgoParams string `json:"-" gorm:"algo_params"` // params algorithm need AlgoParams string `json:"-" gorm:"algo_params"` // params algorithm need
AlgoParamsJson interface{} `json:"algo_params" gorm:"-"` // AlgoParamsJson interface{} `json:"algo_params" gorm:"-"` //
Delay int `json:"delay"` // Time (in seconds) to delay evaluation Delay int `json:"delay"` // Time (in seconds) to delay evaluation
Severity int `json:"severity"` // 0: Emergency 1: Warning 2: Notice Severity int `json:"severity"` // 1: Emergency 2: Warning 3: Notice
Disabled int `json:"disabled"` // 0: enabled, 1: disabled Disabled int `json:"disabled"` // 0: enabled, 1: disabled
PromForDuration int `json:"prom_for_duration"` // prometheus for, unit:s PromForDuration int `json:"prom_for_duration"` // prometheus for, unit:s
PromQl string `json:"prom_ql"` // just one ql PromQl string `json:"prom_ql"` // just one ql
@ -58,7 +58,7 @@ func (ar *AlertRule) TableName() string {
} }
func (ar *AlertRule) Verify() error { func (ar *AlertRule) Verify() error {
if ar.GroupId <= 0 { if ar.GroupId < 0 {
return fmt.Errorf("GroupId(%d) invalid", ar.GroupId) return fmt.Errorf("GroupId(%d) invalid", ar.GroupId)
} }