Skip to content

Commit

Permalink
Merge pull request #452 from vteratipally/add_fstypes
Browse files Browse the repository at this point in the history
Add more info to disk metrics
  • Loading branch information
k8s-ci-robot authored Aug 7, 2020
2 parents c01ea4f + 50127b0 commit 860e6b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/systemstatsmonitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Below metrics are collected from `disk` component:
* `disk_operation_bytes_count`: # of Bytes used for reads/writes on this device
* `disk_operation_time`: [# of milliseconds spent reading/writing][iostat doc]
* `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.
FSType and MountOptions are also reported as additional information.

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

Expand Down
8 changes: 5 additions & 3 deletions pkg/systemstatsmonitor/disk_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
"Disk bytes used, in Bytes",
"Byte",
metrics.LastValue,
[]string{deviceNameLabel, stateLabel})
[]string{deviceNameLabel, fsTypeLabel, mountOptionLabel, stateLabel})
if err != nil {
glog.Fatalf("Error initializing metric for %q: %v", metrics.DiskBytesUsedID, err)
}
Expand Down Expand Up @@ -276,8 +276,10 @@ func (dc *diskCollector) collect() {
continue
}
deviceName := strings.TrimPrefix(partition.Device, "/dev/")
dc.mBytesUsed.Record(map[string]string{deviceNameLabel: deviceName, stateLabel: "free"}, int64(usageStat.Free))
dc.mBytesUsed.Record(map[string]string{deviceNameLabel: deviceName, stateLabel: "used"}, int64(usageStat.Used))
fstype := partition.Fstype
opttypes := partition.Opts
dc.mBytesUsed.Record(map[string]string{deviceNameLabel: deviceName, fsTypeLabel: fstype, mountOptionLabel: opttypes, stateLabel: "free"}, int64(usageStat.Free))
dc.mBytesUsed.Record(map[string]string{deviceNameLabel: deviceName, fsTypeLabel: fstype, mountOptionLabel: opttypes, stateLabel: "used"}, int64(usageStat.Used))
}

}
Expand Down
6 changes: 6 additions & 0 deletions pkg/systemstatsmonitor/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ const directionLabel = "direction"

// stateLabel labels the state of disk/memory/cpu usage, e.g.: "free", "used".
const stateLabel = "state"

// fsTypeLabel labels the fst type of the disk, e.g.: "ext4", "ext2", "vfat"
const fsTypeLabel = "fstype"

// mountPointLabel labels the mountpoint of the monitored disk device
const mountOptionLabel = "mountoption"

0 comments on commit 860e6b0

Please sign in to comment.