diff --git a/api/rest/client/client.go b/api/rest/client/client.go index bbe1ee9eb..e9cdded31 100644 --- a/api/rest/client/client.go +++ b/api/rest/client/client.go @@ -104,9 +104,9 @@ type Client interface { // serialized version, strings instead of pids, is returned GetConnectGraph() (api.ConnectGraphSerial, error) - // PeerMonitorLatestMetrics returns a map with the latest metrics of matching name + // Metrics returns a map with the latest metrics of matching name // for the current cluster peers. - PeerMonitorLatestMetrics(name string) ([]api.Metric, error) + Metrics(name string) ([]api.Metric, error) } // Config allows to configure the parameters to connect diff --git a/api/rest/client/methods.go b/api/rest/client/methods.go index ff45d8abc..882985748 100644 --- a/api/rest/client/methods.go +++ b/api/rest/client/methods.go @@ -204,11 +204,11 @@ func (c *defaultClient) GetConnectGraph() (api.ConnectGraphSerial, error) { return graphS, err } -// PeerMonitorLatestMetrics returns a map with the latest metrics of matching name +// Metrics returns a map with the latest metrics of matching name // for the current cluster peers. -func (c *defaultClient) PeerMonitorLatestMetrics(name string) ([]api.Metric, error) { +func (c *defaultClient) Metrics(name string) ([]api.Metric, error) { var metrics []api.Metric - err := c.do("GET", fmt.Sprintf("/health/metrics/%s", name), nil, nil, &metrics) + err := c.do("GET", fmt.Sprintf("/monitor/metrics/%s", name), nil, nil, &metrics) return metrics, err } diff --git a/api/rest/restapi.go b/api/rest/restapi.go index a64a05b48..972611d5a 100644 --- a/api/rest/restapi.go +++ b/api/rest/restapi.go @@ -383,9 +383,9 @@ func (api *API) routes() []route { api.graphHandler, }, { - "PeerMonitorLatestMetrics", + "Metrics", "GET", - "/health/metrics/{name}", + "/monitor/metrics/{name}", api.metricsHandler, }, } diff --git a/cmd/ipfs-cluster-ctl/formatters.go b/cmd/ipfs-cluster-ctl/formatters.go index 87cafff61..3d1497840 100644 --- a/cmd/ipfs-cluster-ctl/formatters.go +++ b/cmd/ipfs-cluster-ctl/formatters.go @@ -216,12 +216,7 @@ func textFormatPrintAddedOutput(obj *api.AddedOutput) { } func textFormatPrintMetric(obj *api.Metric) { - fmt.Printf("{\n") - fmt.Printf(" Peer: %s\n", (obj.Peer).String()) - fmt.Printf(" Value: %s\n", obj.Value) - fmt.Printf(" Expire: %d\n", obj.Expire) - fmt.Printf(" Expire: %t\n", obj.Valid) - fmt.Printf("}\n") + fmt.Printf("%s: %s | Expire : %d\n", obj.Peer.Pretty(), obj.Value, obj.Expire) } func textFormatPrintError(obj *api.Error) { diff --git a/cmd/ipfs-cluster-ctl/main.go b/cmd/ipfs-cluster-ctl/main.go index 58e1643f1..02ed42c3a 100644 --- a/cmd/ipfs-cluster-ctl/main.go +++ b/cmd/ipfs-cluster-ctl/main.go @@ -764,14 +764,14 @@ graph of the connections. Output is a dot file encoding the cluster's connectio }, { Name: "metrics", - Usage: "Get latest metrics of matching name for the current cluster peers.", + Usage: "List latest metrics logged by this peer", Description: ` -This command would show the peers and the last list of metrics logged for each as -returned by the Peer Monitor, in a friendly way. +This commands displays the latest valid metrics of the given type logged +by this peer for all current cluster peers. `, ArgsUsage: "Metric name", Action: func(c *cli.Context) error { - resp, cerr := globalClient.PeerMonitorLatestMetrics(c.Args().First()) + resp, cerr := globalClient.Metrics(c.Args().First()) formatResponse(c, resp, cerr) return nil },