diff --git a/cmd/metrics-realtime.go b/cmd/metrics-realtime.go index 2b413cd7a..2538487df 100644 --- a/cmd/metrics-realtime.go +++ b/cmd/metrics-realtime.go @@ -19,6 +19,7 @@ package cmd import ( "context" + "net/http" "time" "github.com/minio/madmin-go/v3" @@ -38,8 +39,14 @@ func collectLocalMetrics(types madmin.MetricType, opts collectMetricsOpts) (m ma return } + byHostName := globalMinioAddr if len(opts.hosts) > 0 { - if _, ok := opts.hosts[globalMinioAddr]; !ok { + server := getLocalServerProperty(globalEndpoints, &http.Request{ + Host: globalLocalNodeName, + }) + if _, ok := opts.hosts[server.Endpoint]; ok { + byHostName = server.Endpoint + } else { return } } @@ -85,8 +92,8 @@ func collectLocalMetrics(types madmin.MetricType, opts collectMetricsOpts) (m ma // Add types... // ByHost is a shallow reference, so careful about sharing. - m.ByHost = map[string]madmin.Metrics{globalMinioAddr: m.Aggregated} - m.Hosts = append(m.Hosts, globalMinioAddr) + m.ByHost = map[string]madmin.Metrics{byHostName: m.Aggregated} + m.Hosts = append(m.Hosts, byHostName) return m } diff --git a/cmd/peer-rest-client.go b/cmd/peer-rest-client.go index 8edf47526..83423bf80 100644 --- a/cmd/peer-rest-client.go +++ b/cmd/peer-rest-client.go @@ -214,6 +214,9 @@ func (client *peerRESTClient) GetMetrics(ctx context.Context, t madmin.MetricTyp for disk := range opts.disks { values.Set(peerRESTDisk, disk) } + for host := range opts.hosts { + values.Add(peerRESTHost, host) + } values.Set(peerRESTJobID, opts.jobID) values.Set(peerRESTDepID, opts.depID) diff --git a/cmd/peer-rest-common.go b/cmd/peer-rest-common.go index 23d3d728b..25a9e4272 100644 --- a/cmd/peer-rest-common.go +++ b/cmd/peer-rest-common.go @@ -99,6 +99,7 @@ const ( peerRESTStorageClass = "storage-class" peerRESTMetricsTypes = "types" peerRESTDisk = "disk" + peerRESTHost = "host" peerRESTJobID = "job-id" peerRESTDepID = "depID" peerRESTStartRebalance = "start-rebalance" diff --git a/cmd/peer-rest-server.go b/cmd/peer-rest-server.go index 5e866aec3..96be14ca6 100644 --- a/cmd/peer-rest-server.go +++ b/cmd/peer-rest-server.go @@ -453,6 +453,12 @@ func (s *peerRESTServer) GetMetricsHandler(w http.ResponseWriter, r *http.Reques for _, disk := range r.Form[peerRESTDisk] { diskMap[disk] = struct{}{} } + + hostMap := make(map[string]struct{}) + for _, host := range r.Form[peerRESTHost] { + hostMap[host] = struct{}{} + } + jobID := r.Form.Get(peerRESTJobID) depID := r.Form.Get(peerRESTDepID) @@ -461,6 +467,7 @@ func (s *peerRESTServer) GetMetricsHandler(w http.ResponseWriter, r *http.Reques info := collectLocalMetrics(types, collectMetricsOpts{ disks: diskMap, + hosts: hostMap, jobID: jobID, depID: depID, })