From f892dc6491c8babe9ae110e549ab57faa8fd6798 Mon Sep 17 00:00:00 2001 From: rzrbld Date: Sun, 5 Apr 2020 18:00:20 +0300 Subject: [PATCH 1/2] Add bucket count and object count metrics --- src/handlers/metrics.go | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/handlers/metrics.go b/src/handlers/metrics.go index 373ce6a..cac5ead 100644 --- a/src/handlers/metrics.go +++ b/src/handlers/metrics.go @@ -8,11 +8,26 @@ import ( "github.com/prometheus/client_golang/prometheus/promauto" ) -var opsProcessed = promauto.NewGaugeVec(prometheus.GaugeOpts{ +var bucketsSizes = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "bucket_size_current", Help: "bucket size in kbytes", }, []string{"bucket"}) +var objectsCount = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "objects_count_current", + Help: "number of objects on cluster", +}) + +var objectsSize = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "objects_total_size_current", + Help: "size of objects on cluster", +}) + +var bucketsCount = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "bucket_count_current", + Help: "number of buckets on cluster", +}) + func RecordMetrics() { go func() { for { @@ -22,11 +37,23 @@ func RecordMetrics() { } else { if len(du.BucketsSizes) != 0 { for k, v := range du.BucketsSizes { - opsProcessed.WithLabelValues(string(k)).Set(float64(v)) + bucketsSizes.WithLabelValues(string(k)).Set(float64(v)) } } + + if du.ObjectsCount >= 0 { + objectsCount.Set(float64(du.ObjectsCount)) + } + + if du.ObjectsTotalSize >= 0 { + objectsSize.Set(float64(du.ObjectsTotalSize)) + } + + if du.BucketsCount >= 0 { + bucketsCount.Set(float64(du.BucketsCount)) + } } - time.Sleep(30 * time.Minute) + time.Sleep(2 * time.Minute) } }() } From 3486ed45299f5717b3b59531dc23ec1c279dbe49 Mon Sep 17 00:00:00 2001 From: rzrbld Date: Sun, 5 Apr 2020 18:30:00 +0300 Subject: [PATCH 2/2] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 30fb190..961c640 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ main run.sh runc.sh rung.sh +runl.sh