update alert api

This commit is contained in:
liugq 2022-04-20 10:35:17 +08:00
parent 147d394699
commit 97ba1c5fe1
3 changed files with 6 additions and 1 deletions

View File

@ -45,7 +45,7 @@ func (h *AlertAPI) getAlert(w http.ResponseWriter, req *http.Request, ps httprou
func (h *AlertAPI) acknowledgeAlert(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
body := struct {
AlertIDs []string `json:"alert_ids"`
AlertIDs []string `json:"ids"`
}{}
queryDsl := util.MapStr{
"query": util.MapStr{

View File

@ -29,6 +29,10 @@ func (alert *AlertAPI) Init() {
api.HandleAPIMethod(api.PUT, "/alerting/channel/:channel_id", alert.updateChannel)
api.HandleAPIMethod(api.GET, "/alerting/channel/_search", alert.searchChannel)
api.HandleAPIMethod(api.GET, "/alerting/alert/_search", alert.searchAlert)
api.HandleAPIMethod(api.GET, "/alerting/alert/:alert_id", alert.getAlert)
api.HandleAPIMethod(api.POST, "/alerting/alert/_acknowledge", alert.acknowledgeAlert)
//just for test
//api.HandleAPIMethod(api.GET, "/alerting/rule/test", alert.testRule)

View File

@ -583,6 +583,7 @@ func (engine *Engine) Do(rule *alerting.Rule) error {
//todo init last notification time when create task (by last alert item is notified)
rule.LastNotificationTime = time.Now()
alertItem.IsNotified = true
//kv.AddValue(alerting2.KVLastNotificationTime, []byte(rule.ID), []byte(rule.LastNotificationTime.Format(time.RFC3339)))
}
isAck, err := hasAcknowledgedRule(rule.ID, rule.LastTermStartTime)
if err != nil {