mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add bucket label to s3 prometheus metrics
This commit is contained in:
parent
097a12dfb4
commit
62f74f5e3c
|
@ -1,6 +1,7 @@
|
||||||
package s3api
|
package s3api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/s3api/s3_constants"
|
||||||
stats_collect "github.com/chrislusf/seaweedfs/weed/stats"
|
stats_collect "github.com/chrislusf/seaweedfs/weed/stats"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -27,11 +28,12 @@ func (r *StatusRecorder) Flush() {
|
||||||
|
|
||||||
func track(f http.HandlerFunc, action string) http.HandlerFunc {
|
func track(f http.HandlerFunc, action string) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
bucket, _ := s3_constants.GetBucketAndObject(r)
|
||||||
w.Header().Set("Server", "SeaweedFS S3")
|
w.Header().Set("Server", "SeaweedFS S3")
|
||||||
recorder := NewStatusResponseWriter(w)
|
recorder := NewStatusResponseWriter(w)
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
f(recorder, r)
|
f(recorder, r)
|
||||||
stats_collect.S3RequestHistogram.WithLabelValues(action).Observe(time.Since(start).Seconds())
|
stats_collect.S3RequestHistogram.WithLabelValues(action, bucket).Observe(time.Since(start).Seconds())
|
||||||
stats_collect.S3RequestCounter.WithLabelValues(action, strconv.Itoa(recorder.Status)).Inc()
|
stats_collect.S3RequestCounter.WithLabelValues(action, strconv.Itoa(recorder.Status), bucket).Inc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,8 @@ var (
|
||||||
Subsystem: "s3",
|
Subsystem: "s3",
|
||||||
Name: "request_total",
|
Name: "request_total",
|
||||||
Help: "Counter of s3 requests.",
|
Help: "Counter of s3 requests.",
|
||||||
}, []string{"type", "code"})
|
}, []string{"type", "code", "bucket"})
|
||||||
|
|
||||||
S3RequestHistogram = prometheus.NewHistogramVec(
|
S3RequestHistogram = prometheus.NewHistogramVec(
|
||||||
prometheus.HistogramOpts{
|
prometheus.HistogramOpts{
|
||||||
Namespace: "SeaweedFS",
|
Namespace: "SeaweedFS",
|
||||||
|
@ -181,7 +182,7 @@ var (
|
||||||
Name: "request_seconds",
|
Name: "request_seconds",
|
||||||
Help: "Bucketed histogram of s3 request processing time.",
|
Help: "Bucketed histogram of s3 request processing time.",
|
||||||
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 24),
|
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 24),
|
||||||
}, []string{"type"})
|
}, []string{"type", "bucket"})
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
Loading…
Reference in a new issue