Skip to content

Commit fa5214b

Browse files
Merge pull request #3 from willgorman/deletedvols
Label cluster_volume_count by status
2 parents f9788b4 + d1ffb46 commit fa5214b

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

pkg/prom/collector.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,25 @@ func (c *SolidfireCollector) collectVolumeMeta(ctx context.Context, ch chan<- pr
182182
mu.Lock()
183183
defer mu.Unlock()
184184

185-
ch <- prometheus.MustNewConstMetric(
186-
MetricDescriptions.VolumeCount,
187-
prometheus.CounterValue,
188-
float64(len(volumes.Result.Volumes)),
189-
)
185+
volumeCntByStatus := map[string]int{}
190186

191187
for _, vol := range volumes.Result.Volumes {
192188
c.volumeNamesByID[vol.VolumeID] = vol.Name
189+
volumeCntByStatus[vol.Status]++
190+
}
191+
192+
for status, count := range volumeCntByStatus {
193+
ch <- prometheus.MustNewConstMetric(
194+
MetricDescriptions.VolumeCount,
195+
prometheus.CounterValue,
196+
float64(count),
197+
status,
198+
)
193199
}
194200
return nil
195201
}
196-
func (c *SolidfireCollector) collectNodeMeta(ctx context.Context, ch chan<- prometheus.Metric) error {
197202

203+
func (c *SolidfireCollector) collectNodeMeta(ctx context.Context, ch chan<- prometheus.Metric) error {
198204
nodes, err := c.client.ListAllNodes(ctx)
199205
if err != nil {
200206
return err
@@ -410,6 +416,7 @@ func (c *SolidfireCollector) collectVolumeStats(ctx context.Context, ch chan<- p
410416
}
411417
return nil
412418
}
419+
413420
func (c *SolidfireCollector) collectClusterCapacity(ctx context.Context, ch chan<- prometheus.Metric) error {
414421
clusterCapacity, err := c.client.GetClusterCapacity(ctx)
415422
if err != nil {
@@ -562,6 +569,7 @@ func (c *SolidfireCollector) collectClusterCapacity(ctx context.Context, ch chan
562569
clusterThinProvisioningFactor*clusterDeDuplicationFactor*clusterCompressionFactor)
563570
return nil
564571
}
572+
565573
func (c *SolidfireCollector) collectClusterFaults(ctx context.Context, ch chan<- prometheus.Metric) error {
566574
ClusterActiveFaults, err := c.client.ListClusterFaults(ctx)
567575
if err != nil {
@@ -588,6 +596,7 @@ func (c *SolidfireCollector) collectClusterFaults(ctx context.Context, ch chan<-
588596
}
589597
return nil
590598
}
599+
591600
func (c *SolidfireCollector) collectClusterNodeStats(ctx context.Context, ch chan<- prometheus.Metric) error {
592601
ClusterNodeStats, err := c.client.ListNodeStats(ctx)
593602
if err != nil {
@@ -752,6 +761,7 @@ func (c *SolidfireCollector) collectClusterNodeStats(ctx context.Context, ch cha
752761
}
753762
return nil
754763
}
764+
755765
func (c *SolidfireCollector) collectVolumeQosHistograms(ctx context.Context, ch chan<- prometheus.Metric) error {
756766
VolumeQoSHistograms, err := c.client.ListVolumeQoSHistograms(ctx)
757767
if err != nil {
@@ -871,6 +881,7 @@ func (c *SolidfireCollector) collectVolumeQosHistograms(ctx context.Context, ch
871881
}
872882
return nil
873883
}
884+
874885
func (c *SolidfireCollector) collectClusterStats(ctx context.Context, ch chan<- prometheus.Metric) error {
875886
clusterStats, err := c.client.GetClusterStats(ctx)
876887
if err != nil {
@@ -1192,6 +1203,7 @@ func (c *SolidfireCollector) collectClusterFullThreshold(ctx context.Context, ch
11921203
)
11931204
return nil
11941205
}
1206+
11951207
func (c *SolidfireCollector) collectDriveDetails(ctx context.Context, ch chan<- prometheus.Metric) error {
11961208
ListDrives, err := c.client.ListDrives(ctx)
11971209
if err != nil {
@@ -1233,6 +1245,7 @@ func (c *SolidfireCollector) collectDriveDetails(ctx context.Context, ch chan<-
12331245
}
12341246
return nil
12351247
}
1248+
12361249
func (c *SolidfireCollector) collectISCSISessions(ctx context.Context, ch chan<- prometheus.Metric) error {
12371250
ListISCSISessions, err := c.client.ListISCSISessions(ctx)
12381251
if err != nil {
@@ -1294,6 +1307,7 @@ func (c *SolidfireCollector) collectInitiators(ctx context.Context, ch chan<- pr
12941307
)
12951308
return nil
12961309
}
1310+
12971311
func (c *SolidfireCollector) collectVolumeAccessGroups(ctx context.Context, ch chan<- prometheus.Metric) error {
12981312
volumeAccessGroups, err := c.client.ListVolumeAccessGroups(ctx)
12991313
if err != nil {

pkg/prom/metrics.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type Descriptions struct {
6565
ClusterUsedMetadataSpaceInSnapshotsBytes *prometheus.Desc
6666
ClusterUsedSpaceBytes *prometheus.Desc
6767
ClusterZeroBlocks *prometheus.Desc
68-
//The following metrics are Calculated by us:
68+
// The following metrics are Calculated by us:
6969
ClusterCompressionFactor *prometheus.Desc
7070
ClusterDeDuplicationFactor *prometheus.Desc
7171
ClusterEfficiencyFactor *prometheus.Desc
@@ -140,7 +140,7 @@ type Descriptions struct {
140140
DriveCapacityBytes *prometheus.Desc
141141

142142
NodeISCSISessions *prometheus.Desc
143-
//NodeISCSIVolumes *prometheus.Desc
143+
// NodeISCSIVolumes *prometheus.Desc
144144

145145
InitiatorCount *prometheus.Desc
146146
AccountCount *prometheus.Desc
@@ -936,7 +936,7 @@ func NewMetricDescriptions(namespace string) *Descriptions {
936936
d.VolumeCount = prometheus.NewDesc(
937937
prometheus.BuildFQName(namespace, "", "cluster_volume_count"),
938938
"The total number of volumes in cluster",
939-
nil,
939+
[]string{"status"},
940940
nil,
941941
)
942942

pkg/testutils/collector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ solidfire_volume_burst_iops_credit{volume_id="1",volume_name="test-volume1"} 600
145145
solidfire_volume_burst_iops_credit{volume_id="2",volume_name="test-volume2"} 0
146146
solidfire_volume_client_queue_depth{volume_id="1",volume_name="test-volume1"} 0
147147
solidfire_volume_client_queue_depth{volume_id="2",volume_name="test-volume2"} 0
148-
solidfire_cluster_volume_count 2
148+
solidfire_cluster_volume_count{status="active"} 2
149149
solidfire_volume_last_sample_read_bytes{volume_id="1",volume_name="test-volume1"} 0
150150
solidfire_volume_last_sample_read_bytes{volume_id="2",volume_name="test-volume2"} 0
151151
solidfire_volume_last_sample_read_ops{volume_id="1",volume_name="test-volume1"} 0
@@ -427,7 +427,7 @@ solidfire_node_used_memory_bytes{node_id="1",node_name="n01"} 9.000198144e+09
427427
solidfire_node_write_latency_seconds_total{node_id="1",node_name="n01"} 0
428428
solidfire_node_write_ops_total{node_id="1",node_name="n01"} 1.3089387e+07
429429
solidfire_up 0
430-
solidfire_cluster_volume_count 2
430+
solidfire_cluster_volume_count{status="active"} 2
431431
solidfire_volume_qos_below_min_iops_percentage_bucket{volume_id="1",volume_name="test-volume1",le="19"} 32
432432
solidfire_volume_qos_below_min_iops_percentage_bucket{volume_id="1",volume_name="test-volume1",le="39"} 6
433433
solidfire_volume_qos_below_min_iops_percentage_bucket{volume_id="1",volume_name="test-volume1",le="59"} 4

0 commit comments

Comments
 (0)