diff --git a/plugin/api/alerting/alert.go b/plugin/api/alerting/alert.go index 63195d3a..908635ed 100644 --- a/plugin/api/alerting/alert.go +++ b/plugin/api/alerting/alert.go @@ -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{ diff --git a/plugin/api/alerting/api.go b/plugin/api/alerting/api.go index d09ddcb4..a7dedcf1 100644 --- a/plugin/api/alerting/api.go +++ b/plugin/api/alerting/api.go @@ -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) diff --git a/service/alerting/elasticsearch/engine.go b/service/alerting/elasticsearch/engine.go index b7ccde98..bdeebcf2 100644 --- a/service/alerting/elasticsearch/engine.go +++ b/service/alerting/elasticsearch/engine.go @@ -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 {