Skip to content

Conversation

@IbraAoad
Copy link
Contributor

@IbraAoad IbraAoad commented Feb 18, 2025

Issue

Node Exporter does not expose the system's virtualization state, limiting visibility into whether a host is running on bare metal or under virtualization.

Solution

This PR adds a new gauge metric with a label virtualization_type to indicate the system’s virtualization type (e.g., "kvm", "none", or "unknown"), retrieved via a DBus query from systemd.

Metric examples:

node_systemd_virtualization_info{virtualization_type="kvm"} 1 # actual virtualized system
node_systemd_virtualization_info{virtualization_type="none"} 1 # bare-metal
node_systemd_virtualization_info{virtualization_type="unknown"} 1 # the dbus query returned an error

Context

Systemd dbus allows querying system's virtualization via readonly s Virtualization.

For better reporting, empty string indicating bare-metal is mapped to none in this PR and dbus query errors are mapped to unkown.

Virtualization contains a short ID string describing the virtualization technology the system runs in. On bare-metal hardware this is the empty string, otherwise an identifier such as "kvm", "vmware" and so on. For a full list of IDs see systemd-detect-virt(1). Note that only the "innermost" virtualization technology is exported here. This detects both full-machine virtualizations (VMs) and shared-kernel virtualization (containers).

Testing

Manual testing was also performed on a multipass vm using KVM on linux with node-exporter running inside of it and systemd collector enabled ./node_exporter --collector.systemd

@IbraAoad IbraAoad force-pushed the add_virt_type branch 2 times, most recently from 5682be5 to 9755b52 Compare February 18, 2025 09:32
Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits.

@IbraAoad IbraAoad requested a review from SuperQ February 19, 2025 13:20
@IbraAoad
Copy link
Contributor Author

Hey @SuperQ,

Suggestion applied. When you have a moment, could you please take another look and let me know if everything looks good?, thanks a million!

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

IbraAoad and others added 6 commits February 20, 2025 17:27
Co-authored-by: Ben Kochie <[email protected]>
Signed-off-by: Ibrahim Awwad <[email protected]>
Signed-off-by: IbraAoad <[email protected]>
Signed-off-by: Mikel Olasagasti Uranga <[email protected]>
Signed-off-by: IbraAoad <[email protected]>
Signed-off-by: Alexander Soelberg Heidarsson <[email protected]>
Signed-off-by: IbraAoad <[email protected]>
@IbraAoad
Copy link
Contributor Author

Hey @SuperQ , Thanks a million, would it be possible to get this merged anytime you have a minute?

@SuperQ SuperQ merged commit 6cfb643 into prometheus:master Feb 23, 2025
13 checks passed
SuperQ added a commit that referenced this pull request Oct 22, 2025
* [CHANGE] mdadm: Use sysfs for RAID metrics #3031
* [CHANGE] filesystem: Add erofs in default excluded fs #3313
* [CHANGE] tcpstat: Use std lib binary.NativeEndian #3386
* [FEATURE] pcidevice: Add new collector for PCIe devices #3339
* [FEATURE] AIX: Add more metrics #3338
* [FEATURE] systemd: Add Virtualization metrics #3254
* [FEATURE] swaps: Add new collector #3428
* [ENHANCEMENT] filesystem: Take super options into account for read-only #3387
* [ENHANCEMENT] perf: Add tlb_data metrics #3436
* [BUGFIX] interrupts: Fix OpenBSD interrupt device parsing #3288
* [BUGFIX] diskstats: Simplify condition #3290
* [BUGFIX] thermal: Sanitize darwin thermal strings #3294
* [BUGFIX] filesystem: Fix Darwin collector cgo memory leak #3315
* [BUGFIX] ethtool: Fix returning 0 for sanitized metrics #3335
* [BUGFIX] netdev: Fix Darwin netdev i/o bytes metric #3336
* [BUGFIX] systemd: Fix logging race #3364
* [BUGFIX] filesystem: Fix duplicate Darwin CGO import #3391

Signed-off-by: Ben Kochie <[email protected]>
@SuperQ SuperQ mentioned this pull request Oct 22, 2025
SuperQ added a commit that referenced this pull request Oct 23, 2025
* [CHANGE] mdadm: Use sysfs for RAID metrics #3031
* [CHANGE] filesystem: Add erofs in default excluded fs #3313
* [CHANGE] tcpstat: Use std lib binary.NativeEndian #3386
* [FEATURE] pcidevice: Add new collector for PCIe devices #3339
* [FEATURE] AIX: Add more metrics #3338
* [FEATURE] systemd: Add Virtualization metrics #3254
* [FEATURE] swaps: Add new collector #3428
* [ENHANCEMENT] filesystem: Take super options into account for read-only #3387
* [ENHANCEMENT] perf: Add tlb_data metrics #3436
* [BUGFIX] interrupts: Fix OpenBSD interrupt device parsing #3288
* [BUGFIX] diskstats: Simplify condition #3290
* [BUGFIX] thermal: Sanitize darwin thermal strings #3294
* [BUGFIX] filesystem: Fix Darwin collector cgo memory leak #3315
* [BUGFIX] ethtool: Fix returning 0 for sanitized metrics #3335
* [BUGFIX] netdev: Fix Darwin netdev i/o bytes metric #3336
* [BUGFIX] systemd: Fix logging race #3364
* [BUGFIX] filesystem: Fix duplicate Darwin CGO import #3391

Signed-off-by: Ben Kochie <[email protected]>
SuperQ added a commit that referenced this pull request Oct 24, 2025
* [CHANGE] mdadm: Use sysfs for RAID metrics #3031
* [CHANGE] filesystem: Add erofs in default excluded fs #3313
* [CHANGE] tcpstat: Use std lib binary.NativeEndian #3386
* [FEATURE] pcidevice: Add new collector for PCIe devices #3339
* [FEATURE] AIX: Add more metrics #3338
* [FEATURE] systemd: Add Virtualization metrics #3254
* [FEATURE] swaps: Add new collector #3428
* [ENHANCEMENT] filesystem: Take super options into account for read-only #3387
* [ENHANCEMENT] perf: Add tlb_data metrics #3436
* [BUGFIX] interrupts: Fix OpenBSD interrupt device parsing #3288
* [BUGFIX] diskstats: Simplify condition #3290
* [BUGFIX] thermal: Sanitize darwin thermal strings #3294
* [BUGFIX] filesystem: Fix Darwin collector cgo memory leak #3315
* [BUGFIX] ethtool: Fix returning 0 for sanitized metrics #3335
* [BUGFIX] netdev: Fix Darwin netdev i/o bytes metric #3336
* [BUGFIX] systemd: Fix logging race #3364
* [BUGFIX] filesystem: Fix duplicate Darwin CGO import #3391

Signed-off-by: Ben Kochie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants