From 9cb54a338135375e87820a939689fe32b61d56c7 Mon Sep 17 00:00:00 2001 From: silenceqi Date: Fri, 13 Dec 2024 15:12:24 +0800 Subject: [PATCH] chore: adapter node metrics query with `cluster_id ` or `cluster uuid` (#28) --- modules/elastic/api/cluster_overview.go | 20 +++++++++++++++++--- modules/elastic/api/node_metrics.go | 20 +++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/modules/elastic/api/cluster_overview.go b/modules/elastic/api/cluster_overview.go index cca784ff..39979af3 100644 --- a/modules/elastic/api/cluster_overview.go +++ b/modules/elastic/api/cluster_overview.go @@ -566,9 +566,23 @@ func (h *APIHandler) GetClusterNodes(w http.ResponseWriter, req *http.Request, p }, }, { - "term": util.MapStr{ - "metadata.labels.cluster_uuid": util.MapStr{ - "value": clusterUUID, + "bool": util.MapStr{ + "minimum_should_match": 1, + "should": []util.MapStr{ + { + "term": util.MapStr{ + "metadata.labels.cluster_id": util.MapStr{ + "value": id, + }, + }, + }, + { + "term": util.MapStr{ + "metadata.labels.cluster_uuid": util.MapStr{ + "value": clusterUUID, + }, + }, + }, }, }, }, diff --git a/modules/elastic/api/node_metrics.go b/modules/elastic/api/node_metrics.go index f3ddc425..d42d3cf2 100644 --- a/modules/elastic/api/node_metrics.go +++ b/modules/elastic/api/node_metrics.go @@ -117,9 +117,23 @@ func (h *APIHandler) getNodeMetrics(ctx context.Context, clusterID string, bucke var must = []util.MapStr{ { - "term":util.MapStr{ - "metadata.labels.cluster_uuid":util.MapStr{ - "value": clusterUUID, + "bool": util.MapStr{ + "minimum_should_match": 1, + "should": []util.MapStr{ + { + "term": util.MapStr{ + "metadata.labels.cluster_id": util.MapStr{ + "value": clusterID, + }, + }, + }, + { + "term": util.MapStr{ + "metadata.labels.cluster_uuid": util.MapStr{ + "value": clusterUUID, + }, + }, + }, }, }, },