-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add Windows metric for process handle counts #21379
Labels
Comments
braydonk
added
enhancement
New feature or request
needs triage
New item requiring triage
labels
May 1, 2023
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
braydonk
changed the title
Windows support for
Add Windows metric for process handle counts
May 26, 2023
process.open_file_descriptors
This was referenced May 26, 2023
dmitryax
pushed a commit
that referenced
this issue
Jun 27, 2023
**Description:** <Describe what has changed.> Adds a new Windows-exclusive metric called process.handles, which represents the handle count of the given process. When enabled, the receiver will make a WMI Query at the beginning of each scrape to update the handle count for all processes on the system. If the metric is enabled on a platform other than Windows, an error will be produced when attempting to refresh handle counts. This matches the rough behaviour of the Linux exclusive `process.open_file_descriptors`. **Link to tracking Issue:** <Issue number if applicable> #21379 #12482 **Testing:** <Describe what testing was performed and which tests were added.> Ran the binary with the following configuration: ``` receivers: hostmetrics: collection_interval: 2s scrapers: cpu: {} disk: {} filesystem: {} load: {} memory: {} network: {} paging: {} process: mute_process_name_error: true metrics: process.handles: enabled: true processes: {} exporters: file: path: x.json service: pipelines: metrics: receivers: [hostmetrics] exporters: [file] ``` The following is an example result of a scrape with this configuration. https://gist.github.com/braydonk/c97996272574319e03111dc79076a1bd
The |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Component(s)
receiver/hostmetrics
Is your feature request related to a problem? Please describe.
I would like a metric for a process' Handle Count in Windows.
Describe the solution you'd like
I would like to add a gauge metric in hostmetrics called
process.handles
, which represents the process' handle count at time of collection.Each scrape, the receiver would do a
NtQuerySystemInformation
syscall with the info classSystemProcessInformation
, which responds with information for all processes including each process' handle count. For each pid, we would get the handle count from the syscall results and record the datapoint.Describe alternatives you've considered
I have opened shirou/gopsutil#1455 with an accompanying example PR to implement this in
gopsutil
. This would bring this metric in-line with the implementation of all other process metrics, but this has 2 major issues:gopsutil
API is inflexible for a piece of process information that is exclusive to a single platform like this.NumFDs
is not the same as a process' handle count in Windows.Additional context
This StackExchange answer contains a good summary of what handles are in Windows: https://superuser.com/questions/1065826/handles-vs-threads-vs-processes
NtQuerySystemInformation syscall docs: https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntquerysysteminformation
Specifically this sections of the syscall docs is relevant: https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntquerysysteminformation#systemprocessinformation
The text was updated successfully, but these errors were encountered: