forked from minio/madmin-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetrics-api.go
More file actions
59 lines (46 loc) · 1.51 KB
/
Copy pathmetrics-api.go
File metadata and controls
59 lines (46 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package madmin
import (
"context"
"encoding/json"
"net/http"
"time"
)
// ClusterAPIStats is a simplified version of madmin.APIStats that is used to
// report cluster-wide API metrics.
type ClusterAPIStats struct {
// Time these metrics were collected
CollectedAt time.Time `json:"collected"`
// Nodes responded to the request.
Nodes int `json:"nodes"`
// Errors will contain any errors encountered while collecting the metrics.
Errors []string `json:"errors,omitempty"`
// Number of active requests.
ActiveRequests int64 `json:"activeRequests,omitempty"`
// Number of queued requests.
QueuedRequests int64 `json:"queuedRequests,omitempty"`
// lastMinute is the combined stats for the last minute.
LastMinute APIStats `json:"lastMinute"`
// LastDay is the combined stats for the last day.
LastDay APIStats `json:"lastDay"`
// LastDaySegmented are the stats for the last day, accumulated in time segments.
LastDaySegmented SegmentedAPIMetrics `json:"lastDaySegmented"`
}
// ClusterAPIStats makes an admin call to retrieve general API metrics.
func (adm *AdminClient) ClusterAPIStats(ctx context.Context) (res *ClusterAPIStats, err error) {
path := adminAPIPrefix + "/api/stats"
resp, err := adm.executeMethod(ctx,
http.MethodGet, requestData{
relPath: path,
},
)
if err != nil {
return nil, err
}
defer closeResponse(resp)
if resp.StatusCode != http.StatusOK {
return nil, httpRespToErrorResponse(resp)
}
res = &ClusterAPIStats{}
err = json.NewDecoder(resp.Body).Decode(res)
return res, err
}