From e13210157dd897ac37710a6e88144fe554a6b01c Mon Sep 17 00:00:00 2001 From: varsha teratipally Date: Wed, 5 Aug 2020 21:12:25 +0000 Subject: [PATCH 1/3] Add more info to disk metrics --- pkg/systemstatsmonitor/disk_collector.go | 8 +++++--- pkg/systemstatsmonitor/labels.go | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/systemstatsmonitor/disk_collector.go b/pkg/systemstatsmonitor/disk_collector.go index 6e4ba8591..7107baa6a 100644 --- a/pkg/systemstatsmonitor/disk_collector.go +++ b/pkg/systemstatsmonitor/disk_collector.go @@ -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) } @@ -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)) } } diff --git a/pkg/systemstatsmonitor/labels.go b/pkg/systemstatsmonitor/labels.go index 3b5c1858d..a75e39ee9 100644 --- a/pkg/systemstatsmonitor/labels.go +++ b/pkg/systemstatsmonitor/labels.go @@ -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" \ No newline at end of file From 4c40b7e46815eeba44857bf82697d2968a9da5be Mon Sep 17 00:00:00 2001 From: varsha teratipally Date: Wed, 5 Aug 2020 21:43:58 +0000 Subject: [PATCH 2/3] updated readme --- pkg/systemstatsmonitor/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/systemstatsmonitor/README.md b/pkg/systemstatsmonitor/README.md index c378a9105..30d94acb8 100644 --- a/pkg/systemstatsmonitor/README.md +++ b/pkg/systemstatsmonitor/README.md @@ -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`). From 50127b0512599f7f6f16af7b6a798edc693dc299 Mon Sep 17 00:00:00 2001 From: varsha teratipally Date: Thu, 6 Aug 2020 00:43:45 +0000 Subject: [PATCH 3/3] changed labelname after code review --- pkg/systemstatsmonitor/disk_collector.go | 6 +++--- pkg/systemstatsmonitor/labels.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/systemstatsmonitor/disk_collector.go b/pkg/systemstatsmonitor/disk_collector.go index 7107baa6a..3bab1528b 100644 --- a/pkg/systemstatsmonitor/disk_collector.go +++ b/pkg/systemstatsmonitor/disk_collector.go @@ -145,7 +145,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector "Disk bytes used, in Bytes", "Byte", metrics.LastValue, - []string{deviceNameLabel, fstypeLabel, mountOptionLabel, stateLabel}) + []string{deviceNameLabel, fsTypeLabel, mountOptionLabel, stateLabel}) if err != nil { glog.Fatalf("Error initializing metric for %q: %v", metrics.DiskBytesUsedID, err) } @@ -278,8 +278,8 @@ func (dc *diskCollector) collect() { deviceName := strings.TrimPrefix(partition.Device, "/dev/") 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)) + 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)) } } diff --git a/pkg/systemstatsmonitor/labels.go b/pkg/systemstatsmonitor/labels.go index a75e39ee9..e1133e60a 100644 --- a/pkg/systemstatsmonitor/labels.go +++ b/pkg/systemstatsmonitor/labels.go @@ -25,8 +25,8 @@ 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" +// 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" \ No newline at end of file +const mountOptionLabel = "mountoption"