diff --git a/collectors/health.go b/collectors/health.go index 0fa06bf..4350f29 100644 --- a/collectors/health.go +++ b/collectors/health.go @@ -964,7 +964,7 @@ type cephHealthStats struct { ServiceMap struct { Services struct { RbdMirror struct { - Daemons map[string]interface{} `json:"daemons"` + Daemons map[string]json.RawMessage `json:"daemons"` } `json:"rbd-mirror"` } `json:"services"` } `json:"servicemap"` @@ -1307,13 +1307,22 @@ func (c *ClusterHealthCollector) collect(ch chan<- prometheus.Metric) error { c.MgrsActive.Set(float64(activeMgr)) c.MgrsNum.Set(float64(activeMgr + len(stats.MgrMap.StandBys))) - for name := range stats.ServiceMap.Services.RbdMirror.Daemons { + for name, data := range stats.ServiceMap.Services.RbdMirror.Daemons { if name == "summary" { continue } - ch <- prometheus.MustNewConstMetric( - c.RbdMirrorUp, prometheus.GaugeValue, 1.0, name) + md := struct { + Metadata struct { + Id string `json:"id"` + } `json:"metadata"` + }{} + + // Extract id from metadata + if err := json.Unmarshal(data, &md); err == nil { + ch <- prometheus.MustNewConstMetric( + c.RbdMirrorUp, prometheus.GaugeValue, 1.0, md.Metadata.Id) + } } return nil diff --git a/collectors/health_test.go b/collectors/health_test.go index 81d0407..c7b84fb 100644 --- a/collectors/health_test.go +++ b/collectors/health_test.go @@ -711,16 +711,23 @@ $ sudo ceph -s "rbd-mirror": { "daemons": { "summary": "", - "prod-mon01-block01": { - "addr": "10.78.41.10:0/1272328707", + "681363": { + "start_epoch": 4, + "start_stamp": "2020-09-24 04:27:12.310285", + "addr": "10.39.70.112:0/2856123533", "metadata": { - "arch": "x86_64" + "arch": "x86_64", + "id": "prod-mon01-block01" } }, - "prod-mon02-block01": { - "addr": "10.78.41.11:0/2337288266", + + "681474": { + "start_epoch": 6, + "start_stamp": "2020-09-24 04:28:44.500861", + "addr": "10.39.70.111:0/3132809711", "metadata": { - "arch": "x86_64" + "arch": "x86_64", + "id": "prod-mon02-block01" } } }