Skip to content

Commit 860e6b0

Browse files
authored
Merge pull request #452 from vteratipally/add_fstypes
Add more info to disk metrics
2 parents c01ea4f + 50127b0 commit 860e6b0

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

pkg/systemstatsmonitor/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Below metrics are collected from `disk` component:
4040
* `disk_operation_bytes_count`: # of Bytes used for reads/writes on this device
4141
* `disk_operation_time`: [# of milliseconds spent reading/writing][iostat doc]
4242
* `disk_bytes_used`: Disk usage in Bytes. The usage state is reported under the `state` metric label (e.g. `used`, `free`). Summing values of all states yields the disk size.
43+
FSType and MountOptions are also reported as additional information.
4344

4445
The name of the disk block device is reported in the `device_name` metric label (e.g. `sda`).
4546

pkg/systemstatsmonitor/disk_collector.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
145145
"Disk bytes used, in Bytes",
146146
"Byte",
147147
metrics.LastValue,
148-
[]string{deviceNameLabel, stateLabel})
148+
[]string{deviceNameLabel, fsTypeLabel, mountOptionLabel, stateLabel})
149149
if err != nil {
150150
glog.Fatalf("Error initializing metric for %q: %v", metrics.DiskBytesUsedID, err)
151151
}
@@ -276,8 +276,10 @@ func (dc *diskCollector) collect() {
276276
continue
277277
}
278278
deviceName := strings.TrimPrefix(partition.Device, "/dev/")
279-
dc.mBytesUsed.Record(map[string]string{deviceNameLabel: deviceName, stateLabel: "free"}, int64(usageStat.Free))
280-
dc.mBytesUsed.Record(map[string]string{deviceNameLabel: deviceName, stateLabel: "used"}, int64(usageStat.Used))
279+
fstype := partition.Fstype
280+
opttypes := partition.Opts
281+
dc.mBytesUsed.Record(map[string]string{deviceNameLabel: deviceName, fsTypeLabel: fstype, mountOptionLabel: opttypes, stateLabel: "free"}, int64(usageStat.Free))
282+
dc.mBytesUsed.Record(map[string]string{deviceNameLabel: deviceName, fsTypeLabel: fstype, mountOptionLabel: opttypes, stateLabel: "used"}, int64(usageStat.Used))
281283
}
282284

283285
}

pkg/systemstatsmonitor/labels.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ const directionLabel = "direction"
2424

2525
// stateLabel labels the state of disk/memory/cpu usage, e.g.: "free", "used".
2626
const stateLabel = "state"
27+
28+
// fsTypeLabel labels the fst type of the disk, e.g.: "ext4", "ext2", "vfat"
29+
const fsTypeLabel = "fstype"
30+
31+
// mountPointLabel labels the mountpoint of the monitored disk device
32+
const mountOptionLabel = "mountoption"

0 commit comments

Comments
 (0)