Skip to content

Commit

Permalink
new metric for tracking which node a volume is on (#12)
Browse files Browse the repository at this point in the history
* new metric for tracking which node a volume is on
  • Loading branch information
mjavier2k authored Mar 17, 2020
1 parent c76c8ae commit bc09387
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/prom/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func (c *solidfireCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- MetricDescriptions.ListDrivesCapacity

ch <- MetricDescriptions.NodeISCSISessionsTotal
ch <- MetricDescriptions.NodeISCSIVolumes
}

func (c *solidfireCollector) Collect(ch chan<- prometheus.Metric) {
Expand Down Expand Up @@ -1186,6 +1187,7 @@ func (c *solidfireCollector) Collect(ch chan<- prometheus.Metric) {

for node, v := range sessions {
for vol, val := range v {

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.NodeISCSISessionsTotal,
prometheus.GaugeValue,
Expand All @@ -1195,6 +1197,15 @@ func (c *solidfireCollector) Collect(ch chan<- prometheus.Metric) {
strconv.Itoa(vol),
volumeNamesByID[vol],
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.NodeISCSIVolumes,
prometheus.GaugeValue,
float64(node),
strconv.Itoa(vol),
volumeNamesByID[vol],
)

}
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/prom/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ type Descriptions struct {
ListDrivesCapacity *prometheus.Desc

NodeISCSISessionsTotal *prometheus.Desc
NodeISCSIVolumes *prometheus.Desc
}

func NewMetricDescriptions(namespace string) *Descriptions {
Expand Down Expand Up @@ -957,5 +958,12 @@ func NewMetricDescriptions(namespace string) *Descriptions {
nil,
)

d.NodeISCSIVolumes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "volume_node_id"),
"The node id where the volume is hosted.",
[]string{"volume_id", "volume_name"},
nil,
)

return &d
}

0 comments on commit bc09387

Please sign in to comment.