Skip to content

Commit 0465c55

Browse files
committed
fix: lsblk strip rootfs strip prefix
1 parent 63e6b2c commit 0465c55

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

collector/lsblk_linux.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,21 @@ func lsblkStringPtr(s *string) string {
6868
return *s
6969
}
7070

71+
// lsblkMountpointForLabels maps mount paths under --path.rootfs to the host view (same as filesystem collector).
72+
func lsblkMountpointForLabels(mp *string) string {
73+
if mp == nil || *mp == "" {
74+
return ""
75+
}
76+
return rootfsStripPrefix(*mp)
77+
}
78+
7179
func (c *lsblkCollector) emitRecursive(ch chan<- prometheus.Metric, devices []lsblkJSONDevice, parent string) {
7280
for _, d := range devices {
7381
ch <- prometheus.MustNewConstMetric(c.infoDesc, prometheus.GaugeValue, 1,
7482
d.Name,
7583
parent,
7684
lsblkStringPtr(d.Fstype),
77-
lsblkStringPtr(d.Mountpoint),
85+
lsblkMountpointForLabels(d.Mountpoint),
7886
lsblkStringPtr(d.Size),
7987
lsblkStringPtr(d.Fsused),
8088
lsblkStringPtr(d.FsusePct),

0 commit comments

Comments
 (0)