diff options
author | Jakob Borg <jakob@kastelo.net> | 2023-11-24 09:05:57 +0100 |
---|---|---|
committer | Jakob Borg <jakob@kastelo.net> | 2023-11-27 08:24:59 +0100 |
commit | 2ae15aa4546b8cf76cd6077303aa6b97e2e043ee (patch) | |
tree | 3263b89ae8a5c74b14a50d72641ebca9f3087982 | |
parent | 47bcf4f8f4909b971640ffc4607807382f156803 (diff) | |
download | syncthing-2ae15aa4546b8cf76cd6077303aa6b97e2e043ee.tar.gz syncthing-2ae15aa4546b8cf76cd6077303aa6b97e2e043ee.zip |
cmd/stcrashreceiver: Add metrics for diskstore inventory
-rw-r--r-- | cmd/stcrashreceiver/diskstore.go | 11 | ||||
-rw-r--r-- | cmd/stcrashreceiver/metrics.go | 15 |
2 files changed, 26 insertions, 0 deletions
diff --git a/cmd/stcrashreceiver/diskstore.go b/cmd/stcrashreceiver/diskstore.go index 1073dee14..124d77d4a 100644 --- a/cmd/stcrashreceiver/diskstore.go +++ b/cmd/stcrashreceiver/diskstore.go @@ -12,6 +12,7 @@ import ( "context" "io" "log" + "math" "os" "path/filepath" "sort" @@ -147,6 +148,11 @@ func (d *diskStore) clean() { if len(d.currentFiles) > 0 { oldest = time.Since(time.Unix(d.currentFiles[0].mtime, 0)).Truncate(time.Minute) } + + metricDiskstoreFilesTotal.Set(float64(len(d.currentFiles))) + metricDiskstoreBytesTotal.Set(float64(d.currentSize)) + metricDiskstoreOldestAgeSeconds.Set(math.Round(oldest.Seconds())) + log.Printf("Clean complete: %d files, %d MB, oldest is %v ago", len(d.currentFiles), d.currentSize>>20, oldest) } @@ -178,6 +184,11 @@ func (d *diskStore) inventory() error { if len(d.currentFiles) > 0 { oldest = time.Since(time.Unix(d.currentFiles[0].mtime, 0)).Truncate(time.Minute) } + + metricDiskstoreFilesTotal.Set(float64(len(d.currentFiles))) + metricDiskstoreBytesTotal.Set(float64(d.currentSize)) + metricDiskstoreOldestAgeSeconds.Set(math.Round(oldest.Seconds())) + log.Printf("Inventory complete: %d files, %d MB, oldest is %v ago", len(d.currentFiles), d.currentSize>>20, oldest) return err } diff --git a/cmd/stcrashreceiver/metrics.go b/cmd/stcrashreceiver/metrics.go index a7539d816..8ccbc8fa3 100644 --- a/cmd/stcrashreceiver/metrics.go +++ b/cmd/stcrashreceiver/metrics.go @@ -22,4 +22,19 @@ var ( Subsystem: "crashreceiver", Name: "failure_reports_total", }, []string{"result"}) + metricDiskstoreFilesTotal = promauto.NewGauge(prometheus.GaugeOpts{ + Namespace: "syncthing", + Subsystem: "crashreceiver", + Name: "diskstore_files_total", + }) + metricDiskstoreBytesTotal = promauto.NewGauge(prometheus.GaugeOpts{ + Namespace: "syncthing", + Subsystem: "crashreceiver", + Name: "diskstore_bytes_total", + }) + metricDiskstoreOldestAgeSeconds = promauto.NewGauge(prometheus.GaugeOpts{ + Namespace: "syncthing", + Subsystem: "crashreceiver", + Name: "diskstore_oldest_age_seconds", + }) ) |