mirror of
https://github.com/minio/minio.git
synced 2025-04-19 02:05:24 -04:00
move per bucket metrics to peer location (#17627)
This commit is contained in:
parent
8522905d97
commit
5b7c83341b
@ -236,28 +236,28 @@ func (s *bucketConnStats) incS3OutputBytes(bucket string, n int64) {
|
|||||||
s.stats[bucket] = stats
|
s.stats[bucket] = stats
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return S3 total input bytes for input bucket
|
type inOutBytes struct {
|
||||||
func (s *bucketConnStats) getS3InputBytes(bucket string) uint64 {
|
In uint64
|
||||||
s.RLock()
|
Out uint64
|
||||||
defer s.RUnlock()
|
|
||||||
|
|
||||||
stats := s.stats[bucket]
|
|
||||||
if stats == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return stats.s3InputBytes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return S3 total output bytes
|
// Return S3 total input bytes for input bucket
|
||||||
func (s *bucketConnStats) getS3OutputBytes(bucket string) uint64 {
|
func (s *bucketConnStats) getS3InOutBytes() map[string]inOutBytes {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
|
|
||||||
stats := s.stats[bucket]
|
if len(s.stats) == 0 {
|
||||||
if stats == nil {
|
return nil
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
return stats.s3OutputBytes
|
|
||||||
|
bucketStats := make(map[string]inOutBytes, len(s.stats))
|
||||||
|
for k, v := range s.stats {
|
||||||
|
bucketStats[k] = inOutBytes{
|
||||||
|
In: v.s3InputBytes,
|
||||||
|
Out: v.s3OutputBytes,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bucketStats
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete metrics once bucket is deleted.
|
// delete metrics once bucket is deleted.
|
||||||
|
@ -1990,6 +1990,67 @@ func getHTTPMetrics() *MetricsGroup {
|
|||||||
VariableLabels: map[string]string{"api": api},
|
VariableLabels: map[string]string{"api": api},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for bucket, inOut := range globalBucketConnStats.getS3InOutBytes() {
|
||||||
|
recvBytes := inOut.In
|
||||||
|
if recvBytes > 0 {
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: getBucketTrafficReceivedBytes(),
|
||||||
|
Value: float64(recvBytes),
|
||||||
|
VariableLabels: map[string]string{"bucket": bucket},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
sentBytes := inOut.Out
|
||||||
|
if sentBytes > 0 {
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: getBucketTrafficSentBytes(),
|
||||||
|
Value: float64(sentBytes),
|
||||||
|
VariableLabels: map[string]string{"bucket": bucket},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
httpStats := globalBucketHTTPStats.load(bucket)
|
||||||
|
for k, v := range httpStats.currentS3Requests.Load() {
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: getBucketS3RequestsInFlightMD(),
|
||||||
|
Value: float64(v),
|
||||||
|
VariableLabels: map[string]string{"bucket": bucket, "api": k},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range httpStats.totalS3Requests.Load() {
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: getBucketS3RequestsTotalMD(),
|
||||||
|
Value: float64(v),
|
||||||
|
VariableLabels: map[string]string{"bucket": bucket, "api": k},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range httpStats.totalS3Canceled.Load() {
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: getBucketS3RequestsCanceledMD(),
|
||||||
|
Value: float64(v),
|
||||||
|
VariableLabels: map[string]string{"bucket": bucket, "api": k},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range httpStats.totalS34xxErrors.Load() {
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: getBucketS3Requests4xxErrorsMD(),
|
||||||
|
Value: float64(v),
|
||||||
|
VariableLabels: map[string]string{"bucket": bucket, "api": k},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range httpStats.totalS35xxErrors.Load() {
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: getBucketS3Requests5xxErrorsMD(),
|
||||||
|
Value: float64(v),
|
||||||
|
VariableLabels: map[string]string{"bucket": bucket, "api": k},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
return mg
|
return mg
|
||||||
@ -2104,65 +2165,6 @@ func getBucketUsageMetrics() *MetricsGroup {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
recvBytes := globalBucketConnStats.getS3InputBytes(bucket)
|
|
||||||
if recvBytes > 0 {
|
|
||||||
metrics = append(metrics, Metric{
|
|
||||||
Description: getBucketTrafficReceivedBytes(),
|
|
||||||
Value: float64(recvBytes),
|
|
||||||
VariableLabels: map[string]string{"bucket": bucket},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
sentBytes := globalBucketConnStats.getS3OutputBytes(bucket)
|
|
||||||
if sentBytes > 0 {
|
|
||||||
metrics = append(metrics, Metric{
|
|
||||||
Description: getBucketTrafficSentBytes(),
|
|
||||||
Value: float64(sentBytes),
|
|
||||||
VariableLabels: map[string]string{"bucket": bucket},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
httpStats := globalBucketHTTPStats.load(bucket)
|
|
||||||
for k, v := range httpStats.currentS3Requests.Load() {
|
|
||||||
metrics = append(metrics, Metric{
|
|
||||||
Description: getBucketS3RequestsInFlightMD(),
|
|
||||||
Value: float64(v),
|
|
||||||
VariableLabels: map[string]string{"bucket": bucket, "api": k},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v := range httpStats.totalS3Requests.Load() {
|
|
||||||
metrics = append(metrics, Metric{
|
|
||||||
Description: getBucketS3RequestsTotalMD(),
|
|
||||||
Value: float64(v),
|
|
||||||
VariableLabels: map[string]string{"bucket": bucket, "api": k},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v := range httpStats.totalS3Canceled.Load() {
|
|
||||||
metrics = append(metrics, Metric{
|
|
||||||
Description: getBucketS3RequestsCanceledMD(),
|
|
||||||
Value: float64(v),
|
|
||||||
VariableLabels: map[string]string{"bucket": bucket, "api": k},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v := range httpStats.totalS34xxErrors.Load() {
|
|
||||||
metrics = append(metrics, Metric{
|
|
||||||
Description: getBucketS3Requests4xxErrorsMD(),
|
|
||||||
Value: float64(v),
|
|
||||||
VariableLabels: map[string]string{"bucket": bucket, "api": k},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v := range httpStats.totalS35xxErrors.Load() {
|
|
||||||
metrics = append(metrics, Metric{
|
|
||||||
Description: getBucketS3Requests5xxErrorsMD(),
|
|
||||||
Value: float64(v),
|
|
||||||
VariableLabels: map[string]string{"bucket": bucket, "api": k},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if stats.hasReplicationUsage() {
|
if stats.hasReplicationUsage() {
|
||||||
for arn, stat := range stats.Stats {
|
for arn, stat := range stats.Stats {
|
||||||
metrics = append(metrics, Metric{
|
metrics = append(metrics, Metric{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user