update alerting ignore api

This commit is contained in:
liugq 2022-05-25 12:58:04 +08:00
parent 61f025be9f
commit 0438651474
1 changed files with 10 additions and 2 deletions

View File

@ -67,9 +67,17 @@ func (h *AlertAPI) ignoreAlertMessage(w http.ResponseWriter, req *http.Request,
log.Error(err)
return
}
//delete kv cache
//update kv cache
for _, msg := range body.Messages {
_ = kv.DeleteKey(alerting2.KVLastMessageState, []byte(msg.RuleID))
stateBytes, err := kv.GetValue(alerting2.KVLastMessageState, []byte(msg.RuleID))
if err != nil && stateBytes != nil {
message := &alerting.AlertMessage{}
util.MustFromJSONBytes(stateBytes, message)
if message.Status == alerting.MessageStateAlerting {
message.Status = alerting.MessageStateIgnored
}
kv.AddValue(alerting2.KVLastMessageState, []byte(msg.RuleID), util.MustToJSONBytes(message))
}
}