Compare commits

..

1 Commits

Author SHA1 Message Date
renovate[bot]
d2aba6d6b9 chore(deps): update dependency golangci/golangci-lint to v2.10.1 2026-02-17 19:43:27 +00:00
8 changed files with 21 additions and 67 deletions

View File

@@ -21,7 +21,7 @@ jobs:
runs-on: windows-2025 runs-on: windows-2025
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with: with:
go-version-file: 'go.mod' go-version-file: 'go.mod'
@@ -44,7 +44,7 @@ jobs:
runs-on: windows-2025 runs-on: windows-2025
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with: with:
go-version-file: 'go.mod' go-version-file: 'go.mod'
@@ -83,7 +83,7 @@ jobs:
git config --global core.eol lf git config --global core.eol lf
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with: with:
go-version-file: 'go.mod' go-version-file: 'go.mod'
@@ -91,5 +91,5 @@ jobs:
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with: with:
# renovate: github=golangci/golangci-lint # renovate: github=golangci/golangci-lint
version: v2.7.2 version: v2.10.1
args: "--max-same-issues=0" args: "--max-same-issues=0"

View File

@@ -28,7 +28,7 @@ jobs:
with: with:
fetch-depth: '0' fetch-depth: '0'
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with: with:
go-version-file: 'go.mod' go-version-file: 'go.mod'

View File

@@ -11,7 +11,7 @@ jobs:
if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks.
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f # v10.2.0 - uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
# opt out of defaults to avoid marking issues as stale and closing them # opt out of defaults to avoid marking issues as stale and closing them

View File

@@ -11,7 +11,7 @@ jobs:
if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks.
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f # v10.2.0 - uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
# opt out of defaults to avoid marking issues as stale and closing them # opt out of defaults to avoid marking issues as stale and closing them

View File

@@ -154,11 +154,11 @@ Some metrics explained: https://learn.microsoft.com/en-us/archive/blogs/chrisavi
### Hyper-V Hypervisor Virtual Processor ### Hyper-V Hypervisor Virtual Processor
| Name | Description | Type | Labels | | Name | Description | Type | Labels |
|--------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|---------|-----------------------| |--------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|---------|--------------|
| `windows_hyperv_hypervisor_virtual_processor_mode_time_total` | Time that processor spent in different modes (hypervisor, guest_run, guest_idle, remote) | counter | `vm`, `core`, `state` | | `windows_hyperv_hypervisor_virtual_processor_time_total` | Time that processor spent in different modes (hypervisor, guest_run, guest_idle, remote) | counter | `vm`, `core` |
| `windows_hyperv_hypervisor_virtual_processor_run_time_total` | Time that processor spent | counter | `vm`, `core` | | `windows_hyperv_hypervisor_virtual_processor_total_run_time_total` | Time that processor spent | counter | `vm`, `core` |
| `windows_hyperv_hypervisor_virtual_processor_cpu_wait_time_per_dispatch_total` | The average time (in nanoseconds) spent waiting for a virtual processor to be dispatched onto a logical processor. | counter | `vm`, `core` | | `windows_hyperv_hypervisor_virtual_processor_cpu_wait_time_per_dispatch_total` | The average time (in nanoseconds) spent waiting for a virtual processor to be dispatched onto a logical processor. | counter | `vm`, `core` |
### Hyper-V Virtual Network Adapter ### Hyper-V Virtual Network Adapter
@@ -265,19 +265,19 @@ _This collector does not yet have explained examples, we would appreciate your h
## Useful queries ## Useful queries
Percent of physical CPU resources used per VM (on instance "localhost") Percent of physical CPU resources used per VM (on instance "localhost")
``` ```
(sum (rate(windows_hyperv_hypervisor_virtual_processor_mode_time_total{state="hypervisor",instance="localhost"}[1m]))) / ignoring(state,vm) group_left max (windows_cpu_logical_processor{instance="localhost"}) / 100000 (sum (rate(windows_hyperv_hypervisor_virtual_processor_time_total{state="hypervisor",instance="localhost"}[1m]))) / ignoring(state,vm) group_left max (windows_cpu_logical_processor{instance="localhost"}) / 100000
``` ```
Percent of physical CPU resources used by all VMs (on all monitored hosts) Percent of physical CPU resources used by all VMs (on all monitored hosts)
``` ```
(sum by (instance)(rate(windows_hyperv_hypervisor_virtual_processor_run_time_total{}[1m]))) / max by (instance)(windows_cpu_logical_processor{}) / 100000 (sum by (instance)(rate(windows_hyperv_hypervisor_virtual_processor_total_run_time_total{}[1m]))) / max by (instance)(windows_cpu_logical_processor{}) / 100000
``` ```
Percent of physical CPU resources by the hosts themselves (on all monitored hosts) Percent of physical CPU resources by the hosts themselves (on all monitored hosts)
``` ```
(sum by (instance)(rate(windows_hyperv_hypervisor_root_virtual_processor_time_total{state="total"}[1m]))) / sum by (instance)(windows_cpu_logical_processor{}) / 100000 (sum by (instance)(rate(windows_hyperv_hypervisor_root_virtual_processor_total_run_time_total{state="total"}[1m]))) / sum by (instance)(windows_cpu_logical_processor{}) / 100000
``` ```
Percent of physical CPU resources by the hypervisor (on all monitored hosts) Percent of physical CPU resources by the hypervisor (on all monitored hosts)
``` ```
(sum by (instance)(rate(windows_hyperv_hypervisor_logical_processor_time_total{}[1m]))) / sum by (instance)(windows_cpu_logical_processor{}) / 100000 (sum by (instance)(rate(windows_hyperv_hypervisor_logical_processor_total_run_time_total{}[1m]))) / sum by (instance)(windows_cpu_logical_processor{}) / 100000
``` ```
## Alerting examples ## Alerting examples

