filter message stats api

This commit is contained in:
liugq 2022-06-05 17:30:29 +08:00
parent bd1e982e61
commit 7b26184469
1 changed files with 18 additions and 9 deletions

View File

@ -81,11 +81,7 @@ func (h *AlertAPI) ignoreAlertMessage(w http.ResponseWriter, req *http.Request,
func (h *AlertAPI) getAlertMessageStats(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
esClient := elastic.GetClient(h.Config.Elasticsearch)
queryDsl := util.MapStr{
"size": 0,
"query": util.MapStr{
"bool": util.MapStr{
"must": []util.MapStr{
must := []util.MapStr{
{
"terms": util.MapStr{
"status": []string{
@ -93,7 +89,20 @@ func (h *AlertAPI) getAlertMessageStats(w http.ResponseWriter, req *http.Request
},
},
},
},
}
clusterFilter, hasAllPrivilege := h.GetClusterFilter(req, "resource_id")
if !hasAllPrivilege && clusterFilter == nil {
h.WriteJSON(w, elastic.SearchResponse{}, http.StatusOK)
return
}
if !hasAllPrivilege {
must = append(must,clusterFilter)
}
queryDsl := util.MapStr{
"size": 0,
"query": util.MapStr{
"bool": util.MapStr{
"must": must,
},
},
"aggs": util.MapStr{