mirror of
https://github.com/minio/minio.git
synced 2025-04-23 11:55:47 -04:00
fix: gateway_s3_bytes_sent metric for all API methods (#9242)
Co-authored-by: Harshavardhana <harsha@minio.io>
This commit is contained in:
parent
95e89f1712
commit
336460f67e
@ -432,7 +432,7 @@ type MetricsTransport struct {
|
|||||||
// RoundTrip implements the RoundTrip method for MetricsTransport
|
// RoundTrip implements the RoundTrip method for MetricsTransport
|
||||||
func (m MetricsTransport) RoundTrip(r *http.Request) (*http.Response, error) {
|
func (m MetricsTransport) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||||
metered := shouldMeterRequest(r)
|
metered := shouldMeterRequest(r)
|
||||||
if metered && (r.Method == http.MethodGet || r.Method == http.MethodHead) {
|
if metered && (r.Method == http.MethodPost || r.Method == http.MethodPut) {
|
||||||
m.Metrics.IncRequests(r.Method)
|
m.Metrics.IncRequests(r.Method)
|
||||||
if r.ContentLength > 0 {
|
if r.ContentLength > 0 {
|
||||||
m.Metrics.IncBytesSent(uint64(r.ContentLength))
|
m.Metrics.IncBytesSent(uint64(r.ContentLength))
|
||||||
@ -444,7 +444,8 @@ func (m MetricsTransport) RoundTrip(r *http.Request) (*http.Response, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if metered && (r.Method == http.MethodGet || r.Method == http.MethodHead) {
|
if metered && (r.Method == http.MethodGet || r.Method == http.MethodHead) {
|
||||||
if r.ContentLength > 0 {
|
m.Metrics.IncRequests(r.Method)
|
||||||
|
if resp.ContentLength > 0 {
|
||||||
m.Metrics.IncBytesReceived(uint64(resp.ContentLength))
|
m.Metrics.IncBytesReceived(uint64(resp.ContentLength))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ import (
|
|||||||
type RequestStats struct {
|
type RequestStats struct {
|
||||||
Get atomic.Uint64 `json:"Get"`
|
Get atomic.Uint64 `json:"Get"`
|
||||||
Head atomic.Uint64 `json:"Head"`
|
Head atomic.Uint64 `json:"Head"`
|
||||||
|
Put atomic.Uint64 `json:"Put"`
|
||||||
|
Post atomic.Uint64 `json:"Post"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metrics - represents bytes served from backend
|
// Metrics - represents bytes served from backend
|
||||||
@ -63,6 +65,10 @@ func (s *Metrics) IncRequests(method string) {
|
|||||||
s.requestStats.Get.Add(1)
|
s.requestStats.Get.Add(1)
|
||||||
} else if method == http.MethodHead {
|
} else if method == http.MethodHead {
|
||||||
s.requestStats.Head.Add(1)
|
s.requestStats.Head.Add(1)
|
||||||
|
} else if method == http.MethodPut {
|
||||||
|
s.requestStats.Put.Add(1)
|
||||||
|
} else if method == http.MethodPost {
|
||||||
|
s.requestStats.Post.Add(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +203,24 @@ func gatewayMetricsPrometheus(ch chan<- prometheus.Metric) {
|
|||||||
float64(s.Head.Load()),
|
float64(s.Head.Load()),
|
||||||
http.MethodHead,
|
http.MethodHead,
|
||||||
)
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName("gateway", globalGatewayName, "requests"),
|
||||||
|
"Total number of requests made to "+globalGatewayName+" by current MinIO Gateway",
|
||||||
|
[]string{"method"}, nil),
|
||||||
|
prometheus.CounterValue,
|
||||||
|
float64(s.Put.Load()),
|
||||||
|
http.MethodPut,
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName("gateway", globalGatewayName, "requests"),
|
||||||
|
"Total number of requests made to "+globalGatewayName+" by current MinIO Gateway",
|
||||||
|
[]string{"method"}, nil),
|
||||||
|
prometheus.CounterValue,
|
||||||
|
float64(s.Post.Load()),
|
||||||
|
http.MethodPost,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// collects cache metrics for MinIO server in Prometheus specific format
|
// collects cache metrics for MinIO server in Prometheus specific format
|
||||||
|
@ -151,8 +151,8 @@ MinIO Gateway instances enabled with Disk-Caching expose caching related metrics
|
|||||||
|
|
||||||
MinIO Gateway instance exposes metrics related to Gateway communication with the cloud backend (S3, Azure & GCS Gateway).
|
MinIO Gateway instance exposes metrics related to Gateway communication with the cloud backend (S3, Azure & GCS Gateway).
|
||||||
|
|
||||||
- `gateway_<gateway_type>_requests`: Total number of GET & HEAD requests made to cloud backend. This metrics has a label `method` that identifies GET & HEAD Requests.
|
- `gateway_<gateway_type>_requests`: Total number of requests made to cloud backend. This metrics has a label `method` that identifies GET, HEAD, PUT and POST Requests.
|
||||||
- `gateway_<gateway_type>_bytes_sent`: Total number of bytes sent to cloud backend (in GET & HEAD Requests).
|
- `gateway_<gateway_type>_bytes_sent`: Total number of bytes sent to cloud backend (in PUT & POST Requests).
|
||||||
- `gateway_<gateway_type>_bytes_received`: Total number of bytes received from cloud backend (in GET & HEAD Requests).
|
- `gateway_<gateway_type>_bytes_received`: Total number of bytes received from cloud backend (in GET & HEAD Requests).
|
||||||
|
|
||||||
Note that this is currently only support for Azure, S3 and GCS Gateway.
|
Note that this is currently only support for Azure, S3 and GCS Gateway.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user