windows_exporter
windows_exporter copied to clipboard
Adding Service name to processes if it exists
This is in response to #483
@carlpett Ready for review
Example:
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1172",service_display_name="Windows Time"} 5.431296e+06
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1180",service_display_name="Network Store Interface Service"} 1.0166272e+07
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="11804",service_display_name="Windows Push Notifications User Service_5ece1971"} 1.0788864e+07
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="12048",service_display_name="Connected Devices Platform User Service_740d56fd"} 6.98368e+06
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1248",service_display_name="Windows Connection Manager"} 6.30784e+06
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1256",service_display_name="Network Connection Broker"} 5.996544e+06
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1264",service_display_name="Time Broker"} 5.378048e+06
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1308",service_display_name="DHCP Client"} 6.639616e+06
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="13156",service_display_name="Windows Push Notifications User Service_72959979"} 1.0039296e+07
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1388",service_display_name="DNS Client"} 8.925184e+06
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1444",service_display_name="CoreMessaging"} 5.578752e+06
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1484",service_display_name="Storage Service"} 5.79584e+06
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="14856",service_display_name="Windows Push Notifications User Service_740d56fd"} 1.0170368e+07
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1536",service_display_name="Windows Event Log"} 3.3878016e+07
windows_process_page_file_bytes{creating_process_id="784",process="svchost",process_id="1644",service_display_name="Remote Desktop Services UserMode Port Redirector"} 6.41024e+06
Hey @BongoEADGC6, Thanks for the contribution! As mentioned in a comment, I'm a bit concerned about the performance implications here. What do you think?
@carlpett Understood, let me see what I can dig up.
@carlpett Sadly, I do no see a way to tie these things together via perflib. The other option that I can see is that we could utilize data from the service collector since that collector obtains the process id already.
This depends largely on the order in which the collectors run.
This depends largely on the order in which the collectors run.
Collectors are run asynchronously so collection order isn't deterministic :disappointed:
Okay, two other options:
- Direct integration with the Windows APIs, probably
EnumServicesStatusExA
- Some form of caching solution. You'd need to get all services at startup, but also fallback to querying again if a new one appears
The first one would be better in many ways (and we should then use it for the service collector as well), but does involve a bit more low-level work. You could have a look at #702 for some inspiration.
For what its worth I have an in-house branch that does this to satisfy a business requirement, I added a --collector.process.translate bool flag so if the service is found to be running as a service it returns the service name instead. It has not been an issue performance-wise and did not noticeably change the number of collector timeouts compared to control.
@1sttec that sounds interesting, would you be comfortable making the branch public?
@1sttec that sounds interesting, would you be comfortable making the branch public? https://github.com/prometheus-community/windows_exporter/pull/978
We did try
Closing due to age