From 634e70c971f2c4112a5b1d0ac6da468ce3655cfb Mon Sep 17 00:00:00 2001 From: liugq Date: Thu, 2 Jun 2022 21:19:53 +0800 Subject: [PATCH] change alert message statistic only by alerting state --- plugin/api/alerting/message.go | 4 ++-- plugin/api/init.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin/api/alerting/message.go b/plugin/api/alerting/message.go index 50386caf..eee5e1be 100644 --- a/plugin/api/alerting/message.go +++ b/plugin/api/alerting/message.go @@ -85,11 +85,11 @@ func (h *AlertAPI) getAlertMessageStats(w http.ResponseWriter, req *http.Request "size": 0, "query": util.MapStr{ "bool": util.MapStr{ - "must_not": []util.MapStr{ + "must": []util.MapStr{ { "terms": util.MapStr{ "status": []string{ - alerting.MessageStateRecovered, + alerting.MessageStateAlerting, }, }, }, diff --git a/plugin/api/init.go b/plugin/api/init.go index 1c5368d5..fec22f23 100644 --- a/plugin/api/init.go +++ b/plugin/api/init.go @@ -26,9 +26,9 @@ func Init(cfg *config.AppConfig) { api.HandleAPIMethod(api.PUT, path.Join(pathPrefix, "dict/:id"), handler.UpdateDictItemAction) api.HandleAPIMethod(api.POST, path.Join(esPrefix, "doc/:index/_search"), handler.HandleSearchDocumentAction) - api.HandleAPIMethod(api.POST, path.Join(esPrefix, "doc/:index"),handler.HandleAddDocumentAction) - api.HandleAPIMethod(api.PUT, path.Join(esPrefix, "doc/:index/:docId"), handler.HandleUpdateDocumentAction) - api.HandleAPIMethod(api.DELETE, path.Join(esPrefix, "doc/:index/:docId"), handler.HandleDeleteDocumentAction) + api.HandleAPIMethod(api.POST, path.Join(esPrefix, "doc/:index"), handler.ClusterRequired(handler.HandleAddDocumentAction, "doc.create")) + api.HandleAPIMethod(api.PUT, path.Join(esPrefix, "doc/:index/:docId"), handler.ClusterRequired(handler.HandleUpdateDocumentAction, "doc.update")) + api.HandleAPIMethod(api.DELETE, path.Join(esPrefix, "doc/:index/:docId"), handler.ClusterRequired(handler.HandleDeleteDocumentAction, "doc.delete")) api.HandleAPIMethod(api.GET, path.Join(esPrefix, "doc/_validate"), handler.ValidateDocIDAction) api.HandleAPIMethod(api.POST, path.Join(pathPrefix, "rebuild/*id"), handler.HandleReindexAction)