windows_exporter icon indicating copy to clipboard operation
windows_exporter copied to clipboard

Add disk usage to container metrics

Open semaph0r opened this issue 6 years ago • 8 comments

I do have a use-case where I want to monitor the disk usage of containers.

Is there any possibility to get this added?

As far as I know, the Win32_LogicalDisk class is capable of providing such information. Nonetheless I am not sure if the hcsshim provides access to it or if there are any syscalls available inside vmcompute.dll which is used by container.go and hcsshim. Also the GetDiskFreeSpaceExW syscall is part of kernel32.dll and may be not suitable, to be integrated in wmi_exporter or hcsshim.

I developed a workaround executing powershell Get-PSDrive C | Select-Object Used,Free as command inside each container and parse the result. But, I am searching for a more clean an reliable solution.

semaph0r avatar May 15 '19 16:05 semaph0r

Hi @semaph0r, If you check the Win32_LogicalDisk class from the host via Powershell, are they listed there? If so, it should work out of the box. I don't have any systems running Windows containers yet, so I don't have a testbed I'm afraid.

In case the WMI system does not expose these, I think your best shot would be to use the textfile collector. Either continuing with the approach you have with powershell, or creating some utility to fetch it. It does not seem the hcsshim directly exposes anything about disk usage in the statistics interface we use, but it does expose the vhd paths (the virtual disks backing the container storage), which could be one possibility.

carlpett avatar May 15 '19 18:05 carlpett

Good points! I need some time to verify your options

semaph0r avatar May 17 '19 11:05 semaph0r

Hi @carlpett ,

I issued the above mentioned command inside my docker environment:

docker run mcr.microsoft.com/windows/servercore:1809 powershell "gwmi Win32_LogicalDisk"

This will respond as expected with:

DeviceID     : C:
DriveType    : 3
ProviderName :
FreeSpace    : 21182816256
Size         : 21339549696
VolumeName   :  

How can I integrate this query into the collector?

semaph0r avatar May 29 '19 06:05 semaph0r

Hi, Sorry if I was not clear - what I meant was if the containers disks show up if you run that query on the hosting machine itself (that is, not inside docker). The hope would be that it would list all disks mounted by all running containers there.

carlpett avatar May 29 '19 17:05 carlpett

@carlpett @sachinmsft hcshim's Statistics expose StorageStats about disk read/write. https://github.com/microsoft/hcsshim/blob/master/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema1/schema1.go#L188 can we expose disk read/write metric from the StorageStats?

szediktam avatar Feb 14 '22 13:02 szediktam

https://github.com/prometheus-community/windows_exporter/pull/943 I create a pr to collect storage metrics for windows-exporter. @carlpett @semaph0r

szediktam avatar Feb 16 '22 14:02 szediktam

#943 I create a pr to collect storage metrics for windows-exporter. @carlpett @semaph0r

@carlpett @sachinmsft This pr is already merged. windows_exporter will expose storage metrics for windows container(example metrics see #943) after v0.18.1. I thinks those metrics meet your needs. If so, this issue can be closed.

szediktam avatar Feb 27 '22 13:02 szediktam

/close

szediktam avatar Mar 09 '22 06:03 szediktam

This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

github-actions[bot] avatar Nov 25 '23 09:11 github-actions[bot]