Skip to content

Commit

Permalink
Issue ipfs-cluster#449 API endpoint for Peer Monitor metrics
Browse files Browse the repository at this point in the history
Opened new endpoint `GET /health/metrics/<name>` which would respond
with metrics of type <name>

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
  • Loading branch information
kishansagathiya committed Oct 21, 2018
1 parent b0b826d commit fafbf7b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api/rest/restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ func (api *API) routes() []route {
"/health/graph",
api.graphHandler,
},
{
"PeerMonitorLatestMetrics",
"GET",
"/health/metrics/{name}",
api.metricsHandler,
},
}
}

Expand Down Expand Up @@ -506,6 +512,19 @@ func (api *API) graphHandler(w http.ResponseWriter, r *http.Request) {
api.sendResponse(w, autoStatus, err, graph)
}

func (api *API) metricsHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
name := vars["name"]

var metrics []types.Metric
err := api.rpcClient.Call("",
"Cluster",
"PeerMonitorLatestMetrics",
name,
&metrics)
sendResponse(w, err, metrics)
}

func (api *API) addHandler(w http.ResponseWriter, r *http.Request) {
reader, err := r.MultipartReader()
if err != nil {
Expand Down

0 comments on commit fafbf7b

Please sign in to comment.