s3: expose /metrics on main HTTP port

Allows the admin server to scrape S3 API server metrics without a
separate -metricsPort. Placed alongside /status and /healthz.
This commit is contained in:
Chris Lu
2026-09-14 20:41:44 -07:00
parent 7d9c875599
commit ebbc6ed21f
+3
View File
@@ -16,6 +16,7 @@ import (
"time"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
"google.golang.org/grpc"
"github.com/seaweedfs/seaweedfs/weed/cluster"
@@ -33,6 +34,7 @@ import (
. "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3err"
"github.com/seaweedfs/seaweedfs/weed/security"
stats_collect "github.com/seaweedfs/seaweedfs/weed/stats"
"github.com/seaweedfs/seaweedfs/weed/util"
"github.com/seaweedfs/seaweedfs/weed/util/chunk_cache"
"github.com/seaweedfs/seaweedfs/weed/util/grace"
@@ -788,6 +790,7 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) {
apiRouter.Methods(http.MethodGet, http.MethodHead).Path("/status").HandlerFunc(s3a.StatusHandler)
apiRouter.Methods(http.MethodGet, http.MethodHead).Path("/healthz").HandlerFunc(s3a.StatusHandler)
apiRouter.Methods(http.MethodGet, http.MethodHead).Path("/readyz").HandlerFunc(s3a.StatusHandler)
apiRouter.Methods(http.MethodGet).Path("/metrics").Handler(promhttp.HandlerFor(stats_collect.Gather, promhttp.HandlerOpts{}))
// Object path pattern with (?s) flag to match newlines in object keys
const objectPath = "/{object:(?s).+}"