mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Change endpoint format for per-bucket metrics (#19655)
Per-bucket metrics endpoints always start with /bucket and the bucket name is appended to the path. e.g. if the collector path is /bucket/api, the endpoint for the bucket "mybucket" would be /minio/metrics/v3/bucket/api/mybucket Change the existing bucket api endpoint accordingly from /api/bucket to /bucket/api
This commit is contained in:
@@ -221,18 +221,15 @@ func (h *metricsV3Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
pathComponents := mux.Vars(r)["pathComps"]
|
||||
isListingRequest := r.Form.Has("list")
|
||||
|
||||
// Parse optional buckets query parameter.
|
||||
bucketsParam := r.Form["buckets"]
|
||||
buckets := make([]string, 0, len(bucketsParam))
|
||||
for _, bp := range bucketsParam {
|
||||
bp = strings.TrimSpace(bp)
|
||||
if bp == "" {
|
||||
continue
|
||||
}
|
||||
splits := strings.Split(bp, ",")
|
||||
for _, split := range splits {
|
||||
buckets = append(buckets, strings.TrimSpace(split))
|
||||
}
|
||||
buckets := []string{}
|
||||
if strings.HasPrefix(pathComponents, "/bucket/") {
|
||||
// bucket specific metrics, extract the bucket name from the path.
|
||||
// it's the last part of the path. e.g. /bucket/api/<bucket-name>
|
||||
bucketIdx := strings.LastIndex(pathComponents, "/")
|
||||
buckets = append(buckets, pathComponents[bucketIdx+1:])
|
||||
// remove bucket from pathComponents as it is dyanamic and
|
||||
// hence not included in the collector path.
|
||||
pathComponents = pathComponents[:bucketIdx]
|
||||
}
|
||||
|
||||
innerHandler := h.handle(pathComponents, isListingRequest, buckets)
|
||||
|
||||
@@ -29,9 +29,13 @@ import (
|
||||
//
|
||||
// These are paths under the top-level /minio/metrics/v3 metrics endpoint. Each
|
||||
// of these paths returns a set of V3 metrics.
|
||||
//
|
||||
// Per-bucket metrics endpoints always start with /bucket and the bucket name is
|
||||
// appended to the path. e.g. if the collector path is /bucket/api, the endpoint
|
||||
// for the bucket "mybucket" would be /minio/metrics/v3/bucket/api/mybucket
|
||||
const (
|
||||
apiRequestsCollectorPath collectorPath = "/api/requests"
|
||||
apiBucketCollectorPath collectorPath = "/api/bucket"
|
||||
apiBucketCollectorPath collectorPath = "/bucket/api"
|
||||
|
||||
systemNetworkInternodeCollectorPath collectorPath = "/system/network/internode"
|
||||
systemDriveCollectorPath collectorPath = "/system/drive"
|
||||
|
||||
Reference in New Issue
Block a user