fix wrong template variable message with sending test rule message
This commit is contained in:
parent
f22c5cb380
commit
bc27aafd7e
|
@ -941,11 +941,24 @@ func (engine *Engine) Test(rule *alerting.Rule, msgType string) ([]alerting.Acti
|
||||||
alerting2.ParamEventID: util.GetUUID(),
|
alerting2.ParamEventID: util.GetUUID(),
|
||||||
alerting2.ParamTimestamp: time.Now().Unix(),
|
alerting2.ParamTimestamp: time.Now().Unix(),
|
||||||
} )
|
} )
|
||||||
title, message := rule.GetNotificationTitleAndMessage()
|
if msgType == "escalation" || msgType == "notification" {
|
||||||
err = attachTitleMessageToCtx(title, message, paramsCtx)
|
title, message := rule.GetNotificationTitleAndMessage()
|
||||||
if err != nil {
|
err = attachTitleMessageToCtx(title, message, paramsCtx)
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}else if msgType == "recover_notification" {
|
||||||
|
if rule.RecoveryNotificationConfig == nil {
|
||||||
|
return nil, fmt.Errorf("recovery notification must not be empty")
|
||||||
|
}
|
||||||
|
err = attachTitleMessageToCtx(rule.RecoveryNotificationConfig.Title, rule.RecoveryNotificationConfig.Message, paramsCtx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return nil, fmt.Errorf("unkonwn parameter msg type")
|
||||||
}
|
}
|
||||||
|
|
||||||
var channels []alerting.Channel
|
var channels []alerting.Channel
|
||||||
switch msgType {
|
switch msgType {
|
||||||
case "escalation":
|
case "escalation":
|
||||||
|
|
Loading…
Reference in New Issue