mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Use better host names for metric errors (#18188)
Typically hosts would end up like this: ``` "hosts": [ ":9000", ":9000", ":9000", ... ``` Also add host name to errors.
This commit is contained in:
parent
2b4531f069
commit
7cd08594f6
@ -20,7 +20,6 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/madmin-go/v3"
|
"github.com/minio/madmin-go/v3"
|
||||||
@ -42,18 +41,6 @@ func collectLocalMetrics(types madmin.MetricType, opts collectMetricsOpts) (m ma
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
byHostName := globalMinioAddr
|
|
||||||
if len(opts.hosts) > 0 {
|
|
||||||
server := getLocalServerProperty(globalEndpoints, &http.Request{
|
|
||||||
Host: globalLocalNodeName,
|
|
||||||
})
|
|
||||||
if _, ok := opts.hosts[server.Endpoint]; ok {
|
|
||||||
byHostName = server.Endpoint
|
|
||||||
} else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if types.Contains(madmin.MetricsDisk) {
|
if types.Contains(madmin.MetricsDisk) {
|
||||||
m.ByDisk = make(map[string]madmin.DiskMetric)
|
m.ByDisk = make(map[string]madmin.DiskMetric)
|
||||||
aggr := madmin.DiskMetric{
|
aggr := madmin.DiskMetric{
|
||||||
@ -87,7 +74,7 @@ func collectLocalMetrics(types madmin.MetricType, opts collectMetricsOpts) (m ma
|
|||||||
}
|
}
|
||||||
netStats, err := net.GetInterfaceNetStats(globalInternodeInterface)
|
netStats, err := net.GetInterfaceNetStats(globalInternodeInterface)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.Errors = append(m.Errors, err.Error())
|
m.Errors = append(m.Errors, fmt.Sprintf("%s: %v (nicstats)", globalMinioAddr, err.Error()))
|
||||||
} else {
|
} else {
|
||||||
m.Aggregated.Net.NetStats = netStats
|
m.Aggregated.Net.NetStats = netStats
|
||||||
}
|
}
|
||||||
@ -104,18 +91,18 @@ func collectLocalMetrics(types madmin.MetricType, opts collectMetricsOpts) (m ma
|
|||||||
}
|
}
|
||||||
cm, err := c.Times(false)
|
cm, err := c.Times(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.Errors = append(m.Errors, err.Error())
|
m.Errors = append(m.Errors, fmt.Sprintf("%s: %v (cputimes)", globalMinioAddr, err.Error()))
|
||||||
} else {
|
} else {
|
||||||
// not collecting per-cpu stats, so there will be only one element
|
// not collecting per-cpu stats, so there will be only one element
|
||||||
if len(cm) == 1 {
|
if len(cm) == 1 {
|
||||||
m.Aggregated.CPU.TimesStat = &cm[0]
|
m.Aggregated.CPU.TimesStat = &cm[0]
|
||||||
} else {
|
} else {
|
||||||
m.Errors = append(m.Errors, fmt.Sprintf("Expected one CPU stat, got %d", len(cm)))
|
m.Errors = append(m.Errors, fmt.Sprintf("%s: Expected one CPU stat, got %d", globalMinioAddr, len(cm)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadStat, err := load.Avg()
|
loadStat, err := load.Avg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.Errors = append(m.Errors, err.Error())
|
m.Errors = append(m.Errors, fmt.Sprintf("%s: %v (loadStat)", globalMinioAddr, err.Error()))
|
||||||
} else {
|
} else {
|
||||||
m.Aggregated.CPU.LoadStat = loadStat
|
m.Aggregated.CPU.LoadStat = loadStat
|
||||||
}
|
}
|
||||||
@ -123,8 +110,8 @@ func collectLocalMetrics(types madmin.MetricType, opts collectMetricsOpts) (m ma
|
|||||||
// Add types...
|
// Add types...
|
||||||
|
|
||||||
// ByHost is a shallow reference, so careful about sharing.
|
// ByHost is a shallow reference, so careful about sharing.
|
||||||
m.ByHost = map[string]madmin.Metrics{byHostName: m.Aggregated}
|
m.ByHost = map[string]madmin.Metrics{globalMinioAddr: m.Aggregated}
|
||||||
m.Hosts = append(m.Hosts, byHostName)
|
m.Hosts = append(m.Hosts, globalMinioAddr)
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
@ -777,7 +777,7 @@ func (sys *NotificationSys) GetMetrics(ctx context.Context, t madmin.MetricType,
|
|||||||
|
|
||||||
for index, err := range g.Wait() {
|
for index, err := range g.Wait() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reply[index].Errors = []string{err.Error()}
|
reply[index].Errors = []string{fmt.Sprintf("%s: %s (rpc)", sys.peerClients[index].String(), err.Error())}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return reply
|
return reply
|
||||||
|
Loading…
Reference in New Issue
Block a user