Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Populate bucket_traffic_received_bytes_total metric (#7249)

Roman Shishkin83c1bfbacd5d
diff --git a/weed/s3api/s3api_object_handlers_put.go b/weed/s3api/s3api_object_handlers_put.go
index 2ce91e07c9..17fceb8d24 100644
--- a/weed/s3api/s3api_object_handlers_put.go
+++ b/weed/s3api/s3api_object_handlers_put.go
@@ -362,7 +362,7 @@ func (s3a *S3ApiServer) putToFiler(r *http.Request, uploadUrl string, dataReader
return "", filerErrorToS3Error(ret.Error), ""
}
- stats_collect.RecordBucketActiveTime(bucket)
+ BucketTrafficReceived(ret.Size, r)
// Return the SSE type determined by the unified handler
return etag, s3err.ErrNone, sseResult.SSEType
diff --git a/weed/s3api/stats.go b/weed/s3api/stats.go
index 973871bde9..14c0ad1501 100644
--- a/weed/s3api/stats.go
+++ b/weed/s3api/stats.go
@@ -37,6 +37,12 @@ func TimeToFirstByte(action string, start time.Time, r *http.Request) {
stats_collect.RecordBucketActiveTime(bucket)
}
+func BucketTrafficReceived(bytesReceived int64, r *http.Request) {
+ bucket, _ := s3_constants.GetBucketAndObject(r)
+ stats_collect.RecordBucketActiveTime(bucket)
+ stats_collect.S3BucketTrafficReceivedBytesCounter.WithLabelValues(bucket).Add(float64(bytesReceived))
+}
+
func BucketTrafficSent(bytesTransferred int64, r *http.Request) {
bucket, _ := s3_constants.GetBucketAndObject(r)
stats_collect.RecordBucketActiveTime(bucket)