Skip to content

Commit

Permalink
Merge pull request #176 from syhpoon/BLOCK-2553
Browse files Browse the repository at this point in the history
rbd_mirror_up: switch to const metric
  • Loading branch information
syhpoon committed Sep 14, 2020
2 parents f383240 + 30e99c4 commit d332f23
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions collectors/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ type ClusterHealthCollector struct {
MgrsNum prometheus.Gauge

// RbdMirrorUp shows the alive rbd-mirror daemons
RbdMirrorUp *prometheus.GaugeVec
RbdMirrorUp *prometheus.Desc
}

const (
Expand Down Expand Up @@ -820,14 +820,11 @@ func NewClusterHealthCollector(conn Conn, cluster string) *ClusterHealthCollecto
ConstLabels: labels,
},
),
RbdMirrorUp: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: cephNamespace,
Name: "rbd_mirror_up",
Help: "Alive rbd-mirror daemons",
ConstLabels: labels,
},
RbdMirrorUp: prometheus.NewDesc(
fmt.Sprintf("%s_rbd_mirror_up", cephNamespace),
"Alive rbd-mirror daemons",
[]string{"name"},
labels,
),
}
}
Expand Down Expand Up @@ -898,7 +895,6 @@ func (c *ClusterHealthCollector) metricsList() []prometheus.Metric {
func (c *ClusterHealthCollector) collectorList() []prometheus.Collector {
return []prometheus.Collector{
c.PGState,
c.RbdMirrorUp,
}
}

Expand Down Expand Up @@ -1304,7 +1300,8 @@ func (c *ClusterHealthCollector) collect(ch chan<- prometheus.Metric) error {
continue
}

c.RbdMirrorUp.With(prometheus.Labels{"name": name}).Set(1)
ch <- prometheus.MustNewConstMetric(
c.RbdMirrorUp, prometheus.GaugeValue, 1.0, name)
}

return nil
Expand Down Expand Up @@ -1729,6 +1726,7 @@ func (c *ClusterHealthCollector) collectCacheIO(clientStr string) error {
// to the provided prometheus channel.
func (c *ClusterHealthCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- c.SlowRequestsByOSDDesc
ch <- c.RbdMirrorUp

for _, metric := range c.metricsList() {
ch <- metric.Desc()
Expand Down

0 comments on commit d332f23

Please sign in to comment.