diff options
| author | Hadi Zamani <130847170+hadizamani021@users.noreply.github.com> | 2025-01-26 09:25:06 +0330 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-25 21:55:06 -0800 |
| commit | a2330f624b8f44776857c4d0c1ab8d05fb866759 (patch) | |
| tree | d7eb70a788a4e9fa0a153777d815488ed2da2554 | |
| parent | be15fee8e7a4623afca02933f6ed8092994e1dae (diff) | |
| download | seaweedfs-a2330f624b8f44776857c4d0c1ab8d05fb866759.tar.xz seaweedfs-a2330f624b8f44776857c4d0c1ab8d05fb866759.zip | |
Add metrics for uploaded and deleted s3 objects (#6475)
| -rw-r--r-- | weed/s3api/s3api_object_handlers_delete.go | 3 | ||||
| -rw-r--r-- | weed/s3api/s3api_object_handlers_multipart.go | 3 | ||||
| -rw-r--r-- | weed/s3api/s3api_object_handlers_put.go | 1 | ||||
| -rw-r--r-- | weed/stats/metrics.go | 18 |
4 files changed, 24 insertions, 1 deletions
diff --git a/weed/s3api/s3api_object_handlers_delete.go b/weed/s3api/s3api_object_handlers_delete.go index 045fe1a14..def589de8 100644 --- a/weed/s3api/s3api_object_handlers_delete.go +++ b/weed/s3api/s3api_object_handlers_delete.go @@ -15,6 +15,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + stats_collect "github.com/seaweedfs/seaweedfs/weed/stats" "github.com/seaweedfs/seaweedfs/weed/util" ) @@ -56,6 +57,7 @@ func (s3a *S3ApiServer) DeleteObjectHandler(w http.ResponseWriter, r *http.Reque return } + stats_collect.S3DeletedObjectsCounter.WithLabelValues(bucket).Inc() w.WriteHeader(http.StatusNoContent) } @@ -174,6 +176,7 @@ func (s3a *S3ApiServer) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *h deleteResp.DeletedObjects = deletedObjects } deleteResp.Errors = deleteErrors + stats_collect.S3DeletedObjectsCounter.WithLabelValues(bucket).Add(float64(len(deletedObjects))) writeSuccessResponseXML(w, r, deleteResp) diff --git a/weed/s3api/s3api_object_handlers_multipart.go b/weed/s3api/s3api_object_handlers_multipart.go index 8a274d72c..707a98df5 100644 --- a/weed/s3api/s3api_object_handlers_multipart.go +++ b/weed/s3api/s3api_object_handlers_multipart.go @@ -15,7 +15,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" weed_server "github.com/seaweedfs/seaweedfs/weed/server" - + stats_collect "github.com/seaweedfs/seaweedfs/weed/stats" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/s3" ) @@ -91,6 +91,7 @@ func (s3a *S3ApiServer) CompleteMultipartUploadHandler(w http.ResponseWriter, r s3err.WriteErrorResponse(w, r, errCode) return } + stats_collect.S3UploadedObjectsCounter.WithLabelValues(bucket).Inc() writeSuccessResponseXML(w, r, response) diff --git a/weed/s3api/s3api_object_handlers_put.go b/weed/s3api/s3api_object_handlers_put.go index 4f194a18c..9e3f5d9d9 100644 --- a/weed/s3api/s3api_object_handlers_put.go +++ b/weed/s3api/s3api_object_handlers_put.go @@ -102,6 +102,7 @@ func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request) setEtag(w, etag) } + stats_collect.S3UploadedObjectsCounter.WithLabelValues(bucket).Inc() writeSuccessResponseEmpty(w, r) } diff --git a/weed/stats/metrics.go b/weed/stats/metrics.go index 045686479..f741aee10 100644 --- a/weed/stats/metrics.go +++ b/weed/stats/metrics.go @@ -335,6 +335,22 @@ var ( Name: "bucket_traffic_sent_bytes_total", Help: "Total number of bytes sent from an S3 bucket to clients.", }, []string{"bucket"}) + + S3DeletedObjectsCounter = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: Namespace, + Subsystem: "s3", + Name: "deleted_objects", + Help: "Number of objects deleted in each bucket.", + }, []string{"bucket"}) + + S3UploadedObjectsCounter = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: Namespace, + Subsystem: "s3", + Name: "uploaded_objects", + Help: "Number of objects uploaded in each bucket.", + }, []string{"bucket"}) ) func init() { @@ -380,6 +396,8 @@ func init() { Gather.MustRegister(S3TimeToFirstByteHistogram) Gather.MustRegister(S3BucketTrafficReceivedBytesCounter) Gather.MustRegister(S3BucketTrafficSentBytesCounter) + Gather.MustRegister(S3DeletedObjectsCounter) + Gather.MustRegister(S3UploadedObjectsCounter) go bucketMetricTTLControl() } |
