aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-10-22 09:13:47 -0700
committerChris Lu <chris.lu@gmail.com>2020-10-22 09:13:47 -0700
commit575d7952a141f4f8061943d84032f26f2ea48a9a (patch)
tree9c42762fc5098f90f1c0824dcb388655cb9d367a
parent5179e559f74cf7aed562f785e40bef46da3191bf (diff)
downloadseaweedfs-575d7952a141f4f8061943d84032f26f2ea48a9a.tar.xz
seaweedfs-575d7952a141f4f8061943d84032f26f2ea48a9a.zip
add available resource stats
fix https://github.com/chrislusf/seaweedfs/issues/1555
-rw-r--r--weed/stats/metrics.go9
-rw-r--r--weed/storage/disk_location.go3
2 files changed, 12 insertions, 0 deletions
diff --git a/weed/stats/metrics.go b/weed/stats/metrics.go
index 13ab3bae1..3f5d851a4 100644
--- a/weed/stats/metrics.go
+++ b/weed/stats/metrics.go
@@ -101,6 +101,14 @@ var (
Help: "Actual disk size used by volumes.",
}, []string{"collection", "type"})
+ VolumeServerResourceGauge = prometheus.NewGaugeVec(
+ prometheus.GaugeOpts{
+ Namespace: "SeaweedFS",
+ Subsystem: "volumeServer",
+ Name: "resource",
+ Help: "Resource usage",
+ }, []string{"name", "type"})
+
S3RequestCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "SeaweedFS",
@@ -132,6 +140,7 @@ func init() {
Gather.MustRegister(VolumeServerMaxVolumeCounter)
Gather.MustRegister(VolumeServerReadOnlyVolumeGauge)
Gather.MustRegister(VolumeServerDiskSizeGauge)
+ Gather.MustRegister(VolumeServerResourceGauge)
Gather.MustRegister(S3RequestCounter)
Gather.MustRegister(S3RequestHistogram)
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index c309b3f92..ed57aa54b 100644
--- a/weed/storage/disk_location.go
+++ b/weed/storage/disk_location.go
@@ -305,6 +305,9 @@ func (l *DiskLocation) CheckDiskSpace() {
for {
if dir, e := filepath.Abs(l.Directory); e == nil {
s := stats.NewDiskStatus(dir)
+ stats.VolumeServerResourceGauge.WithLabelValues(l.Directory, "all").Set(float64(s.All))
+ stats.VolumeServerResourceGauge.WithLabelValues(l.Directory, "used").Set(float64(s.Used))
+ stats.VolumeServerResourceGauge.WithLabelValues(l.Directory, "free").Set(float64(s.Free))
if (s.PercentFree < l.MinFreeSpacePercent) != l.isDiskSpaceLow {
l.isDiskSpaceLow = !l.isDiskSpaceLow
}