From 58ffa9cbba25c3c8499630a24b2bbf5c8363884f Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 14 Sep 2026 20:40:35 -0700 Subject: [PATCH] master: expose /metrics on main HTTP port Allows the admin server to scrape master metrics without a separate -metricsPort. Uses the same promhttp.HandlerFor(stats.Gather) pattern as the admin server's own /metrics endpoint. --- weed/server/master_server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/weed/server/master_server.go b/weed/server/master_server.go index 3a1364c11..b47ab25ba 100644 --- a/weed/server/master_server.go +++ b/weed/server/master_server.go @@ -14,6 +14,7 @@ import ( "sync" "time" + "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/seaweedfs/seaweedfs/weed/cluster/maintenance" "github.com/seaweedfs/seaweedfs/weed/stats" "github.com/seaweedfs/seaweedfs/weed/telemetry" @@ -175,6 +176,7 @@ func NewMasterServer(r *mux.Router, option *MasterOption, peers map[string]pb.Se handleStaticResources2(r) r.HandleFunc("/healthz", requestIDMiddleware(ms.healthzHandler)).Methods(http.MethodGet, http.MethodHead) r.HandleFunc("/readyz", requestIDMiddleware(ms.readyzHandler)).Methods(http.MethodGet, http.MethodHead) + r.Handle("/metrics", promhttp.HandlerFor(stats.Gather, promhttp.HandlerOpts{})).Methods(http.MethodGet) r.HandleFunc("/", ms.proxyToLeader(requestIDMiddleware(ms.uiStatusHandler))) r.HandleFunc("/ui/index.html", requestIDMiddleware(ms.uiStatusHandler)) if !ms.option.DisableHttp {