diff --git a/weed/server/filer_server.go b/weed/server/filer_server.go index ee052579c..1016b4447 100644 --- a/weed/server/filer_server.go +++ b/weed/server/filer_server.go @@ -159,6 +159,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption) fs.checkWithMaster() go stats.LoopPushingMetric("filer", string(fs.option.Host), fs.metricsAddress, fs.metricsIntervalSec) + go fs.loopUpdateMetric() go fs.filer.KeepMasterClientConnected(context.Background()) if !util.LoadConfiguration("filer", false) { diff --git a/weed/server/filer_server_metric.go b/weed/server/filer_server_metric.go new file mode 100644 index 000000000..913dbd5f4 --- /dev/null +++ b/weed/server/filer_server_metric.go @@ -0,0 +1,20 @@ +package weed_server + +import ( + "sync/atomic" + "time" + + "github.com/seaweedfs/seaweedfs/weed/stats" +) + +func (fs *FilerServer) loopUpdateMetric() { + + ticker := time.NewTicker(time.Second) + defer ticker.Stop() + + for range ticker.C { + inFlightDataSize := atomic.LoadInt64(&fs.inFlightDataSize) + stats.FilerInFlightDataSizeGauge.Set(float64(inFlightDataSize)) + } + +} diff --git a/weed/stats/metrics.go b/weed/stats/metrics.go index 956bf4009..c38873dbf 100644 --- a/weed/stats/metrics.go +++ b/weed/stats/metrics.go @@ -135,6 +135,14 @@ var ( Help: "The last send timestamp of the filer subscription.", }, []string{"sourceFiler", "clientName", "path"}) + FilerInFlightDataSizeGauge = prometheus.NewGauge( + prometheus.GaugeOpts{ + Namespace: Namespace, + Subsystem: "filer", + Name: "in_flight_data_size", + Help: "", + }) + FilerStoreCounter = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: Namespace, @@ -299,6 +307,7 @@ func init() { Gather.MustRegister(FilerStoreHistogram) Gather.MustRegister(FilerSyncOffsetGauge) Gather.MustRegister(FilerServerLastSendTsOfSubscribeGauge) + Gather.MustRegister(FilerInFlightDataSizeGauge) Gather.MustRegister(collectors.NewGoCollector()) Gather.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))