4
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/prometheus-community/windows_exporter module github.com/prometheus-community/windows_exporter
go 1.25.0 go 1.25
require ( require (
github.com/alecthomas/kingpin/v2 v2.4.0 github.com/alecthomas/kingpin/v2 v2.4.0
@@ -30,7 +30,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/procfs v0.20.0 // indirect github.com/prometheus/procfs v0.19.2 // indirect
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/crypto v0.48.0 // indirect golang.org/x/crypto v0.48.0 // indirect

4
go.sum
View File

@@ -52,8 +52,8 @@ github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTU
github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
github.com/prometheus/exporter-toolkit v0.15.1 h1:XrGGr/qWl8Gd+pqJqTkNLww9eG8vR/CoRk0FubOKfLE= github.com/prometheus/exporter-toolkit v0.15.1 h1:XrGGr/qWl8Gd+pqJqTkNLww9eG8vR/CoRk0FubOKfLE=
github.com/prometheus/exporter-toolkit v0.15.1/go.mod h1:P/NR9qFRGbCFgpklyhix9F6v6fFr/VQB/CVsrMDGKo4= github.com/prometheus/exporter-toolkit v0.15.1/go.mod h1:P/NR9qFRGbCFgpklyhix9F6v6fFr/VQB/CVsrMDGKo4=
github.com/prometheus/procfs v0.20.0 h1:AA7aCvjxwAquZAlonN7888f2u4IN8WVeFgBi4k82M4Q= github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws=
github.com/prometheus/procfs v0.20.0/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo= github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

View File

@@ -35,9 +35,7 @@ type collectorHypervisorVirtualProcessor struct {
// \Hyper-V Hypervisor Virtual Processor(*)\% Hypervisor Run Time // \Hyper-V Hypervisor Virtual Processor(*)\% Hypervisor Run Time
// \Hyper-V Hypervisor Virtual Processor(*)\% Remote Run Time // \Hyper-V Hypervisor Virtual Processor(*)\% Remote Run Time
hypervisorVirtualProcessorTimeTotal *prometheus.Desc hypervisorVirtualProcessorTimeTotal *prometheus.Desc
hypervisorVirtualProcessorModeTimeTotal *prometheus.Desc // New name for better clarity
hypervisorVirtualProcessorTotalRunTimeTotal *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\% Total Run Time hypervisorVirtualProcessorTotalRunTimeTotal *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\% Total Run Time
hypervisorVirtualProcessorRunTimeTotal *prometheus.Desc // New name for better clarity
hypervisorVirtualProcessorContextSwitches *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\CPU Wait Time Per Dispatch hypervisorVirtualProcessorContextSwitches *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\CPU Wait Time Per Dispatch
} }
@@ -61,32 +59,16 @@ func (c *Collector) buildHypervisorVirtualProcessor() error {
c.hypervisorVirtualProcessorTimeTotal = prometheus.NewDesc( c.hypervisorVirtualProcessorTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_time_total"), prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_time_total"),
"DEPRECATED: use hypervisor_virtual_processor_mode_time_total. Time that processor spent in different modes (hypervisor, guest_run, guest_idle, 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"),
"Time that processor spent in different modes (hypervisor, guest_run, guest_idle, remote)", "Time that processor spent in different modes (hypervisor, guest_run, guest_idle, remote)",
[]string{"vm", "core", "state"}, []string{"vm", "core", "state"},
nil, nil,
) )
// end same metric
c.hypervisorVirtualProcessorTotalRunTimeTotal = prometheus.NewDesc( c.hypervisorVirtualProcessorTotalRunTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_total_run_time_total"), prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_total_run_time_total"),
"DEPRECATED: use hypervisor_virtual_processor_run_time_total. Time that processor spent",
[]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"),
"Time that processor spent", "Time that processor spent",
[]string{"vm", "core"}, []string{"vm", "core"},
nil, nil,
) )
// end same metric
c.hypervisorVirtualProcessorContextSwitches = prometheus.NewDesc( c.hypervisorVirtualProcessorContextSwitches = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_cpu_wait_time_per_dispatch_total"), prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_cpu_wait_time_per_dispatch_total"),
"The average time (in nanoseconds) spent waiting for a virtual processor to be dispatched onto a logical processor.", "The average time (in nanoseconds) spent waiting for a virtual processor to be dispatched onto a logical processor.",
@@ -138,42 +120,14 @@ func (c *Collector) collectHypervisorVirtualProcessor(ch chan<- prometheus.Metri
data.HypervisorVirtualProcessorRemoteRunTimePercent, data.HypervisorVirtualProcessorRemoteRunTimePercent,
vmName, coreID, "remote", vmName, coreID, "remote",
) )
// Same metric with new name for better clarity, old one is kept for backward compatibility
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorModeTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorHypervisorRunTimePercent,
vmName, coreID, "hypervisor",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorModeTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorGuestRunTimePercent,
vmName, coreID, "guest",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorModeTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorRemoteRunTimePercent,
vmName, coreID, "remote",
)
// end same metric
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorTotalRunTimeTotal, c.hypervisorVirtualProcessorTotalRunTimeTotal,
prometheus.CounterValue, prometheus.CounterValue,
data.HypervisorVirtualProcessorTotalRunTimePercent, data.HypervisorVirtualProcessorTotalRunTimePercent,
vmName, coreID, vmName, coreID,
) )
// Same metric with new name for better clarity, old one is kept for backward compatibility
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorRunTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorTotalRunTimePercent,
vmName, coreID,
)
// end same metric
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorContextSwitches, c.hypervisorVirtualProcessorContextSwitches,
prometheus.CounterValue, prometheus.CounterValue,