Skip to content

Commit

Permalink
Support harbor v2.6 (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
thechristschn authored Nov 16, 2022
1 parent 6599268 commit 8d7e27a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions metrics_systemvolumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func (h *HarborExporter) collectSystemVolumesMetric(ch chan<- prometheus.Metric) bool {
start := time.Now()
type systemVolumesMetric struct {
Storage struct {
Storage []struct {
Total float64
Free float64
}
Expand All @@ -23,11 +23,16 @@ func (h *HarborExporter) collectSystemVolumesMetric(ch chan<- prometheus.Metric)
return false
}

if len(data.Storage) < 1 {
level.Error(h.logger).Log("msg", "Error retrieving system volumes")
return false
}

ch <- prometheus.MustNewConstMetric(
allMetrics["system_volumes_bytes"].Desc, allMetrics["system_volumes_bytes"].Type, data.Storage.Total, "total",
allMetrics["system_volumes_bytes"].Desc, allMetrics["system_volumes_bytes"].Type, data.Storage[0].Total, "total",
)
ch <- prometheus.MustNewConstMetric(
allMetrics["system_volumes_bytes"].Desc, allMetrics["system_volumes_bytes"].Type, data.Storage.Free, "free",
allMetrics["system_volumes_bytes"].Desc, allMetrics["system_volumes_bytes"].Type, data.Storage[0].Free, "free",
)

reportLatency(start, "system_volumes_latency", ch)
Expand Down

0 comments on commit 8d7e27a

Please sign in to comment.