Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOD: surface filesystem device error #2918 #2922

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions collector/filesystem_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var (
"Regexp of filesystem types to ignore for filesystem collector.",
).Hidden().String()

filesystemLabelNames = []string{"device", "mountpoint", "fstype"}
filesystemLabelNames = []string{"device", "mountpoint", "fstype", "device_error"}
)

type filesystemCollector struct {
Expand All @@ -73,7 +73,7 @@ type filesystemCollector struct {
}

type filesystemLabels struct {
device, mountPoint, fsType, options string
device, mountPoint, fsType, options, device_error string
}

type filesystemStats struct {
Expand Down Expand Up @@ -184,11 +184,11 @@ func (c *filesystemCollector) Update(ch chan<- prometheus.Metric) error {

ch <- prometheus.MustNewConstMetric(
c.deviceErrorDesc, prometheus.GaugeValue,
s.deviceError, s.labels.device, s.labels.mountPoint, s.labels.fsType,
s.deviceError, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.device_error,
)
ch <- prometheus.MustNewConstMetric(
c.roDesc, prometheus.GaugeValue,
s.ro, s.labels.device, s.labels.mountPoint, s.labels.fsType,
s.ro, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.device_error,
)

if s.deviceError > 0 {
Expand All @@ -197,23 +197,23 @@ func (c *filesystemCollector) Update(ch chan<- prometheus.Metric) error {

ch <- prometheus.MustNewConstMetric(
c.sizeDesc, prometheus.GaugeValue,
s.size, s.labels.device, s.labels.mountPoint, s.labels.fsType,
s.size, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.device_error,
)
ch <- prometheus.MustNewConstMetric(
c.freeDesc, prometheus.GaugeValue,
s.free, s.labels.device, s.labels.mountPoint, s.labels.fsType,
s.free, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.device_error,
)
ch <- prometheus.MustNewConstMetric(
c.availDesc, prometheus.GaugeValue,
s.avail, s.labels.device, s.labels.mountPoint, s.labels.fsType,
s.avail, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.device_error,
)
ch <- prometheus.MustNewConstMetric(
c.filesDesc, prometheus.GaugeValue,
s.files, s.labels.device, s.labels.mountPoint, s.labels.fsType,
s.files, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.device_error,
)
ch <- prometheus.MustNewConstMetric(
c.filesFreeDesc, prometheus.GaugeValue,
s.filesFree, s.labels.device, s.labels.mountPoint, s.labels.fsType,
s.filesFree, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.device_error,
)
}
return nil
Expand Down
3 changes: 3 additions & 0 deletions collector/filesystem_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {

stuckMountsMtx.Lock()
if _, ok := stuckMounts[labels.mountPoint]; ok {
labels.device_error = "mountpoint timeout"
stats = append(stats, filesystemStats{
labels: labels,
deviceError: 1,
Expand Down Expand Up @@ -133,6 +134,7 @@ func (c *filesystemCollector) processStat(labels filesystemLabels) filesystemSta
stuckMountsMtx.Unlock()

if err != nil {
labels.device_error = err.Error()
level.Debug(c.logger).Log("msg", "Error on statfs() system call", "rootfs", rootfsFilePath(labels.mountPoint), "err", err)
return filesystemStats{
labels: labels,
Expand Down Expand Up @@ -211,6 +213,7 @@ func parseFilesystemLabels(r io.Reader) ([]filesystemLabels, error) {
mountPoint: rootfsStripPrefix(parts[1]),
fsType: parts[2],
options: parts[3],
device_error: "",
})
}

Expand Down