chore: Remove registry based perfdata collector (#1742)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2024-11-17 21:51:12 +01:00
committed by GitHub
parent 6206b695c6
commit e6a15d4ec4
213 changed files with 8079 additions and 12405 deletions

View File

@@ -10,7 +10,6 @@ import (
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus/client_golang/prometheus"
)
@@ -161,11 +160,7 @@ func (c *Collector) GetName() string {
return Name
}
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
return []string{}, nil
}
func (c *Collector) Close(_ *slog.Logger) error {
func (c *Collector) Close() error {
return nil
}
@@ -179,13 +174,13 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
buildSubsystemName := func(component string) string { return "hyperv_" + component }
c.healthCritical = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("health"), "critical"),
prometheus.BuildFQName("windows", buildSubsystemName("health"), "critical"),
"This counter represents the number of virtual machines with critical health",
nil,
nil,
)
c.healthOk = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("health"), "ok"),
prometheus.BuildFQName("windows", buildSubsystemName("health"), "ok"),
"This counter represents the number of virtual machines with ok health",
nil,
nil,
@@ -194,19 +189,19 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.physicalPagesAllocated = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vid"), "physical_pages_allocated"),
prometheus.BuildFQName("windows", buildSubsystemName("vid"), "physical_pages_allocated"),
"The number of physical pages allocated",
[]string{"vm"},
nil,
)
c.preferredNUMANodeIndex = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vid"), "preferred_numa_node_index"),
prometheus.BuildFQName("windows", buildSubsystemName("vid"), "preferred_numa_node_index"),
"The preferred NUMA node index associated with this partition",
[]string{"vm"},
nil,
)
c.remotePhysicalPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vid"), "remote_physical_pages"),
prometheus.BuildFQName("windows", buildSubsystemName("vid"), "remote_physical_pages"),
"The number of physical pages not allocated from the preferred NUMA node",
[]string{"vm"},
nil,
@@ -215,127 +210,127 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.addressSpaces = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "address_spaces"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "address_spaces"),
"The number of address spaces in the virtual TLB of the partition",
nil,
nil,
)
c.attachedDevices = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "attached_devices"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "attached_devices"),
"The number of devices attached to the partition",
nil,
nil,
)
c.depositedPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "deposited_pages"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "deposited_pages"),
"The number of pages deposited into the partition",
nil,
nil,
)
c.deviceDMAErrors = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "device_dma_errors"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "device_dma_errors"),
"An indicator of illegal DMA requests generated by all devices assigned to the partition",
nil,
nil,
)
c.deviceInterruptErrors = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "device_interrupt_errors"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "device_interrupt_errors"),
"An indicator of illegal interrupt requests generated by all devices assigned to the partition",
nil,
nil,
)
c.deviceInterruptMappings = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "device_interrupt_mappings"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "device_interrupt_mappings"),
"The number of device interrupt mappings used by the partition",
nil,
nil,
)
c.deviceInterruptThrottleEvents = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "device_interrupt_throttle_events"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "device_interrupt_throttle_events"),
"The number of times an interrupt from a device assigned to the partition was temporarily throttled because the device was generating too many interrupts",
nil,
nil,
)
c.gpaPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "preferred_numa_node_index"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "preferred_numa_node_index"),
"The number of pages present in the GPA space of the partition (zero for root partition)",
nil,
nil,
)
c.gpaSpaceModifications = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "gpa_space_modifications"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "gpa_space_modifications"),
"The rate of modifications to the GPA space of the partition",
nil,
nil,
)
c.ioTLBFlushCost = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "io_tlb_flush_cost"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "io_tlb_flush_cost"),
"The average time (in nanoseconds) spent processing an I/O TLB flush",
nil,
nil,
)
c.ioTLBFlushes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "io_tlb_flush"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "io_tlb_flush"),
"The rate of flushes of I/O TLBs of the partition",
nil,
nil,
)
c.recommendedVirtualTLBSize = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "recommended_virtual_tlb_size"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "recommended_virtual_tlb_size"),
"The recommended number of pages to be deposited for the virtual TLB",
nil,
nil,
)
c.skippedTimerTicks = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "physical_pages_allocated"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "physical_pages_allocated"),
"The number of timer interrupts skipped for the partition",
nil,
nil,
)
c.value1Gdevicepages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "1G_device_pages"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "1G_device_pages"),
"The number of 1G pages present in the device space of the partition",
nil,
nil,
)
c.value1GGPApages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "1G_gpa_pages"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "1G_gpa_pages"),
"The number of 1G pages present in the GPA space of the partition",
nil,
nil,
)
c.value2Mdevicepages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "2M_device_pages"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "2M_device_pages"),
"The number of 2M pages present in the device space of the partition",
nil,
nil,
)
c.value2MGPApages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "2M_gpa_pages"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "2M_gpa_pages"),
"The number of 2M pages present in the GPA space of the partition",
nil,
nil,
)
c.value4Kdevicepages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "4K_device_pages"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "4K_device_pages"),
"The number of 4K pages present in the device space of the partition",
nil,
nil,
)
c.value4KGPApages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "4K_gpa_pages"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "4K_gpa_pages"),
"The number of 4K pages present in the GPA space of the partition",
nil,
nil,
)
c.virtualTLBFlushEntires = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "virtual_tlb_flush_entires"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "virtual_tlb_flush_entires"),
"The rate of flushes of the entire virtual TLB",
nil,
nil,
)
c.virtualTLBPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("root_partition"), "virtual_tlb_pages"),
prometheus.BuildFQName("windows", buildSubsystemName("root_partition"), "virtual_tlb_pages"),
"The number of pages used by the virtual TLB of the partition",
nil,
nil,
@@ -344,13 +339,13 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.virtualProcessors = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("hypervisor"), "virtual_processors"),
prometheus.BuildFQName("windows", buildSubsystemName("hypervisor"), "virtual_processors"),
"The number of virtual processors present in the system",
nil,
nil,
)
c.logicalProcessors = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("hypervisor"), "logical_processors"),
prometheus.BuildFQName("windows", buildSubsystemName("hypervisor"), "logical_processors"),
"The number of logical processors present in the system",
nil,
nil,
@@ -359,19 +354,19 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.hostLPGuestRunTimePercent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("host_lp"), "guest_run_time_percent"),
prometheus.BuildFQName("windows", buildSubsystemName("host_lp"), "guest_run_time_percent"),
"The percentage of time spent by the processor in guest code",
[]string{"core"},
nil,
)
c.hostLPHypervisorRunTimePercent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("host_lp"), "hypervisor_run_time_percent"),
prometheus.BuildFQName("windows", buildSubsystemName("host_lp"), "hypervisor_run_time_percent"),
"The percentage of time spent by the processor in hypervisor code",
[]string{"core"},
nil,
)
c.hostLPTotalRunTimePercent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("host_lp"), "total_run_time_percent"),
prometheus.BuildFQName("windows", buildSubsystemName("host_lp"), "total_run_time_percent"),
"The percentage of time spent by the processor in guest and hypervisor code",
[]string{"core"},
nil,
@@ -380,31 +375,31 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.hostGuestRunTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("host_cpu"), "guest_run_time"),
prometheus.BuildFQName("windows", buildSubsystemName("host_cpu"), "guest_run_time"),
"The time spent by the virtual processor in guest code",
[]string{"core"},
nil,
)
c.hostHypervisorRunTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("host_cpu"), "hypervisor_run_time"),
prometheus.BuildFQName("windows", buildSubsystemName("host_cpu"), "hypervisor_run_time"),
"The time spent by the virtual processor in hypervisor code",
[]string{"core"},
nil,
)
c.hostRemoteRunTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("host_cpu"), "remote_run_time"),
prometheus.BuildFQName("windows", buildSubsystemName("host_cpu"), "remote_run_time"),
"The time spent by the virtual processor running on a remote node",
[]string{"core"},
nil,
)
c.hostTotalRunTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("host_cpu"), "total_run_time"),
prometheus.BuildFQName("windows", buildSubsystemName("host_cpu"), "total_run_time"),
"The time spent by the virtual processor in guest and hypervisor code",
[]string{"core"},
nil,
)
c.hostCPUWaitTimePerDispatch = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("host_cpu"), "wait_time_per_dispatch_total"),
prometheus.BuildFQName("windows", buildSubsystemName("host_cpu"), "wait_time_per_dispatch_total"),
"Time in nanoseconds waiting for a virtual processor to be dispatched onto a logical processor",
[]string{"core"},
nil,
@@ -413,31 +408,31 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.vmGuestRunTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_cpu"), "guest_run_time"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_cpu"), "guest_run_time"),
"The time spent by the virtual processor in guest code",
[]string{"vm", "core"},
nil,
)
c.vmHypervisorRunTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_cpu"), "hypervisor_run_time"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_cpu"), "hypervisor_run_time"),
"The time spent by the virtual processor in hypervisor code",
[]string{"vm", "core"},
nil,
)
c.vmRemoteRunTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_cpu"), "remote_run_time"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_cpu"), "remote_run_time"),
"The time spent by the virtual processor running on a remote node",
[]string{"vm", "core"},
nil,
)
c.vmTotalRunTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_cpu"), "total_run_time"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_cpu"), "total_run_time"),
"The time spent by the virtual processor in guest and hypervisor code",
[]string{"vm", "core"},
nil,
)
c.vmCPUWaitTimePerDispatch = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_cpu"), "wait_time_per_dispatch_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_cpu"), "wait_time_per_dispatch_total"),
"Time in nanoseconds waiting for a virtual processor to be dispatched onto a logical processor",
[]string{"vm", "core"},
nil,
@@ -445,127 +440,127 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.broadcastPacketsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "broadcast_packets_received_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "broadcast_packets_received_total"),
"This represents the total number of broadcast packets received per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.broadcastPacketsSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "broadcast_packets_sent_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "broadcast_packets_sent_total"),
"This represents the total number of broadcast packets sent per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.bytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "bytes_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "bytes_total"),
"This represents the total number of bytes per second traversing the virtual switch",
[]string{"vswitch"},
nil,
)
c.bytesReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "bytes_received_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "bytes_received_total"),
"This represents the total number of bytes received per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.bytesSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "bytes_sent_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "bytes_sent_total"),
"This represents the total number of bytes sent per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.directedPacketsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "directed_packets_received_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "directed_packets_received_total"),
"This represents the total number of directed packets received per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.directedPacketsSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "directed_packets_send_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "directed_packets_send_total"),
"This represents the total number of directed packets sent per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.droppedPacketsIncoming = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "dropped_packets_incoming_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "dropped_packets_incoming_total"),
"This represents the total number of packet dropped per second by the virtual switch in the incoming direction",
[]string{"vswitch"},
nil,
)
c.droppedPacketsOutgoing = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "dropped_packets_outcoming_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "dropped_packets_outcoming_total"),
"This represents the total number of packet dropped per second by the virtual switch in the outgoing direction",
[]string{"vswitch"},
nil,
)
c.extensionsDroppedPacketsIncoming = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "extensions_dropped_packets_incoming_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "extensions_dropped_packets_incoming_total"),
"This represents the total number of packet dropped per second by the virtual switch extensions in the incoming direction",
[]string{"vswitch"},
nil,
)
c.extensionsDroppedPacketsOutgoing = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "extensions_dropped_packets_outcoming_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "extensions_dropped_packets_outcoming_total"),
"This represents the total number of packet dropped per second by the virtual switch extensions in the outgoing direction",
[]string{"vswitch"},
nil,
)
c.learnedMacAddresses = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "learned_mac_addresses_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "learned_mac_addresses_total"),
"This counter represents the total number of learned MAC addresses of the virtual switch",
[]string{"vswitch"},
nil,
)
c.multicastPacketsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "multicast_packets_received_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "multicast_packets_received_total"),
"This represents the total number of multicast packets received per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.multicastPacketsSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "multicast_packets_sent_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "multicast_packets_sent_total"),
"This represents the total number of multicast packets sent per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.numberOfSendChannelMoves = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "number_of_send_channel_moves_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "number_of_send_channel_moves_total"),
"This represents the total number of send channel moves per second on this virtual switch",
[]string{"vswitch"},
nil,
)
c.numberOfVMQMoves = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "number_of_vmq_moves_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "number_of_vmq_moves_total"),
"This represents the total number of VMQ moves per second on this virtual switch",
[]string{"vswitch"},
nil,
)
c.packetsFlooded = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "packets_flooded_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "packets_flooded_total"),
"This counter represents the total number of packets flooded by the virtual switch",
[]string{"vswitch"},
nil,
)
c.packets = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "packets_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "packets_total"),
"This represents the total number of packets per second traversing the virtual switch",
[]string{"vswitch"},
nil,
)
c.packetsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "packets_received_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "packets_received_total"),
"This represents the total number of packets received per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.packetsSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "packets_sent_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "packets_sent_total"),
"This represents the total number of packets send per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.purgedMacAddresses = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vswitch"), "purged_mac_addresses_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vswitch"), "purged_mac_addresses_total"),
"This counter represents the total number of purged MAC addresses of the virtual switch",
[]string{"vswitch"},
nil,
@@ -574,37 +569,37 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.adapterBytesDropped = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("ethernet"), "bytes_dropped"),
prometheus.BuildFQName("windows", buildSubsystemName("ethernet"), "bytes_dropped"),
"Bytes Dropped is the number of bytes dropped on the network adapter",
[]string{"adapter"},
nil,
)
c.adapterBytesReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("ethernet"), "bytes_received"),
prometheus.BuildFQName("windows", buildSubsystemName("ethernet"), "bytes_received"),
"Bytes received is the number of bytes received on the network adapter",
[]string{"adapter"},
nil,
)
c.adapterBytesSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("ethernet"), "bytes_sent"),
prometheus.BuildFQName("windows", buildSubsystemName("ethernet"), "bytes_sent"),
"Bytes sent is the number of bytes sent over the network adapter",
[]string{"adapter"},
nil,
)
c.adapterFramesDropped = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("ethernet"), "frames_dropped"),
prometheus.BuildFQName("windows", buildSubsystemName("ethernet"), "frames_dropped"),
"Frames Dropped is the number of frames dropped on the network adapter",
[]string{"adapter"},
nil,
)
c.adapterFramesReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("ethernet"), "frames_received"),
prometheus.BuildFQName("windows", buildSubsystemName("ethernet"), "frames_received"),
"Frames received is the number of frames received on the network adapter",
[]string{"adapter"},
nil,
)
c.adapterFramesSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("ethernet"), "frames_sent"),
prometheus.BuildFQName("windows", buildSubsystemName("ethernet"), "frames_sent"),
"Frames sent is the number of frames sent over the network adapter",
[]string{"adapter"},
nil,
@@ -613,37 +608,37 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.vmStorageErrorCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_device"), "error_count"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_device"), "error_count"),
"This counter represents the total number of errors that have occurred on this virtual device",
[]string{"vm_device"},
nil,
)
c.vmStorageQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_device"), "queue_length"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_device"), "queue_length"),
"This counter represents the current queue length on this virtual device",
[]string{"vm_device"},
nil,
)
c.vmStorageReadBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_device"), "bytes_read"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_device"), "bytes_read"),
"This counter represents the total number of bytes that have been read per second on this virtual device",
[]string{"vm_device"},
nil,
)
c.vmStorageReadOperations = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_device"), "operations_read"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_device"), "operations_read"),
"This counter represents the number of read operations that have occurred per second on this virtual device",
[]string{"vm_device"},
nil,
)
c.vmStorageWriteBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_device"), "bytes_written"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_device"), "bytes_written"),
"This counter represents the total number of bytes that have been written per second on this virtual device",
[]string{"vm_device"},
nil,
)
c.vmStorageWriteOperations = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_device"), "operations_written"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_device"), "operations_written"),
"This counter represents the number of write operations that have occurred per second on this virtual device",
[]string{"vm_device"},
nil,
@@ -652,37 +647,37 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.vmStorageBytesReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_interface"), "bytes_received"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_interface"), "bytes_received"),
"This counter represents the total number of bytes received per second by the network adapter",
[]string{"vm_interface"},
nil,
)
c.vmStorageBytesSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_interface"), "bytes_sent"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_interface"), "bytes_sent"),
"This counter represents the total number of bytes sent per second by the network adapter",
[]string{"vm_interface"},
nil,
)
c.vmStorageDroppedPacketsIncoming = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_interface"), "packets_incoming_dropped"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_interface"), "packets_incoming_dropped"),
"This counter represents the total number of dropped packets per second in the incoming direction of the network adapter",
[]string{"vm_interface"},
nil,
)
c.vmStorageDroppedPacketsOutgoing = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_interface"), "packets_outgoing_dropped"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_interface"), "packets_outgoing_dropped"),
"This counter represents the total number of dropped packets per second in the outgoing direction of the network adapter",
[]string{"vm_interface"},
nil,
)
c.vmStoragePacketsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_interface"), "packets_received"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_interface"), "packets_received"),
"This counter represents the total number of packets received per second by the network adapter",
[]string{"vm_interface"},
nil,
)
c.vmStoragePacketsSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_interface"), "packets_sent"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_interface"), "packets_sent"),
"This counter represents the total number of packets sent per second by the network adapter",
[]string{"vm_interface"},
nil,
@@ -691,61 +686,61 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
//
c.vmMemoryAddedMemory = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_memory"), "added_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_memory"), "added_total"),
"This counter represents memory in MB added to the VM",
[]string{"vm"},
nil,
)
c.vmMemoryAveragePressure = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_memory"), "pressure_average"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_memory"), "pressure_average"),
"This gauge represents the average pressure in the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryCurrentPressure = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_memory"), "pressure_current"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_memory"), "pressure_current"),
"This gauge represents the current pressure in the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryGuestVisiblePhysicalMemory = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_memory"), "physical_guest_visible"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_memory"), "physical_guest_visible"),
"'This gauge represents the amount of memory in MB visible to the VM guest.'",
[]string{"vm"},
nil,
)
c.vmMemoryMaximumPressure = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_memory"), "pressure_maximum"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_memory"), "pressure_maximum"),
"This gauge represents the maximum pressure band in the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryMemoryAddOperations = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_memory"), "add_operations_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_memory"), "add_operations_total"),
"This counter represents the number of operations adding memory to the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryMemoryRemoveOperations = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_memory"), "remove_operations_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_memory"), "remove_operations_total"),
"This counter represents the number of operations removing memory from the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryMinimumPressure = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_memory"), "pressure_minimum"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_memory"), "pressure_minimum"),
"This gauge represents the minimum pressure band in the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryPhysicalMemory = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_memory"), "physical"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_memory"), "physical"),
"This gauge represents the current amount of memory in MB assigned to the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryRemovedMemory = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, buildSubsystemName("vm_memory"), "removed_total"),
prometheus.BuildFQName("windows", buildSubsystemName("vm_memory"), "removed_total"),
"This counter represents memory in MB removed from the VM",
[]string{"vm"},
nil,
@@ -756,101 +751,52 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
logger = logger.With(slog.String("collector", Name))
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
if err := c.collectVmHealth(ch); err != nil {
logger.Error("failed collecting hyperV health status metrics",
slog.Any("err", err),
)
return err
}
if err := c.collectVmVid(ch); err != nil {
logger.Error("failed collecting hyperV pages metrics",
slog.Any("err", err),
)
return err
}
if err := c.collectVmHv(ch); err != nil {
logger.Error("failed collecting hyperV hv status metrics",
slog.Any("err", err),
)
return err
}
if err := c.collectVmProcessor(ch); err != nil {
logger.Error("failed collecting hyperV processor metrics",
slog.Any("err", err),
)
return err
}
if err := c.collectHostLPUsage(logger, ch); err != nil {
logger.Error("failed collecting hyperV host logical processors metrics",
slog.Any("err", err),
)
if err := c.collectHostLPUsage(nil, ch); err != nil {
return err
}
if err := c.collectHostCpuUsage(logger, ch); err != nil {
logger.Error("failed collecting hyperV host CPU metrics",
slog.Any("err", err),
)
if err := c.collectHostCpuUsage(nil, ch); err != nil {
return err
}
if err := c.collectVmCpuUsage(logger, ch); err != nil {
logger.Error("failed collecting hyperV VM CPU metrics",
slog.Any("err", err),
)
if err := c.collectVmCpuUsage(nil, ch); err != nil {
return err
}
if err := c.collectVmSwitch(ch); err != nil {
logger.Error("failed collecting hyperV switch metrics",
slog.Any("err", err),
)
return err
}
if err := c.collectVmEthernet(ch); err != nil {
logger.Error("failed collecting hyperV ethernet metrics",
slog.Any("err", err),
)
return err
}
if err := c.collectVmStorage(ch); err != nil {
logger.Error("failed collecting hyperV virtual storage metrics",
slog.Any("err", err),
)
return err
}
if err := c.collectVmNetwork(ch); err != nil {
logger.Error("failed collecting hyperV virtual network metrics",
slog.Any("err", err),
)
return err
}
if err := c.collectVmMemory(ch); err != nil {
logger.Error("failed collecting hyperV virtual memory metrics",
slog.Any("err", err),
)
return err
}

View File

@@ -1,10 +1,12 @@
//go:build windows
package hyperv_test
import (
"testing"
"github.com/prometheus-community/windows_exporter/internal/collector/hyperv"
"github.com/prometheus-community/windows_exporter/internal/testutils"
"github.com/prometheus-community/windows_exporter/internal/utils/testutils"
)
func BenchmarkCollector(b *testing.B) {