collector: publish base units and _total counter names (#2743)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2026-10-16 10:48:26 +02:00
committed by GitHub
parent dc8092f46d
commit 3fb18521f6
131 changed files with 1674 additions and 1459 deletions
+2 -1
View File
@@ -44,7 +44,8 @@ memory) on a host with 12 logical processors.
`... count` counters are cumulative. The `... latency microseconds`
counters are not cumulative: `Commit operation latency microseconds` of the
configuration file dropped from 6659 to 5213 while `Commit operation count`
stayed 1.
stayed 1. The collector converts the latencies to seconds
(`..._latency_seconds`) and publishes the counts as `_total` counters.
- `Hyper-V VM Vid Partition`: pages are 4 KiB. The 2 GiB VM had 526336
`Physical Pages Allocated`.
- `Hyper-V Virtual Storage Device`: instances are the disk path with `\`
+57 -57
View File
@@ -229,187 +229,187 @@ func (c *Collector) buildDataStore() error {
nil,
)
c.dataStoreReconnectLatencyMicro = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_reconnect_latency_microseconds"),
"Represents the reconnect latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_reconnect_latency_seconds"),
"Represents the reconnect latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreDisconnectCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_disconnect_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_disconnects_total"),
"Represents the disconnect count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreWriteToFileByteLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_file_byte_latency_microseconds"),
"Represents the write to file byte latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_file_byte_latency_seconds"),
"Represents the write to file byte latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreWriteToFileByteCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_file_byte_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_file_bytes_total"),
"Represents the write to file byte count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreWriteToFileCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_file_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_file_operations_total"),
"Represents the write to file count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreReadFromFileByteLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_file_byte_latency_microseconds"),
"Represents the read from file byte latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_file_byte_latency_seconds"),
"Represents the read from file byte latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreReadFromFileByteCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_file_byte_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_file_bytes_total"),
"Represents the read from file byte count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreReadFromFileCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_file_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_file_operations_total"),
"Represents the read from file count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreWriteToStorageByteLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_storage_byte_latency_microseconds"),
"Represents the write to storage byte latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_storage_byte_latency_seconds"),
"Represents the write to storage byte latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreWriteToStorageByteCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_storage_byte_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_storage_bytes_total"),
"Represents the write to storage byte count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreWriteToStorageCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_storage_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_storage_operations_total"),
"Represents the write to storage count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreReadFromStorageByteLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_storage_byte_latency_microseconds"),
"Represents the read from storage byte latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_storage_byte_latency_seconds"),
"Represents the read from storage byte latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreReadFromStorageByteCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_storage_byte_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_storage_bytes_total"),
"Represents the read from storage byte count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreReadFromStorageCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_storage_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_storage_operations_total"),
"Represents the read from storage count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCommitByteLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_byte_latency_microseconds"),
"Represents the commit byte latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_byte_latency_seconds"),
"Represents the commit byte latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCommitByteCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_byte_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_bytes_total"),
"Represents the commit byte count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCommitCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_commits_total"),
"Represents the commit count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCacheUpdateOperationLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_cache_update_operation_latency_microseconds"),
"Represents the cache update operation latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_cache_update_operation_latency_seconds"),
"Represents the cache update operation latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCacheUpdateOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_cache_update_operation_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_cache_update_operations_total"),
"Represents the cache update operation count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCommitOperationLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_operation_latency_microseconds"),
"Represents the commit operation latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_operation_latency_seconds"),
"Represents the commit operation latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCommitOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_operation_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_operations_total"),
"Represents the commit operation count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCompactOperationLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_compact_operation_latency_microseconds"),
"Represents the compact operation latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_compact_operation_latency_seconds"),
"Represents the compact operation latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCompactOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_compact_operation_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_compact_operations_total"),
"Represents the compact operation count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreLoadFileOperationLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_load_file_operation_latency_microseconds"),
"Represents the load file operation latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_load_file_operation_latency_seconds"),
"Represents the load file operation latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreLoadFileOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_load_file_operation_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_load_file_operations_total"),
"Represents the load file operation count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreRemoveOperationLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_remove_operation_latency_microseconds"),
"Represents the remove operation latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_remove_operation_latency_seconds"),
"Represents the remove operation latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreRemoveOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_remove_operation_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_remove_operations_total"),
"Represents the remove operation count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreQuerySizeOperationLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_query_size_operation_latency_microseconds"),
"Represents the query size operation latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_query_size_operation_latency_seconds"),
"Represents the query size operation latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreQuerySizeOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_query_size_operation_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_query_size_operations_total"),
"Represents the query size operation count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreSetOperationLatencyMicro = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_set_operation_latency_microseconds"),
"Represents the set operation latency in microseconds of the DataStore.",
prometheus.BuildFQName(types.Namespace, Name, "datastore_set_operation_latency_seconds"),
"Represents the set operation latency in seconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreSetOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_set_operation_count"),
prometheus.BuildFQName(types.Namespace, Name, "datastore_set_operations_total"),
"Represents the set operation count of the DataStore.",
[]string{"datastore"},
nil,
@@ -533,7 +533,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreReconnectLatencyMicro,
prometheus.GaugeValue,
data.DataStoreReconnectLatencyMicro,
data.DataStoreReconnectLatencyMicro*1e-6,
data.Name,
)
@@ -547,7 +547,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreWriteToFileByteLatency,
prometheus.GaugeValue,
data.DataStoreWriteToFileByteLatency,
data.DataStoreWriteToFileByteLatency*1e-6,
data.Name,
)
@@ -568,7 +568,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreReadFromFileByteLatency,
prometheus.GaugeValue,
data.DataStoreReadFromFileByteLatency,
data.DataStoreReadFromFileByteLatency*1e-6,
data.Name,
)
@@ -589,7 +589,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreWriteToStorageByteLatency,
prometheus.GaugeValue,
data.DataStoreWriteToStorageByteLatency,
data.DataStoreWriteToStorageByteLatency*1e-6,
data.Name,
)
@@ -610,7 +610,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreReadFromStorageByteLatency,
prometheus.GaugeValue,
data.DataStoreReadFromStorageByteLatency,
data.DataStoreReadFromStorageByteLatency*1e-6,
data.Name,
)
@@ -631,7 +631,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreCommitByteLatency,
prometheus.GaugeValue,
data.DataStoreCommitByteLatency,
data.DataStoreCommitByteLatency*1e-6,
data.Name,
)
@@ -652,7 +652,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreCacheUpdateOperationLatency,
prometheus.GaugeValue,
data.DataStoreCacheUpdateOperationLatency,
data.DataStoreCacheUpdateOperationLatency*1e-6,
data.Name,
)
@@ -666,7 +666,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreCommitOperationLatency,
prometheus.GaugeValue,
data.DataStoreCommitOperationLatency,
data.DataStoreCommitOperationLatency*1e-6,
data.Name,
)
@@ -680,7 +680,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreCompactOperationLatency,
prometheus.GaugeValue,
data.DataStoreCompactOperationLatency,
data.DataStoreCompactOperationLatency*1e-6,
data.Name,
)
@@ -694,7 +694,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreLoadFileOperationLatency,
prometheus.GaugeValue,
data.DataStoreLoadFileOperationLatency,
data.DataStoreLoadFileOperationLatency*1e-6,
data.Name,
)
@@ -708,7 +708,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreRemoveOperationLatency,
prometheus.GaugeValue,
data.DataStoreRemoveOperationLatency,
data.DataStoreRemoveOperationLatency*1e-6,
data.Name,
)
@@ -722,7 +722,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreQuerySizeOperationLatency,
prometheus.GaugeValue,
data.DataStoreQuerySizeOperationLatency,
data.DataStoreQuerySizeOperationLatency*1e-6,
data.Name,
)
@@ -736,7 +736,7 @@ func (c *Collector) collectDataStore(ch chan<- prometheus.Metric, scrape *labelc
ch <- scrape.MustNewConstMetric(
c.dataStoreSetOperationLatencyMicro,
prometheus.GaugeValue,
data.DataStoreSetOperationLatencyMicro,
data.DataStoreSetOperationLatencyMicro*1e-6,
data.Name,
)
+3 -3
View File
@@ -87,21 +87,21 @@ func (c *Collector) buildHost() error {
}
c.vmProcessorCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vm_processor_count"),
prometheus.BuildFQName(types.Namespace, Name, "vm_processors"),
"Number of virtual processors assigned to the VM",
[]string{"vm_id", "vm"},
nil,
)
c.hostLogicalProcessorCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "host_logical_processor_count"),
prometheus.BuildFQName(types.Namespace, Name, "host_logical_processors"),
"Number of logical processors on the host",
nil,
nil,
)
c.totalVMProcessorCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "total_vm_processor_count"),
prometheus.BuildFQName(types.Namespace, Name, "assigned_vm_processors"),
"Total number of virtual processors assigned to all VMs",
nil,
nil,
@@ -59,13 +59,13 @@ func (c *Collector) buildHypervisorLogicalProcessor() error {
}
c.hypervisorLogicalProcessorTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_logical_processor_time_total"),
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_logical_processor_time_seconds_total"),
"Time that processor spent in different modes (hypervisor, guest, idle)",
[]string{"core", "state"},
nil,
)
c.hypervisorLogicalProcessorTotalRunTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_logical_processor_total_run_time_total"),
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_logical_processor_total_run_time_seconds_total"),
"Time that processor spent",
[]string{"core"},
nil,
@@ -174,37 +174,37 @@ func (c *Collector) buildHypervisorRootPartitionDescriptors() {
nil,
)
c.hypervisorRootPartition1GDevicePages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_1G_device_pages"),
prometheus.BuildFQName(types.Namespace, Name, "root_partition_1g_device_pages"),
"The number of 1G pages present in the device space of the partition",
nil,
nil,
)
c.hypervisorRootPartition1GGPAPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_1G_gpa_pages"),
prometheus.BuildFQName(types.Namespace, Name, "root_partition_1g_gpa_pages"),
"The number of 1G pages present in the GPA space of the partition",
nil,
nil,
)
c.hypervisorRootPartition2MDevicePages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_2M_device_pages"),
prometheus.BuildFQName(types.Namespace, Name, "root_partition_2m_device_pages"),
"The number of 2M pages present in the device space of the partition",
nil,
nil,
)
c.hypervisorRootPartition2MGPAPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_2M_gpa_pages"),
prometheus.BuildFQName(types.Namespace, Name, "root_partition_2m_gpa_pages"),
"The number of 2M pages present in the GPA space of the partition",
nil,
nil,
)
c.hypervisorRootPartition4KDevicePages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_4K_device_pages"),
prometheus.BuildFQName(types.Namespace, Name, "root_partition_4k_device_pages"),
"The number of 4K pages present in the device space of the partition",
nil,
nil,
)
c.hypervisorRootPartition4KGPAPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_4K_gpa_pages"),
prometheus.BuildFQName(types.Namespace, Name, "root_partition_4k_gpa_pages"),
"The number of 4K pages present in the GPA space of the partition",
nil,
nil,
@@ -71,14 +71,14 @@ func (c *Collector) buildHypervisorRootVirtualProcessor() error {
func (c *Collector) buildHypervisorRootVirtualProcessorDescriptors() {
c.hypervisorRootVirtualProcessorTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_root_virtual_processor_time_total"),
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_root_virtual_processor_time_seconds_total"),
"Time in seconds that processor spent in different modes (guest_run, hypervisor, remote)",
[]string{"core", "state"},
nil,
)
c.hypervisorRootVirtualProcessorTotalRunTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_root_virtual_processor_total_run_time_total"),
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_root_virtual_processor_total_run_time_seconds_total"),
"Time in seconds that processor spent running",
[]string{"core"},
nil,
@@ -35,12 +35,10 @@ type collectorHypervisorVirtualProcessor struct {
// \Hyper-V Hypervisor Virtual Processor(*)\% Guest Run Time
// \Hyper-V Hypervisor Virtual Processor(*)\% Hypervisor Run Time
// \Hyper-V Hypervisor Virtual Processor(*)\% Remote Run Time
hypervisorVirtualProcessorTimeTotal *prometheus.Desc
hypervisorVirtualProcessorModeTimeTotal *prometheus.Desc // New name for better clarity
hypervisorVirtualProcessorTotalRunTimeTotal *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\% Total Run Time
hypervisorVirtualProcessorRunTimeTotal *prometheus.Desc // New name for better clarity
hypervisorVirtualProcessorCPUWaitSeconds *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\CPU Wait Time Per Dispatch
hypervisorVirtualProcessorDispatches *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\Logical Processor Dispatches/sec
hypervisorVirtualProcessorModeTimeTotal *prometheus.Desc
hypervisorVirtualProcessorRunTimeTotal *prometheus.Desc
hypervisorVirtualProcessorCPUWaitSeconds *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\CPU Wait Time Per Dispatch
hypervisorVirtualProcessorDispatches *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\Logical Processor Dispatches/sec
}
type perfDataCounterValuesHypervisorVirtualProcessor struct {
@@ -72,34 +70,18 @@ func (c *Collector) buildHypervisorVirtualProcessor() error {
}
func (c *Collector) buildHypervisorVirtualProcessorDescriptors() {
c.hypervisorVirtualProcessorTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_time_total"),
"DEPRECATED: use hypervisor_virtual_processor_mode_time_total. Time in seconds that processor spent in different modes (hypervisor, guest, remote)",
[]string{"vm", "core", "state"},
nil,
)
// New metric with better name for clarity, old one is kept for backward compatibility
c.hypervisorVirtualProcessorModeTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_mode_time_total"),
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_mode_time_seconds_total"),
"Time in seconds that processor spent in different modes (hypervisor, guest, remote)",
[]string{"vm", "core", "state"},
nil,
)
// end same metric
c.hypervisorVirtualProcessorTotalRunTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_total_run_time_total"),
"DEPRECATED: use hypervisor_virtual_processor_run_time_total. Time in seconds that processor spent running",
[]string{"vm", "core"},
nil,
)
// New metric with better name for clarity, old one is kept for backward compatibility
c.hypervisorVirtualProcessorRunTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_run_time_total"),
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_run_time_seconds_total"),
"Time in seconds that processor spent running",
[]string{"vm", "core"},
nil,
)
// end same metric
c.hypervisorVirtualProcessorCPUWaitSeconds = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_cpu_wait_seconds_total"),
"The time spent waiting for a virtual processor to be dispatched onto a logical processor. "+
@@ -175,27 +157,6 @@ func (c *Collector) publishHypervisorVirtualProcessor(ch chan<- prometheus.Metri
vmName := data.Name
coreID := coreIDs[i]
ch <- scrape.MustNewConstMetric(
c.hypervisorVirtualProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorHypervisorRunTimePercent,
vmName, coreID, "hypervisor",
)
ch <- scrape.MustNewConstMetric(
c.hypervisorVirtualProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorGuestRunTimePercent,
vmName, coreID, "guest",
)
ch <- scrape.MustNewConstMetric(
c.hypervisorVirtualProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorRemoteRunTimePercent,
vmName, coreID, "remote",
)
// Same metric with new name for better clarity, old one is kept for backward compatibility
ch <- scrape.MustNewConstMetric(
c.hypervisorVirtualProcessorModeTimeTotal,
prometheus.CounterValue,
@@ -216,21 +177,14 @@ func (c *Collector) publishHypervisorVirtualProcessor(ch chan<- prometheus.Metri
data.HypervisorVirtualProcessorRemoteRunTimePercent,
vmName, coreID, "remote",
)
// end same metric
ch <- scrape.MustNewConstMetric(
c.hypervisorVirtualProcessorTotalRunTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorTotalRunTimePercent,
vmName, coreID,
)
// Same metric with new name for better clarity, old one is kept for backward compatibility
ch <- scrape.MustNewConstMetric(
c.hypervisorVirtualProcessorRunTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorTotalRunTimePercent,
vmName, coreID,
)
// end same metric
ch <- scrape.MustNewConstMetric(
c.hypervisorVirtualProcessorCPUWaitSeconds,
prometheus.CounterValue,
+21 -16
View File
@@ -38,7 +38,7 @@ func BenchmarkCollector(b *testing.B) {
func TestCollector(t *testing.T) {
metrics := testutils.TestCollector(t, hyperv.New, nil)
testutils.RequireFixtureMetric(t, metrics, hyperv.Name, "windows_hyperv_dynamic_memory_vm_physical_bytes", prometheus.Labels{"vm": "GitHubActions"})
testutils.RequireFixtureMetric(t, metrics, hyperv.Name, "windows_hyperv_vm_processor_count", prometheus.Labels{"vm": "GitHubActions"})
testutils.RequireFixtureMetric(t, metrics, hyperv.Name, "windows_hyperv_vm_processors", prometheus.Labels{"vm": "GitHubActions"})
// An empty "Hyper-V DataStore" counter set is tolerated as an optional
// instance group, so require a series explicitly (#2328).
@@ -58,28 +58,33 @@ func TestCollector(t *testing.T) {
}
}
// TestCollectorVirtualStorageDeviceLatency checks that the deprecated latency gauges
// expose the raw cumulative value in 100ns ticks of the *_io_latency_seconds_total counters.
// TestCollectorVirtualStorageDeviceLatency checks that the latencies are published
// as counters in seconds for every device, and that the removed gauges, which
// exposed the same raw value in 100ns ticks, are gone.
func TestCollectorVirtualStorageDeviceLatency(t *testing.T) {
metrics := testutils.TestCollector(t, hyperv.New, &hyperv.Config{CollectorsEnabled: []string{"virtual_storage_device"}})
for deprecated, replacement := range map[string]string{
"windows_hyperv_virtual_storage_device_latency_seconds": "windows_hyperv_virtual_storage_device_io_latency_seconds_total",
"windows_hyperv_virtual_storage_device_lower_latency_seconds": "windows_hyperv_virtual_storage_device_lower_io_latency_seconds_total",
} {
want := testutils.MetricValuesByLabel(metrics, deprecated, "device")
got := testutils.MetricValuesByLabel(metrics, replacement, "device")
devices := testutils.MetricValuesByLabel(metrics, "windows_hyperv_virtual_storage_device_throughput_total", "device")
require.Len(t, got, len(want))
for _, name := range []string{
"windows_hyperv_virtual_storage_device_io_latency_seconds_total",
"windows_hyperv_virtual_storage_device_lower_io_latency_seconds_total",
} {
got := testutils.MetricValuesByLabel(metrics, name, "device")
require.Len(t, got, len(devices), name)
if len(got) > 0 {
require.Equal(t, dto.MetricType_COUNTER, metrics[replacement].GetType())
require.Equal(t, dto.MetricType_COUNTER, metrics[name].GetType())
}
}
for device, ticks := range want {
require.Contains(t, got, device)
require.InDelta(t, ticks*pdh.TicksToSecondScaleFactor, got[device], 1e-6, "%s{device=%q}", replacement, device)
}
for _, removed := range []string{
"windows_hyperv_virtual_storage_device_latency_seconds",
"windows_hyperv_virtual_storage_device_lower_latency_seconds",
"windows_hyperv_virtual_storage_device_queue_length",
"windows_hyperv_virtual_storage_device_lower_queue_length",
} {
require.NotContains(t, metrics, removed)
}
}
@@ -118,7 +123,7 @@ func TestCollectorVirtualHardDisk(t *testing.T) {
if metric := testutils.RequireFixtureMetric(t, metrics, hyperv.Name, "windows_hyperv_virtual_hard_disk_size_bytes", labels); metric != nil {
device := labelValue(metric, "device")
require.NotEmpty(t, device, "the running VM's disk has no device")
require.Contains(t, testutils.MetricValuesByLabel(metrics, "windows_hyperv_virtual_storage_device_queue_length", "device"), device,
require.Contains(t, testutils.MetricValuesByLabel(metrics, "windows_hyperv_virtual_storage_device_throughput_total", "device"), device,
"device %q is not a virtual_storage_device instance", device)
}
@@ -51,8 +51,8 @@ func (c *Collector) buildVirtualMachineHealthSummary() error {
}
c.health = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_machine_health_total_count"),
"Represents the number of virtual machines with critical health",
prometheus.BuildFQName(types.Namespace, Name, "virtual_machines"),
"Number of virtual machines by health state",
[]string{"state"},
nil,
)
@@ -174,8 +174,8 @@ func (c *Collector) buildVirtualNetworkAdapterDropReasons() error {
}
c.virtualNetworkAdapterDropReasons = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_network_adapter_drop_reasons"),
"Hyper-V Virtual Network Adapter Drop Reasons",
prometheus.BuildFQName(types.Namespace, Name, "virtual_network_adapter_drop_reasons_total"),
"Number of packets dropped by a Hyper-V virtual network adapter, by drop reason and direction",
[]string{"adapter", "reason", "direction"},
nil,
)
+28 -28
View File
@@ -93,56 +93,56 @@ func (c *Collector) buildVirtualSMB() error {
nil,
)
c.virtualSMBWriteBytesRDMA = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_write_bytes_rdma"),
"Represents the number of bytes written per second using RDMA in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_rdma_write_bytes_total"),
"Represents the total number of bytes written using RDMA in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBWriteBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_write_bytes"),
"Represents the number of bytes written per second in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_write_bytes_total"),
"Represents the total number of bytes written in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBReadBytesRDMA = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_read_bytes_rdma"),
"Represents the number of bytes read per second using RDMA in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_rdma_read_bytes_total"),
"Represents the total number of bytes read using RDMA in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBReadBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_read_bytes"),
"Represents the number of bytes read per second in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_read_bytes_total"),
"Represents the total number of bytes read in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBFlushRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_flush_requests"),
"Represents the number of flush requests per second in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_flush_requests_total"),
"Represents the total number of flush requests in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBWriteRequestsRDMA = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_write_requests_rdma"),
"Represents the number of write requests per second using RDMA in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_rdma_write_requests_total"),
"Represents the total number of write requests using RDMA in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBWriteRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_write_requests"),
"Represents the number of write requests per second in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_write_requests_total"),
"Represents the total number of write requests in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBReadRequestsRDMA = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_read_requests_rdma"),
"Represents the number of read requests per second using RDMA in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_rdma_read_requests_total"),
"Represents the total number of read requests using RDMA in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBReadRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_read_requests"),
"Represents the number of read requests per second in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_read_requests_total"),
"Represents the total number of read requests in the virtual SMB",
[]string{"instance"},
nil,
)
@@ -153,32 +153,32 @@ func (c *Collector) buildVirtualSMB() error {
nil,
)
c.virtualSMBCurrentOpenFileCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_current_open_file_count"),
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_open_files"),
"Represents the current number of open files in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBTreeConnectCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_tree_connect_count"),
"Represents the number of tree connects in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_tree_connects_total"),
"Represents the total number of tree connects in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_requests"),
"Represents the number of requests per second in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_requests_total"),
"Represents the total number of requests in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBSentBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_sent_bytes"),
"Represents the number of bytes sent per second in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_sent_bytes_total"),
"Represents the total number of bytes sent in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBReceivedBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_received_bytes"),
"Represents the number of bytes received per second in the virtual SMB",
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_received_bytes_total"),
"Represents the total number of bytes received in the virtual SMB",
[]string{"instance"},
nil,
)
@@ -286,7 +286,7 @@ func (c *Collector) collectVirtualSMB(ch chan<- prometheus.Metric, scrape *label
ch <- scrape.MustNewConstMetric(
c.virtualSMBTreeConnectCount,
prometheus.GaugeValue,
prometheus.CounterValue,
data.VirtualSMBTreeConnectCount,
data.Name,
)
@@ -32,16 +32,12 @@ type collectorVirtualStorageDevice struct {
perfDataObjectVirtualStorageDevice []perfDataCounterValuesVirtualStorageDevice
virtualStorageDeviceErrorCount *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Error Count
virtualStorageDeviceQueueLength *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Queue Length
virtualStorageDeviceReadBytes *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Read Bytes/sec
virtualStorageDeviceReadOperations *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Read Operations/Sec
virtualStorageDeviceWriteBytes *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Write Bytes/sec
virtualStorageDeviceWriteOperations *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Write Operations/Sec
virtualStorageDeviceLatency *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Latency
virtualStorageDeviceThroughput *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Throughput
virtualStorageDeviceNormalizedThroughput *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Normalized Throughput
virtualStorageDeviceLowerQueueLength *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Lower Queue Length
virtualStorageDeviceLowerLatency *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Lower Latency
virtualStorageDeviceIOQuotaReplenishmentRate *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\IO Quota Replenishment Rate
virtualStorageDeviceIOLatency *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Latency
virtualStorageDeviceLowerIOLatency *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Lower Latency
@@ -51,7 +47,6 @@ type perfDataCounterValuesVirtualStorageDevice struct {
Name string
VirtualStorageDeviceErrorCount float64 `perfdata:"Error Count"`
VirtualStorageDeviceQueueLength float64 `perfdata:"Queue Length"`
VirtualStorageDeviceReadBytes float64 `perfdata:"Read Bytes/sec"`
VirtualStorageDeviceReadOperations float64 `perfdata:"Read Count"`
VirtualStorageDeviceWriteBytes float64 `perfdata:"Write Bytes/sec"`
@@ -59,7 +54,6 @@ type perfDataCounterValuesVirtualStorageDevice struct {
VirtualStorageDeviceLatency float64 `perfdata:"Latency"`
VirtualStorageDeviceThroughput float64 `perfdata:"Throughput"`
VirtualStorageDeviceNormalizedThroughput float64 `perfdata:"Normalized Throughput"`
VirtualStorageDeviceLowerQueueLength float64 `perfdata:"Lower Queue Length"`
VirtualStorageDeviceLowerLatency float64 `perfdata:"Lower Latency"`
VirtualStorageDeviceIOQuotaReplenishmentRate float64 `perfdata:"IO Quota Replenishment Rate"`
}
@@ -79,20 +73,13 @@ func (c *Collector) buildVirtualStorageDevice() error {
func (c *Collector) buildVirtualStorageDeviceDescriptors() {
c.virtualStorageDeviceErrorCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_error_count_total"),
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_errors_total"),
"Represents the total number of errors that have occurred on this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_queue_length"),
"DEPRECATED: use rate(windows_hyperv_virtual_storage_device_io_latency_seconds_total). "+
"Cumulative queue length in 100ns ticks, identical to the raw latency.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceReadBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_bytes_read"),
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_read_bytes_total"),
"Represents the total number of bytes that have been read on this virtual device.",
[]string{"device"},
nil,
@@ -104,7 +91,7 @@ func (c *Collector) buildVirtualStorageDeviceDescriptors() {
nil,
)
c.virtualStorageDeviceWriteBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_bytes_written"),
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_written_bytes_total"),
"Represents the total number of bytes that have been written on this virtual device.",
[]string{"device"},
nil,
@@ -115,13 +102,6 @@ func (c *Collector) buildVirtualStorageDeviceDescriptors() {
[]string{"device"},
nil,
)
c.virtualStorageDeviceLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_latency_seconds"),
"DEPRECATED: use windows_hyperv_virtual_storage_device_io_latency_seconds_total. "+
"Cumulative IO transfer latency in 100ns ticks for this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceThroughput = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_throughput_total"),
"Represents the total number of IO transfers completed by this virtual device.",
@@ -134,20 +114,6 @@ func (c *Collector) buildVirtualStorageDeviceDescriptors() {
[]string{"device"},
nil,
)
c.virtualStorageDeviceLowerQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_lower_queue_length"),
"DEPRECATED: use rate(windows_hyperv_virtual_storage_device_lower_io_latency_seconds_total). "+
"Cumulative queue length in 100ns ticks on the underlying storage subsystem, identical to the raw lower latency.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceLowerLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_lower_latency_seconds"),
"DEPRECATED: use windows_hyperv_virtual_storage_device_lower_io_latency_seconds_total. "+
"Cumulative IO transfer latency in 100ns ticks on the underlying storage subsystem for this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceIOLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_io_latency_seconds_total"),
"Represents the total IO transfer latency for this virtual device. "+
@@ -190,13 +156,6 @@ func (c *Collector) publishVirtualStorageDevice(ch chan<- prometheus.Metric, scr
data.Name,
)
ch <- scrape.MustNewConstMetric(
c.virtualStorageDeviceQueueLength,
prometheus.GaugeValue,
data.VirtualStorageDeviceQueueLength,
data.Name,
)
ch <- scrape.MustNewConstMetric(
c.virtualStorageDeviceReadBytes,
prometheus.CounterValue,
@@ -225,13 +184,6 @@ func (c *Collector) publishVirtualStorageDevice(ch chan<- prometheus.Metric, scr
data.Name,
)
ch <- scrape.MustNewConstMetric(
c.virtualStorageDeviceLatency,
prometheus.GaugeValue,
data.VirtualStorageDeviceLatency,
data.Name,
)
ch <- scrape.MustNewConstMetric(
c.virtualStorageDeviceThroughput,
prometheus.CounterValue,
@@ -246,20 +198,6 @@ func (c *Collector) publishVirtualStorageDevice(ch chan<- prometheus.Metric, scr
data.Name,
)
ch <- scrape.MustNewConstMetric(
c.virtualStorageDeviceLowerQueueLength,
prometheus.GaugeValue,
data.VirtualStorageDeviceLowerQueueLength,
data.Name,
)
ch <- scrape.MustNewConstMetric(
c.virtualStorageDeviceLowerLatency,
prometheus.GaugeValue,
data.VirtualStorageDeviceLowerLatency,
data.Name,
)
ch <- scrape.MustNewConstMetric(
c.virtualStorageDeviceIOQuotaReplenishmentRate,
prometheus.CounterValue,