windows_exporter icon indicating copy to clipboard operation
windows_exporter copied to clipboard

windows_os_info not correct

Open flipp303 opened this issue 2 years ago • 1 comments

System: Windows 11 Exporter Version: 0.18.1 Problem: windows_os_info not correct

Hello,

in the Prometheus Browser / Targets / metrics my Windows 11 system appears as: product="Microsoft Windows 10 Pro", version="10.0.22000" classified. Am I doing something wrong??

best regards Thomas.

flipp303 avatar Jul 18 '22 20:07 flipp303

The os collector uses an API I'm unfamiliar with, unfortunately.

@benridley or @retryW are you able to provide troubleshooting steps for this collector?

breed808 avatar Jul 22 '22 23:07 breed808

my windows_exporter on windows 11 metrics also show up as win 10

# HELP windows_os_info OperatingSystem.Caption, OperatingSystem.Version
# TYPE windows_os_info gauge
windows_os_info{product="Microsoft Windows 10 Pro",version="10.0.22000"} 1

grenade avatar Aug 16 '22 08:08 grenade

Sorry all, have been traveling recently.

It looks like this information is read from the registry key SOFTWARE\Microsoft\Windows NT\CurrentVersion, which appears to be staying as Windows 10, major version 10, even with Windows 11. I'll see if I can find an alternative way of fetching this info.

benridley avatar Aug 16 '22 22:08 benridley

So I did some digging, and this appears to be a widely acknowledged issue. Unfortunately, the API calls and registry entries have not been updated to add a way to detect Windows 11.

Microsoft employees have apparently said:

At least for now, OS build number 22000 is the standard that distinguishes Windows 10 from Windows 11.

(from this StackOverflow answer)

We could potentially add in an exception that checks for this and corrects the value exported by windows_os_info for usability purposes, but I guess its worth acknowledging it would be a hack rather than a proper value exposed by the Windows API like the rest of those labels are.

benridley avatar Aug 19 '22 00:08 benridley

Keeping an incorrect human name and relying on a particular build number isn't a great user experience :disappointed:. Thanks for researching this one @benridley!

My preference would be to document this for the os collector and not perform any modifications to the value provided by Windows/Microsoft. We try to avoid "cooked" values with the exporter, instead presenting raw metrics to the user. The exporter providing a different value to the OS could be a cause of surprise for users in the future, though to be fair the current behaviour is already a surprise as proven by this thread.

Thoughts?

breed808 avatar Aug 20 '22 11:08 breed808

I agree @breed808, IMO it's better to keep the exporter 'pure' and move any handling for identifying Windows 11 up into the business logic of whatever is consuming the metrics.

One thing that might be worth doing though is exposing the major, minor, and build numbers as separate labels. Right now we concatenate them into a single version=maj.min.build label, but adding them as separate labels would make things a bit easier when searching for Windows 11+ hosts in PromQL queries and the like, e.g.

windows_os_info{version=10.0.22000} 1

would become

windows_os_info{version=10.0.22000, major_version=10, minor_version=0, build_number=22000} 1

I'm happy to make a PR for this if you agree it's worth doing for this use case.

benridley avatar Aug 22 '22 00:08 benridley

Sure, the proposed labels sound like a good option for users. Send through a PR and I'll get it merged.

breed808 avatar Aug 22 '22 21:08 breed808

Thanks @breed808, I've opened #1051 to address this one. Let me know if there's anything else I can do!

benridley avatar Aug 30 '22 05:08 benridley