add event_enabled field to recovery_notification_config

This commit is contained in:
liugq 2023-07-27 16:22:09 +08:00
parent 3f5beb7c9f
commit 1ce2639903
2 changed files with 4 additions and 2 deletions

View File

@ -83,11 +83,12 @@ type NotificationConfig struct {
}
type RecoveryNotificationConfig struct {
Enabled bool `json:"enabled"`
Enabled bool `json:"enabled"` // channel enabled
Title string `json:"title"` //text template
Message string `json:"message"` // text template
AcceptTimeRange TimeRange `json:"accept_time_range,omitempty"`
Normal []Channel `json:"normal,omitempty"`
EventEnabled bool `json:"event_enabled"`
}
type MessageTemplate struct{

View File

@ -676,9 +676,10 @@ func (engine *Engine) Do(rule *alerting.Rule) error {
if err != nil {
return fmt.Errorf("save alert message error: %w", err)
}
// todo add recover notification to inner system message
// send recover message to channel
recoverCfg := rule.RecoveryNotificationConfig
if recoverCfg != nil && recoverCfg.Enabled {
if recoverCfg != nil && recoverCfg.EventEnabled && recoverCfg.Enabled {
paramsCtx = newParameterCtx(rule, checkResults, util.MapStr{
alerting2.ParamEventID: alertItem.ID,
alerting2.ParamTimestamp: alertItem.Created.Unix(),