aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api/stats.go
diff options
context:
space:
mode:
authorzzq09494 <zzq09494@ly.com>2022-06-16 13:21:25 +0800
committerzzq09494 <zzq09494@ly.com>2022-06-16 13:21:25 +0800
commit62f74f5e3cce0668478c179f81fd1a9c5916e455 (patch)
treefa6b2f17c664c5aabfe5a234431ab506d4f64f8f /weed/s3api/stats.go
parent097a12dfb488236b8accda8e868b2c5d4b64b14e (diff)
downloadseaweedfs-62f74f5e3cce0668478c179f81fd1a9c5916e455.tar.xz
seaweedfs-62f74f5e3cce0668478c179f81fd1a9c5916e455.zip
add bucket label to s3 prometheus metrics
Diffstat (limited to 'weed/s3api/stats.go')
-rw-r--r--weed/s3api/stats.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/weed/s3api/stats.go b/weed/s3api/stats.go
index 973d8c0eb..003807a25 100644
--- a/weed/s3api/stats.go
+++ b/weed/s3api/stats.go
@@ -1,6 +1,7 @@
package s3api
import (
+ "github.com/chrislusf/seaweedfs/weed/s3api/s3_constants"
stats_collect "github.com/chrislusf/seaweedfs/weed/stats"
"net/http"
"strconv"
@@ -27,11 +28,12 @@ func (r *StatusRecorder) Flush() {
func track(f http.HandlerFunc, action string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
+ bucket, _ := s3_constants.GetBucketAndObject(r)
w.Header().Set("Server", "SeaweedFS S3")
recorder := NewStatusResponseWriter(w)
start := time.Now()
f(recorder, r)
- stats_collect.S3RequestHistogram.WithLabelValues(action).Observe(time.Since(start).Seconds())
- stats_collect.S3RequestCounter.WithLabelValues(action, strconv.Itoa(recorder.Status)).Inc()
+ stats_collect.S3RequestHistogram.WithLabelValues(action, bucket).Observe(time.Since(start).Seconds())
+ stats_collect.S3RequestCounter.WithLabelValues(action, strconv.Itoa(recorder.Status), bucket).Inc()
}
}