Skip to content

Commit

Permalink
Add hostname label to ceph_crash_reports
Browse files Browse the repository at this point in the history
  • Loading branch information
xvillaneau committed Jun 16, 2022
1 parent 2faa6cb commit ae09ffe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
11 changes: 7 additions & 4 deletions ceph/crashes.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewCrashesCollector(exporter *Exporter) *CrashesCollector {
crashReportsDesc: prometheus.NewDesc(
fmt.Sprintf("%s_crash_reports", cephNamespace),
"Count of crashes reports per daemon, according to `ceph crash ls`",
[]string{"entity", "status"},
[]string{"entity", "hostname", "status"},
labels,
),
}
Expand All @@ -60,12 +60,14 @@ func NewCrashesCollector(exporter *Exporter) *CrashesCollector {
}

type crashEntry struct {
entity string
isNew bool
entity string
hostname string
isNew bool
}

type cephCrashLs struct {
Entity string `json:"entity_name"`
Hostname string `json:"utsname_hostname"`
Archived string `json:"archived"`
}

Expand All @@ -92,7 +94,7 @@ func (c *CrashesCollector) getCrashLs() (map[crashEntry]int, error) {
}

for _, crash := range crashData {
crashes[crashEntry{crash.Entity, len(crash.Archived) == 0}]++
crashes[crashEntry{crash.Entity, crash.Hostname, len(crash.Archived) == 0}]++
}

return crashes, nil
Expand All @@ -116,6 +118,7 @@ func (c *CrashesCollector) Collect(ch chan<- prometheus.Metric) {
prometheus.GaugeValue,
float64(count),
crash.entity,
crash.hostname,
statusNames[crash.isNew],
)
}
Expand Down
21 changes: 14 additions & 7 deletions ceph/crashes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestCrashesCollector(t *testing.T) {
}
]`,
reMatch: []*regexp.Regexp{
regexp.MustCompile(`crash_reports{cluster="ceph",entity="client.admin",status="new"} 1`),
regexp.MustCompile(`crash_reports{cluster="ceph",entity="client.admin",hostname="test-ceph-server.company.example",status="new"} 1`),
},
},
{
Expand All @@ -95,14 +95,15 @@ func TestCrashesCollector(t *testing.T) {
[
{
"entity_name": "client.admin",
"utsname_hostname": "test-ceph-server.company.example",
"timestamp": "2022-01-25 21:02:46.687015Z",
"archived": "2022-06-14 19:44:40.356826",
"crash_id": "2022-01-25_21:02:46.687015Z_d6513591-c16b-472f-8d40-5a143b28837d"
}
]
`,
reMatch: []*regexp.Regexp{
regexp.MustCompile(`crash_reports{cluster="ceph",entity="client.admin",status="archived"} 1`),
regexp.MustCompile(`crash_reports{cluster="ceph",entity="client.admin",hostname="test-ceph-server.company.example",status="archived"} 1`),
},
},
{
Expand All @@ -111,17 +112,19 @@ func TestCrashesCollector(t *testing.T) {
[
{
"entity_name": "osd.0",
"utsname_hostname": "test-ceph-server.company.example",
"timestamp": "2022-02-01 21:02:46.687015Z",
"crash_id": "2022-02-01_21:02:46.687015Z_0de8b741-b323-4f63-828a-e460294e28b9"
},
{
"entity_name": "osd.0",
"utsname_hostname": "test-ceph-server.company.example",
"timestamp": "2022-02-03 04:05:45.419226Z",
"crash_id": "2022-02-03_04:05:45.419226Z_11c639af-5eb2-4a29-91aa-20120218891a"
}
]`,
reMatch: []*regexp.Regexp{
regexp.MustCompile(`crash_reports{cluster="ceph",entity="osd.0",status="new"} 2`),
regexp.MustCompile(`crash_reports{cluster="ceph",entity="osd.0",hostname="test-ceph-server.company.example",status="new"} 2`),
},
},
{
Expand All @@ -130,19 +133,21 @@ func TestCrashesCollector(t *testing.T) {
[
{
"entity_name": "osd.0",
"utsname_hostname": "test-ceph-server.company.example",
"timestamp": "2022-02-01 21:02:46.687015Z",
"crash_id": "2022-02-01_21:02:46.687015Z_0de8b741-b323-4f63-828a-e460294e28b9"
},
{
"entity_name": "osd.0",
"utsname_hostname": "test-ceph-server.company.example",
"timestamp": "2022-02-03 04:05:45.419226Z",
"archived": "2022-06-14 19:44:40.356826",
"crash_id": "2022-02-03_04:05:45.419226Z_11c639af-5eb2-4a29-91aa-20120218891a"
}
]`,
reMatch: []*regexp.Regexp{
regexp.MustCompile(`crash_reports{cluster="ceph",entity="osd.0",status="new"} 1`),
regexp.MustCompile(`crash_reports{cluster="ceph",entity="osd.0",status="archived"} 1`),
regexp.MustCompile(`crash_reports{cluster="ceph",entity="osd.0",hostname="test-ceph-server.company.example",status="new"} 1`),
regexp.MustCompile(`crash_reports{cluster="ceph",entity="osd.0",hostname="test-ceph-server.company.example",status="archived"} 1`),
},
},
{
Expand All @@ -151,18 +156,20 @@ func TestCrashesCollector(t *testing.T) {
[
{
"entity_name": "mgr.mgr-node-01",
"utsname_hostname": "test-ceph-server.company.example",
"timestamp": "2022-02-01 21:02:46.687015Z",
"crash_id": "2022-02-01_21:02:46.687015Z_0de8b741-b323-4f63-828a-e460294e28b9"
},
{
"entity_name": "client.admin",
"utsname_hostname": "test-ceph-server.company.example",
"timestamp": "2022-02-03 04:05:45.419226Z",
"crash_id": "2022-02-03_04:05:45.419226Z_11c639af-5eb2-4a29-91aa-20120218891a"
}
]`,
reMatch: []*regexp.Regexp{
regexp.MustCompile(`crash_reports{cluster="ceph",entity="mgr.mgr-node-01",status="new"} 1`),
regexp.MustCompile(`crash_reports{cluster="ceph",entity="client.admin",status="new"} 1`),
regexp.MustCompile(`crash_reports{cluster="ceph",entity="mgr.mgr-node-01",hostname="test-ceph-server.company.example",status="new"} 1`),
regexp.MustCompile(`crash_reports{cluster="ceph",entity="client.admin",hostname="test-ceph-server.company.example",status="new"} 1`),
},
},
{
Expand Down

0 comments on commit ae09ffe

Please sign in to comment.