Compare commits

...

46 Commits

Author SHA1 Message Date
dependabot[bot]
4cd9627ebf chore(deps): bump golang.org/x/sys from 0.28.0 to 0.29.0 (#1825)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-01-07 10:07:25 +01:00
Jan-Otto Kröpke
81ea4c6223 performancecounter: fix panic with counter names having brackets (#1822)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-12-27 22:12:23 +01:00
Jan-Otto Kröpke
78386557d4 iis: fix panic (#1820)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-12-22 13:13:25 +01:00
Jan-Otto Kröpke
a9f8b3b722 process: Use registry collector for V1 data (#1814)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-12-21 22:58:47 +01:00
dependabot[bot]
39c929eefe chore(deps): bump github.com/prometheus/exporter-toolkit from 0.13.1 to 0.13.2 (#1815)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-16 12:36:11 +01:00
Jan-Otto Kröpke
eea5a50d5c performancecounter: support yaml documents and tolerate collector errors (#1809)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-12-09 19:14:26 +01:00
dependabot[bot]
a9698e27bf chore(deps): bump golang.org/x/sys from 0.27.0 to 0.28.0 (#1811)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-09 15:22:17 +01:00
dependabot[bot]
fac83b3c74 chore(deps): bump github.com/prometheus/common from 0.60.1 to 0.61.0 (#1810)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-09 15:21:43 +01:00
Jan-Otto Kröpke
0fc926c0b0 Update collector.performancecounter.md
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
2024-12-05 09:36:12 +01:00
Jan-Otto Kröpke
57a3e84cec process: fix metric labels for multiple process instances (#1804)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-12-03 18:31:41 +01:00
Jan-Otto Kröpke
2aebd5c2da process: fix metric labels for multiple process instances (#1803)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-12-03 12:07:03 +01:00
Jan-Otto Kröpke
109c34f572 chore: added tests (#1800)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-12-01 21:50:49 +01:00
Jan-Otto Kröpke
0ad8e01e0e mssql: add counter based on server version (#1799)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-12-01 18:20:44 +01:00
Jan-Otto Kröpke
3a3b50f898 chore: update deps (#1796)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-30 18:34:43 +01:00
Jan-Otto Kröpke
f5ff75ebc2 mssql: fix not collecting sql errors (#1793)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-30 13:10:11 +01:00
Jan-Otto Kröpke
71e5e5ec5f iis: Fix label for Default Web Site (#1792)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-30 13:02:00 +01:00
Jan-Otto Kröpke
40ff2f2e57 vmware: fix memory collector (#1791)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-30 12:13:35 +01:00
Jan-Otto Kröpke
9db94aa66a performancecounter: rename collector (#1787)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-30 11:24:01 +01:00
Jan-Otto Kröpke
a359acb3d1 logical_disk: fix volume access with limited permission (#1786)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-29 23:33:18 +01:00
Jan-Otto Kröpke
487de0c20b hyperv: Removed % Guest Idle Time performance counters (introduced in 0.30.0-beta.4) (#1785)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-29 22:19:22 +01:00
Jan-Otto Kröpke
aaa4ce07f6 system: BREAKING rename windows_system_system_up_time to windows_system_boot_time_timestamp_seconds (#1784)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-29 22:19:14 +01:00
Jan-Otto Kröpke
a2db81494e mssql: set windows_exporter_collector_success to 0, if errors occurs (#1777)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-27 00:14:53 +01:00
Jan-Otto Kröpke
64bf0a6551 collector: don't fail if perf counters are empty. (#1776)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-26 23:56:36 +01:00
Jan-Otto Kröpke
40b6f53479 textfile: set windows_exporter_collector_success to 0, if an errors occurs (#1775)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-26 23:47:23 +01:00
Jan-Otto Kröpke
ca04ad8fd2 fix: use log.file=eventlog as default value, if running as windows service (#1771)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-26 21:46:54 +01:00
Jan-Otto Kröpke
fd55ac4894 collector: refactor metrics handler (#1773)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-26 21:13:47 +01:00
Jan-Otto Kröpke
c8eeb595c0 feat: Support OpenMetrics (#1772)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-26 19:43:52 +01:00
Jan-Otto Kröpke
1a4c6c5ce7 feat: Tolerate collector failures (#1769)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-25 21:27:31 +01:00
dependabot[bot]
fd76be38e0 chore(deps): bump github.com/stretchr/testify from 1.9.0 to 1.10.0 (#1770)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-25 14:27:21 +01:00
Jan-Otto Kröpke
eff124250f chore: move exporter binary to cmd package (#1768)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-24 15:53:56 +01:00
Jan-Otto Kröpke
1badb34506 chore: fix copyright headers (#1767)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-24 14:11:14 +01:00
Jan-Otto Kröpke
f9e41294c3 mscluster: fix cluster and network sub collectors (#1759)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-24 13:57:19 +01:00
Jan-Otto Kröpke
86ace68978 msmq: Use Performance Counter instead WMI (#1766)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-24 13:38:24 +01:00
Jan-Otto Kröpke
e812584f27 smb: extend smb share metrics (#1765)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-24 13:18:14 +01:00
Jan-Otto Kröpke
1ecc340659 nps: refactor collector (#1764)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-24 11:38:36 +01:00
Jan-Otto Kröpke
4c0574536f collector: fix wrong perfdata instances (#1763)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-24 01:52:25 +01:00
Jan-Otto Kröpke
26d6dddf25 adfs: fix collector (#1761)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-24 00:39:38 +01:00
Jan-Otto Kröpke
75c6a4c182 collector: remove windows_exporter_perflib_snapshot_duration_seconds metric (#1760)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-22 21:10:00 +01:00
Jan-Otto Kröpke
a602d7be9d logical_disk: revert panic trigger on error (#1755)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-22 17:20:27 +01:00
Jan-Otto Kröpke
4534c2a6ae mssql: fix performance counter with additional server instance (#1753)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-21 22:52:30 +01:00
Jan-Otto Kröpke
3b378136f5 logical_disk: Get Volume ID for NTFS Volume Mounts (#1752)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-21 20:59:11 +01:00
Jan-Otto Kröpke
85845f4780 exchange: Extend Transport Queue metrics (#1749)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-20 02:05:31 +01:00
Jan-Otto Kröpke
fdee2d8613 hyperv: Refactor collector, added DataStore, Virtual SMB and Dynamic Memory Balancer metrics (click PR number for more information) (#1712)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-19 23:36:37 +01:00
Jan-Otto Kröpke
8c90961c10 mssql: expose server version info (#1741)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-19 23:35:55 +01:00
Jan-Otto Kröpke
2335fba18a logicaldisk: fix base counter values (#1747)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-19 21:35:32 +01:00
Jan-Otto Kröpke
c6ee794598 service: fixed buffer too low error (#1745)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2024-11-18 17:39:42 +01:00
315 changed files with 18009 additions and 10274 deletions

View File

@@ -23,4 +23,4 @@ jobs:
check_filenames: true
# When using this Action in other repos, the --skip option below can be removed
skip: ./.git,go.mod,go.sum
ignore_words_list: calle
ignore_words_list: calle,Entires

View File

@@ -11,7 +11,6 @@ linters:
- exportloopref
- fatcontext
- funlen
- gochecknoglobals
- gocognit
- goconst
- gocyclo
@@ -26,7 +25,10 @@ linters:
- wrapcheck
run:
timeout: 5m
timeout: 15m
output:
sort-results: true
linters-settings:
gosec:
@@ -85,7 +87,3 @@ issues:
- text: "don't use ALL_CAPS in Go names; use CamelCase"
linters:
- revive
- path: internal/perfdata/v1/
linters:
- godox
- stylecheck

View File

@@ -8,6 +8,7 @@ repository:
build:
binaries:
- name: windows_exporter
path: ./cmd/windows_exporter
tags:
all:
- trimpath

13
.run/all.run.xml Normal file
View File

@@ -0,0 +1,13 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="all" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="run">
<module name="windows_exporter" />
<working_directory value="$PROJECT_DIR$" />
<parameters value="--web.listen-address=127.0.0.1:9182 --log.level=info --collectors.enabled=ad,adcs,adfs,cache,container,cpu,cpu_info,cs,dfsr,dhcp,diskdrive,dns,exchange,filetime,fsrmquota,hyperv,iis,license,logical_disk,logon,memory,mscluster,msmq,mssql,net,netframework,nps,os,pagefile,performancecounter,physical_disk,printer,process,remote_fx,scheduled_task,service,smb,smbclient,smtp,system,tcp,terminal_services,thermalzone,time,udp,update,vmware,performancecounter --debug.enabled --collector.performancecounter.objects='[{ &quot;name&quot;: &quot;memory&quot;, &quot;object&quot;: &quot;Memory&quot;, &quot;counters&quot;: [{ &quot;name&quot;:&quot;Cache Faults/sec&quot;, &quot;type&quot;:&quot;counter&quot; }]}]'" />
<sudo value="true" />
<kind value="PACKAGE" />
<package value="github.com/prometheus-community/windows_exporter/cmd/windows_exporter" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/exporter.go" />
<method v="2" />
</configuration>
</component>

View File

@@ -42,7 +42,7 @@ Name | Description | Enabled by default
[net](docs/collector.net.md) | Network interface I/O | &#10003;
[os](docs/collector.os.md) | OS metrics (memory, processes, users) | &#10003;
[pagefile](docs/collector.pagefile.md) | pagefile metrics |
[perfdata](docs/collector.perfdata.md) | Custom perfdata metrics |
[performancecounter](docs/collector.performancecounter.md) | Custom performance counter metrics |
[physical_disk](docs/collector.physical_disk.md) | physical disk metrics | &#10003;
[printer](docs/collector.printer.md) | Printer metrics |
[process](docs/collector.process.md) | Per-process metrics |
@@ -199,6 +199,14 @@ Windows Server 2012 and 2012R2 are supported as best-effort only, but not guaran
The prometheus metrics will be exposed on [localhost:9182](http://localhost:9182)
### HTTP Endpoints
windows_exporter provides the following HTTP endpoints:
* `/metrics`: Exposes metrics in the [Prometheus text format](https://prometheus.io/docs/instrumenting/exposition_formats/).
* `/health`: Returns 200 OK when the exporter is running.
* `/debug/pprof/`: Exposes the [pprof](https://golang.org/pkg/net/http/pprof/) endpoints. Only, if `--debug.enabled` is set.
## Examples
### Enable only service collector and specify a custom query

195
cmd/windows_exporter/doc.go Normal file
View File

@@ -0,0 +1,195 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
The main package for the windows_exporter executable.
usage: windows_exporter [<flags>]
A metrics collector for Windows.
Flags:
-h, --[no-]help Show context-sensitive help (also try
--help-long and --help-man).
--config.file=CONFIG.FILE YAML configuration file to use. Values set in
this file will be overridden by CLI flags.
--[no-]config.file.insecure-skip-verify
Skip TLS verification in loading YAML
configuration.
--web.listen-address=:9182 ...
Addresses on which to expose metrics and web
interface. Repeatable for multiple addresses.
Examples: `:9100` or `[::1]:9100` for http,
`vsock://:9100` for vsock
--web.config.file="" Path to configuration file that can
enable TLS or authentication. See:
https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md
--telemetry.path="/metrics"
URL path for surfacing collected metrics.
--[no-]web.disable-exporter-metrics
Exclude metrics about the exporter itself
(promhttp_*, process_*, go_*).
--telemetry.max-requests=5
Maximum number of concurrent requests. 0 to
disable.
--collectors.enabled="cpu,cs,memory,logical_disk,physical_disk,net,os,service,system"
Comma-separated list of collectors to use.
Use '[defaults]' as a placeholder for all the
collectors enabled by default.
--scrape.timeout-margin=0.5
Seconds to subtract from the timeout allowed by
the client. Tune to allow for overhead or high
loads.
--[no-]debug.enabled If true, windows_exporter will expose debug
endpoints under /debug/pprof.
--process.priority="normal"
Priority of the exporter process. Higher
priorities may improve exporter responsiveness
during periods of system load. Can be one of
["realtime", "high", "abovenormal", "normal",
"belownormal", "low"]
--log.level=info Only log messages with the given severity or
above. One of: [debug, info, warn, error]
--log.format=logfmt Output format of log messages. One of: [logfmt,
json]
--log.file=stderr Output file of log messages. One of [stdout,
stderr, eventlog, <path to log file>]
--[no-]version Show application version.
--collector.scheduled_task.exclude=""
Regexp of tasks to exclude. Task path must
both match include and not match exclude to be
included.
--collector.scheduled_task.include=".+"
Regexp of tasks to include. Task path must
both match include and not match exclude to be
included.
--[no-]collector.updates.online
Whether to search for updates online.
--collector.updates.scrape-interval=6h0m0s
Define the interval of scraping Windows Update
information.
--[no-]collector.exchange.list
List the collectors along with their perflib
object name/ids
--collector.exchange.enabled="ADAccessProcesses,TransportQueues,HttpProxy,ActiveSync,AvailabilityService,OutlookWebAccess,Autodiscover,WorkloadManagement,RpcClientAccess,MapiHttpEmsmdb"
Comma-separated list of collectors to use.
Defaults to all, if not specified.
--collector.net.nic-exclude=""
Regexp of NIC:s to exclude. NIC name must
both match include and not match exclude to be
included.
--collector.net.nic-include=".+"
Regexp of NIC:s to include. NIC name must
both match include and not match exclude to be
included.
--collector.net.enabled="metrics,nic_addresses"
Comma-separated list of collectors to use.
Defaults to all, if not specified.
--collector.mscluster.enabled="cluster,network,node,resource,resourcegroup"
Comma-separated list of collectors to use.
--collector.mssql.enabled="accessmethods,availreplica,bufman,databases,dbreplica,genstats,locks,memmgr,sqlerrors,sqlstats,transactions,waitstats"
Comma-separated list of collectors to use.
--collector.mssql.port=1433
Port of MSSQL server used for
windows_mssql_info metric.
--collector.physical_disk.disk-exclude=""
Regexp of disks to exclude. Disk number must
both match include and not match exclude to be
included.
--collector.physical_disk.disk-include=".+"
Regexp of disks to include. Disk number must
both match include and not match exclude to be
included.
--collector.textfile.directories="C:\\Users\\Jan\\GolandProjects\\windows_exporter\\textfile_inputs"
Directory or Directories to read text files
with metrics from.
--collector.filetime.file-patterns=""
Comma-separated list of file patterns.
Each pattern is a glob pattern that can
contain `*`, `?`, and `**` (recursive). See
https://github.com/bmatcuk/doublestar#patterns
--collector.iis.app-exclude=""
Regexp of apps to exclude. App name must both
match include and not match exclude to be
included.
--collector.iis.app-include=".+"
Regexp of apps to include. App name must both
match include and not match exclude to be
included.
--collector.iis.site-exclude=""
Regexp of sites to exclude. Site name must
both match include and not match exclude to be
included.
--collector.iis.site-include=".+"
Regexp of sites to include. Site name must
both match include and not match exclude to be
included.
--collector.perfdata.objects=""
Objects of performance data to observe.
See docs for more information on how to use
this flag. By default, no objects are observed.
--collector.printer.include=".+"
Regular expression to match printers to collect
metrics for
--collector.printer.exclude=""
Regular expression to match printers to exclude
--collector.process.exclude=""
Regexp of processes to exclude. Process name
must both match include and not match exclude
to be included.
--collector.process.include=".+"
Regexp of processes to include. Process name
must both match include and not match exclude
to be included.
--[no-]collector.process.iis
Enable IIS worker process name queries.
May cause the collector to leak memory.
--collector.hyperv.enabled="datastore,dynamic_memory_balancer,dynamic_memory_vm,hypervisor_logical_processor,hypervisor_root_partition,hypervisor_root_virtual_processor,hypervisor_virtual_processor,legacy_network_adapter,virtual_machine_health_summary,virtual_machine_vid_partition,virtual_network_adapter,virtual_network_adapter_drop_reasons,virtual_smb,virtual_storage_device,virtual_switch"
Comma-separated list of collectors to use.
--collector.logical_disk.volume-exclude=""
Regexp of volumes to exclude. Volume name must
both match include and not match exclude to be
included.
--collector.logical_disk.volume-include=".+"
Regexp of volumes to include. Volume name must
both match include and not match exclude to be
included.
--collector.smtp.server-exclude=""
Regexp of virtual servers to exclude. Server
name must both match include and not match
exclude to be included.
--collector.smtp.server-include=".+"
Regexp of virtual servers to include. Server
name must both match include and not match
exclude to be included.
--collector.tcp.enabled="metrics,connections_state"
Comma-separated list of collectors to use.
Defaults to all, if not specified.
--collector.dfsr.sources-enabled="connection,folder,volume"
Comma-separated list of DFSR Perflib sources to
use.
--collector.service.exclude=""
Regexp of service to exclude. Service name (not
the display name!) must both match include and
not match exclude to be included.
--collector.service.include=".+"
Regexp of service to include. Process name (not
the display name!) must both match include and
not match exclude to be included.
--collector.time.enabled="system_time,ntp"
Comma-separated list of collectors to use.
Defaults to all, if not specified. ntp may not
available on all systems.
*/
package main

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
//go:generate go run github.com/tc-hib/go-winres@v0.3.3 make --product-version=git-tag --file-version=git-tag --arch=amd64,arm64
@@ -20,6 +33,7 @@ import (
"os/signal"
"os/user"
"runtime"
"runtime/debug"
"slices"
"strings"
"time"
@@ -29,6 +43,7 @@ import (
"github.com/prometheus-community/windows_exporter/internal/httphandler"
"github.com/prometheus-community/windows_exporter/internal/log"
"github.com/prometheus-community/windows_exporter/internal/log/flag"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus-community/windows_exporter/pkg/collector"
"github.com/prometheus/common/version"
"github.com/prometheus/exporter-toolkit/web"
@@ -51,6 +66,9 @@ func main() {
}
func run() int {
startTime := time.Now()
ctx := context.Background()
app := kingpin.New("windows_exporter", "A metrics collector for Windows.")
var (
@@ -71,10 +89,6 @@ func run() int {
"web.disable-exporter-metrics",
"Exclude metrics about the exporter itself (promhttp_*, process_*, go_*).",
).Bool()
maxRequests = app.Flag(
"telemetry.max-requests",
"Maximum number of concurrent requests. 0 to disable.",
).Default("5").Int()
enabledCollectors = app.Flag(
"collectors.enabled",
"Comma-separated list of collectors to use. Use '[defaults]' as a placeholder for all the collectors enabled by default.").
@@ -91,9 +105,20 @@ func run() int {
"process.priority",
"Priority of the exporter process. Higher priorities may improve exporter responsiveness during periods of system load. Can be one of [\"realtime\", \"high\", \"abovenormal\", \"normal\", \"belownormal\", \"low\"]",
).Default("normal").String()
memoryLimit = app.Flag(
"process.memory-limit",
"Limit memory usage in bytes. This is a soft-limit and not guaranteed. 0 means no limit. Read more at https://pkg.go.dev/runtime/debug#SetMemoryLimit .",
).Default("200000000").Int64()
)
logConfig := &log.Config{}
logFile := &log.AllowedFile{}
_ = logFile.Set("stdout")
if windowsservice.IsService {
_ = logFile.Set("eventlog")
}
logConfig := &log.Config{File: logFile}
flag.AddFlags(app, logConfig)
app.Version(version.Print("windows_exporter"))
@@ -113,6 +138,8 @@ func run() int {
return 1
}
debug.SetMemoryLimit(*memoryLimit)
logger, err := log.New(logConfig)
if err != nil {
//nolint:sloglint // we do not have an logger yet
@@ -124,7 +151,7 @@ func run() int {
}
if *configFile != "" {
resolver, err := config.NewResolver(*configFile, logger, *insecureSkipVerify)
resolver, err := config.NewResolver(ctx, *configFile, logger, *insecureSkipVerify)
if err != nil {
logger.Error("could not load config file",
slog.Any("err", err),
@@ -134,7 +161,7 @@ func run() int {
}
if err = resolver.Bind(app, os.Args[1:]); err != nil {
logger.Error("Failed to bind configuration",
logger.ErrorContext(ctx, "failed to bind configuration",
slog.Any("err", err),
)
@@ -148,7 +175,7 @@ func run() int {
// Parse flags once more to include those discovered in configuration file(s).
if _, err = app.Parse(os.Args[1:]); err != nil {
logger.Error("Failed to parse CLI args from YAML file",
logger.ErrorContext(ctx, "failed to parse CLI args from YAML file",
slog.Any("err", err),
)
@@ -166,7 +193,7 @@ func run() int {
}
}
logger.Debug("Logging has Started")
logger.LogAttrs(ctx, slog.LevelDebug, "logging has Started")
if err = setPriorityWindows(logger, os.Getpid(), *processPriority); err != nil {
logger.Error("failed to set process priority",
@@ -178,7 +205,7 @@ func run() int {
enabledCollectorList := expandEnabledCollectors(*enabledCollectors)
if err := collectors.Enable(enabledCollectorList); err != nil {
logger.Error("Couldn't enable collectors",
logger.Error("couldn't enable collectors",
slog.Any("err", err),
)
@@ -187,16 +214,18 @@ func run() int {
// Initialize collectors before loading
if err = collectors.Build(logger); err != nil {
logger.Error("Couldn't load collectors",
slog.Any("err", err),
)
for _, err := range utils.SplitError(err) {
logger.Error("couldn't initialize collector",
slog.Any("err", err),
)
return 1
return 1
}
}
logCurrentUser(logger)
logger.Info("Enabled collectors: " + strings.Join(enabledCollectorList, ", "))
logger.InfoContext(ctx, "Enabled collectors: "+strings.Join(enabledCollectorList, ", "))
mux := http.NewServeMux()
mux.Handle("GET /health", httphandler.NewHealthHandler())
@@ -204,7 +233,6 @@ func run() int {
mux.Handle("GET "+*metricsPath, httphandler.New(logger, collectors, &httphandler.Options{
DisableExporterMetrics: *disableExporterMetrics,
TimeoutMargin: *timeoutMargin,
MaxRequests: *maxRequests,
}))
if *debugEnabled {
@@ -215,7 +243,7 @@ func run() int {
mux.HandleFunc("GET /debug/pprof/trace", pprof.Trace)
}
logger.Info("Starting windows_exporter",
logger.LogAttrs(ctx, slog.LevelInfo, fmt.Sprintf("starting windows_exporter in %s", time.Since(startTime)),
slog.String("version", version.Version),
slog.String("branch", version.Branch),
slog.String("revision", version.GetRevision()),
@@ -242,7 +270,7 @@ func run() int {
close(errCh)
}()
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
ctx, stop := signal.NotifyContext(ctx, os.Interrupt, os.Kill)
defer stop()
select {
@@ -252,7 +280,7 @@ func run() int {
logger.Info("Shutting down windows_exporter via service control")
case err := <-errCh:
if err != nil {
logger.Error("Failed to start windows_exporter",
logger.ErrorContext(ctx, "Failed to start windows_exporter",
slog.Any("err", err),
)
@@ -265,7 +293,7 @@ func run() int {
_ = server.Shutdown(ctx)
logger.Info("windows_exporter has shut down")
logger.InfoContext(ctx, "windows_exporter has shut down")
return 0
}
@@ -306,7 +334,7 @@ func setPriorityWindows(logger *slog.Logger, pid int, priority string) error {
return nil
}
logger.Debug("setting process priority to " + priority)
logger.LogAttrs(context.Background(), slog.LevelDebug, "setting process priority to "+priority)
// https://learn.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights
handle, err := windows.OpenProcess(

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,56 @@
{
"RT_GROUP_ICON": {
"APP": {
"0000": [
"icon.png"
]
}
},
"RT_MANIFEST": {
"#1": {
"0409": {
"description": "A Prometheus exporter for Windows machines.",
"minimum-os": "win7",
"execution-level": "as invoker",
"ui-access": false,
"auto-elevate": false,
"dpi-awareness": "system",
"disable-theming": false,
"disable-window-filtering": false,
"high-resolution-scrolling-aware": false,
"ultra-high-resolution-scrolling-aware": false,
"long-path-aware": false,
"printer-driver-isolation": false,
"gdi-scaling": false,
"segment-heap": false,
"use-common-controls-v6": false
}
}
},
"RT_VERSION": {
"#1": {
"0000": {
"fixed": {
"file_version": "0.0.0.0",
"product_version": "0.0.0.0"
},
"info": {
"0409": {
"Comments": "",
"CompanyName": "Prometheus Community",
"FileDescription": "A Prometheus exporter for Windows machines.",
"FileVersion": "",
"InternalName": "windows_exporter",
"LegalCopyright": "",
"LegalTrademarks": "",
"OriginalFilename": "",
"PrivateBuild": "",
"ProductName": "windows_exporter",
"ProductVersion": "",
"SpecialBuild": ""
}
}
}
}
}
}

View File

@@ -1,9 +1,16 @@
# example configuration file for windows_exporter
collectors:
enabled: cpu,cpu_info,exchange,iis,logical_disk,logon,memory,net,os,process,remote_fx,service,system,tcp,time,terminal_services,textfile
enabled: cpu,cpu_info,exchange,iis,logical_disk,logon,memory,net,os,performancecounter,process,remote_fx,service,system,tcp,time,terminal_services,textfile
collector:
service:
include: "windows_exporter"
performancecounter:
objects: |-
- name: memory
object: "Memory"
counters:
- name: "Cache Faults/sec"
type: "counter" # optional
log:
level: warn

View File

@@ -18,6 +18,7 @@ This directory contains documentation of the collectors in the windows_exporter,
- [`fsrmquota`](collector.fsrmquota.md)
- [`hyperv`](collector.hyperv.md)
- [`iis`](collector.iis.md)
- [`license`](collector.license.md)
- [`logical_disk`](collector.logical_disk.md)
- [`logon`](collector.logon.md)
- [`memory`](collector.memory.md)
@@ -28,12 +29,16 @@ This directory contains documentation of the collectors in the windows_exporter,
- [`netframework`](collector.netframework.md)
- [`nps`](collector.nps.md)
- [`os`](collector.os.md)
- [`pagefile`](collector.pagefile.md)
- [`performancecounter`](collector.performancecounter.md)
- [`physical_disk`](collector.physical_disk.md)
- [`printer`](collector.printer.md)
- [`process`](collector.process.md)
- [`remote_fx`](collector.remote_fx.md)
- [`scheduled_task`](collector.scheduled_task.md)
- [`service`](collector.service.md)
- [`smb`](collector.smb.md)
- [`smbclient`](collector.smbclient.md)
- [`smtp`](collector.smtp.md)
- [`system`](collector.system.md)
- [`tcp`](collector.tcp.md)

View File

@@ -1,14 +1,13 @@
# exchange collector
The exchange collector collects metrics from MS Exchange hosts through perflib
The exchange collector collects metrics from MS Exchange hosts through Performance Counter
=======
|||
-|-
Metric name prefix | `exchange`
Classes | [Win32_PerfRawData_MSExchangeADAccess_MSExchangeADAccessProcesses](https://docs.microsoft.com/en-us/exchange/)<br/> [Win32_PerfRawData_MSExchangeTransportQueues_MSExchangeTransportQueues](https://docs.microsoft.com/en-us/exchange/)<br/> [Win32_PerfRawData_ESE_MSExchangeDatabaseInstances](https://docs.microsoft.com/en-us/exchange/)<br/> [Win32_PerfRawData_MSExchangeHttpProxy_MSExchangeHttpProxy](https://docs.microsoft.com/en-us/exchange/)<br/> [Win32_PerfRawData_MSExchangeActiveSync_MSExchangeActiveSync](https://docs.microsoft.com/en-us/exchange/)<br/> [Win32_PerfRawData_MSExchangeAvailabilityService_MSExchangeAvailabilityService](https://docs.microsoft.com/en-us/exchange/)<br/> [Win32_PerfRawData_MSExchangeOWA_MSExchangeOWA](https://docs.microsoft.com/en-us/exchange/)<br/> [Win32_PerfRawData_MSExchangeAutodiscover_MSExchangeAutodiscover](https://docs.microsoft.com/en-us/exchange/)<br/> [Win32_PerfRawData_MSExchangeWorkloadManagementWorkloads_MSExchangeWorkloadManagementWorkloads](https://docs.microsoft.com/en-us/exchange/)<br/> [Win32_PerfRawData_MSExchangeRpcClientAccess_MSExchangeRpcClientAccess](https://docs.microsoft.com/en-us/exchange/)<br/>
Enabled by default? | No
| | |
|---------------------|---------------------|
| Metric name prefix | `exchange` |
| Source | Performance Counter |
| Enabled by default? | No |
## Flags
@@ -19,45 +18,56 @@ Lists the Perflib Objects that are queried for data along with the perlfib objec
Comma-separated list of collectors to use, for example: `--collectors.exchange.enabled=AvailabilityService,OutlookWebAccess`. Matching is case-sensitive. Depending on the exchange installation not all performance counters are available. Use `--collectors.exchange.list` to obtain a list of supported collectors.
## Metrics
Name | Description
--------------|---------------
`windows_exchange_rpc_avg_latency_sec` | The latency (sec), averaged for the past 1024 packets
`windows_exchange_rpc_requests` | Number of client requests currently being processed by the RPC Client Access service
`windows_exchange_rpc_active_user_count` | Number of unique users that have shown some kind of activity in the last 2 minutes
`windows_exchange_rpc_connection_count` | Total number of client connections maintained
`windows_exchange_rpc_operations_total` | The rate at which RPC operations occur
`windows_exchange_rpc_user_count` | Number of users
`windows_exchange_ldap_read_time_sec` | Time (sec) to send an LDAP read request and receive a response
`windows_exchange_ldap_search_time_sec` | Time (sec) to send an LDAP search request and receive a response
`windows_exchange_ldap_write_time_sec` | Time (sec) to send an LDAP Add/Modify/Delete request and receive a response
`windows_exchange_ldap_timeout_errors_total` | Total number of LDAP timeout errors
`windows_exchange_ldap_long_running_ops_per_sec` | Long Running LDAP operations per second
`windows_exchange_transport_queues_external_active_remote_delivery` | External Active Remote Delivery Queue length
`windows_exchange_transport_queues_internal_active_remote_delivery` | Internal Active Remote Delivery Queue length
`windows_exchange_transport_queues_active_mailbox_delivery` | Active Mailbox Delivery Queue length
`windows_exchange_transport_queues_retry_mailbox_delivery` | Retry Mailbox Delivery Queue length
`windows_exchange_transport_queues_unreachable` | Unreachable Queue length
`windows_exchange_transport_queues_external_largest_delivery` | External Largest Delivery Queue length
`windows_exchange_transport_queues_internal_largest_delivery` | Internal Largest Delivery Queue length
`windows_exchange_transport_queues_poison` | Poison Queue length
`windows_exchange_http_proxy_mailbox_server_locator_avg_latency_sec` | Average latency (sec) of MailboxServerLocator web service calls
`windows_exchange_http_proxy_avg_auth_latency` | Average time spent authenticating CAS requests over the last 200 samples
`windows_exchange_http_proxy_outstanding_proxy_requests` | Number of concurrent outstanding proxy requests
`windows_exchange_http_proxy_requests_total` | Number of proxy requests processed each second
`windows_exchange_avail_service_requests_per_sec` | Number of requests serviced per second
`windows_exchange_owa_current_unique_users` | Number of unique users currently logged on to Outlook Web App
`windows_exchange_owa_requests_total` | Number of requests handled by Outlook Web App per second
`windows_exchange_autodiscover_requests_total` | Number of autodiscover service requests processed each second
`windows_exchange_workload_active_tasks` | Number of active tasks currently running in the background for workload management
`windows_exchange_workload_completed_tasks` | Number of workload management tasks that have been completed
`windows_exchange_workload_queued_tasks` | Number of workload management tasks that are currently queued up waiting to be processed
`windows_exchange_workload_yielded_tasks` | The total number of tasks that have been yielded by a workload
`windows_exchange_workload_is_active` | Active indicates whether the workload is in an active (1) or paused (0) state
`windows_exchange_activesync_requests_total` | Num HTTP requests received from the client via ASP.NET per sec. Shows Current user load
`windows_exchange_http_proxy_avg_cas_proccessing_latency_sec` | Average latency (sec) of CAS processing time over the last 200 reqs
`windows_exchange_http_proxy_mailbox_proxy_failure_rate` | % of failures between this CAS and MBX servers over the last 200 sample
`windows_exchange_activesync_ping_cmds_pending` | Number of ping commands currently pending in the queue
`windows_exchange_activesync_sync_cmds_total` | Number of sync commands processed per second. Clients use this command to synchronize items within a folder
| Name | Description |
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| `windows_exchange_rpc_avg_latency_sec` | The latency (sec), averaged for the past 1024 packets |
| `windows_exchange_rpc_requests` | Number of client requests currently being processed by the RPC Client Access service |
| `windows_exchange_rpc_active_user_count` | Number of unique users that have shown some kind of activity in the last 2 minutes |
| `windows_exchange_rpc_connection_count` | Total number of client connections maintained |
| `windows_exchange_rpc_operations_total` | The rate at which RPC operations occur |
| `windows_exchange_rpc_user_count` | Number of users |
| `windows_exchange_ldap_read_time_sec` | Time (sec) to send an LDAP read request and receive a response |
| `windows_exchange_ldap_search_time_sec` | Time (sec) to send an LDAP search request and receive a response |
| `windows_exchange_ldap_write_time_sec` | Time (sec) to send an LDAP Add/Modify/Delete request and receive a response |
| `windows_exchange_ldap_timeout_errors_total` | Total number of LDAP timeout errors |
| `windows_exchange_ldap_long_running_ops_per_sec` | Long Running LDAP operations per second |
| `windows_exchange_transport_queues_external_active_remote_delivery` | External Active Remote Delivery Queue length |
| `windows_exchange_transport_queues_internal_active_remote_delivery` | Internal Active Remote Delivery Queue length |
| `windows_exchange_transport_queues_active_mailbox_delivery` | Active Mailbox Delivery Queue length |
| `windows_exchange_transport_queues_retry_mailbox_delivery` | Retry Mailbox Delivery Queue length |
| `windows_exchange_transport_queues_unreachable` | Unreachable Queue length |
| `windows_exchange_transport_queues_external_largest_delivery` | External Largest Delivery Queue length |
| `windows_exchange_transport_queues_internal_largest_delivery` | Internal Largest Delivery Queue length |
| `windows_exchange_transport_queues_poison` | Poison Queue length |
| `windows_exchange_transport_queues_messages_queued_for_delivery_total` | Messages Queued For Delivery Total |
| `windows_exchange_transport_queues_messages_submitted_total` | Messages Submitted Total |
| `windows_exchange_transport_queues_messages_delayed_total` | Messages Delayed Total |
| `windows_exchange_transport_queues_messages_completed_delivery_total` | Messages Completed Delivery Total |
| `windows_exchange_transport_queues_shadow_queue_length` | Shadow Queue Length |
| `windows_exchange_transport_queues_submission_queue_length` | Submission Queue Length |
| `windows_exchange_transport_queues_delay_queue_length` | Delay Queue Length |
| `windows_exchange_transport_queues_items_completed_delivery_total` | Items Completed Delivery Total |
| `windows_exchange_transport_queues_items_queued_for_delivery_expired_total` | Items Queued For Delivery Expired Total |
| `windows_exchange_transport_queues_items_queued_for_delivery_total` | Items Queued For Delivery Total |
| `windows_exchange_transport_queues_items_resubmitted_total` | Items Resubmitted Total |
| `windows_exchange_http_proxy_mailbox_server_locator_avg_latency_sec` | Average latency (sec) of MailboxServerLocator web service calls |
| `windows_exchange_http_proxy_avg_auth_latency` | Average time spent authenticating CAS requests over the last 200 samples |
| `windows_exchange_http_proxy_outstanding_proxy_requests` | Number of concurrent outstanding proxy requests |
| `windows_exchange_http_proxy_requests_total` | Number of proxy requests processed each second |
| `windows_exchange_avail_service_requests_per_sec` | Number of requests serviced per second |
| `windows_exchange_owa_current_unique_users` | Number of unique users currently logged on to Outlook Web App |
| `windows_exchange_owa_requests_total` | Number of requests handled by Outlook Web App per second |
| `windows_exchange_autodiscover_requests_total` | Number of autodiscover service requests processed each second |
| `windows_exchange_workload_active_tasks` | Number of active tasks currently running in the background for workload management |
| `windows_exchange_workload_completed_tasks` | Number of workload management tasks that have been completed |
| `windows_exchange_workload_queued_tasks` | Number of workload management tasks that are currently queued up waiting to be processed |
| `windows_exchange_workload_yielded_tasks` | The total number of tasks that have been yielded by a workload |
| `windows_exchange_workload_is_active` | Active indicates whether the workload is in an active (1) or paused (0) state |
| `windows_exchange_activesync_requests_total` | Num HTTP requests received from the client via ASP.NET per sec. Shows Current user load |
| `windows_exchange_http_proxy_avg_cas_proccessing_latency_sec` | Average latency (sec) of CAS processing time over the last 200 reqs |
| `windows_exchange_http_proxy_mailbox_proxy_failure_rate` | % of failures between this CAS and MBX servers over the last 200 sample |
| `windows_exchange_activesync_ping_cmds_pending` | Number of ping commands currently pending in the queue |
| `windows_exchange_activesync_sync_cmds_total` | Number of sync commands processed per second. Clients use this command to synchronize items within a folder |
### Example metric
_This collector does not yet have explained examples, we would appreciate your help adding them!_

View File

@@ -2,110 +2,262 @@
The hyperv collector exposes metrics about the Hyper-V hypervisor
|||
-|-
Metric name prefix | `hyperv`
Classes | `Win32_PerfRawData_VmmsVirtualMachineStats_HyperVVirtualMachineHealthSummary`<br/>`Win32_PerfRawData_VidPerfProvider_HyperVVMVidPartition`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorRootPartition`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisor`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor`<br/>`Win32_PerfRawData_NvspSwitchStats_HyperVVirtualSwitch`<br/>`Win32_PerfRawData_EthernetPerfProvider_HyperVLegacyNetworkAdapter`<br/>`Win32_PerfRawData_Counters_HyperVVirtualStorageDevice`<br/>`Win32_PerfRawData_NvspNicStats_HyperVVirtualNetworkAdapter`
Enabled by default? | No
| | |
|---------------------|----------------------|
| Metric name prefix | `hyperv` |
| Source | Performance counters |
| Enabled by default? | No |
## Flags
None
### `--collectors.hyperv.enabled`
Comma-separated list of collectors to use, for example:
`--collectors.hyperv.enabled=dynamic_memory_balancer,dynamic_memory_vm,hypervisor_logical_processor,hypervisor_root_partition,hypervisor_root_virtual_processor,hypervisor_virtual_processor,legacy_network_adapter,virtual_machine_health_summary,virtual_machine_vid_partition,virtual_network_adapter,virtual_storage_device,virtual_switch`.
Matching is case-sensitive.
## Metrics
Name | Description | Type | Labels
-----|-------------|------|-------
`windows_hyperv_health_critical` | _Not yet documented_ | counter | None
`windows_hyperv_health_ok` | _Not yet documented_ | counter | None
`windows_hyperv_vid_physical_pages_allocated` | _Not yet documented_ | counter | `vm`
`windows_hyperv_vid_preferred_numa_node_index` | _Not yet documented_ | counter | `vm`
`windows_hyperv_vid_remote_physical_pages` | _Not yet documented_ | counter | `vm`
`windows_hyperv_root_partition_address_spaces` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_attached_devices` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_deposited_pages` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_device_dma_errors` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_device_interrupt_errors` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_device_interrupt_mappings` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_device_interrupt_throttle_events` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_preferred_numa_node_index` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_gpa_space_modifications` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_io_tlb_flush_cost` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_io_tlb_flush` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_recommended_virtual_tlb_size` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_physical_pages_allocated` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_1G_device_pages` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_1G_gpa_pages` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_2M_device_pages` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_2M_gpa_pages` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_4K_device_pages` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_4K_gpa_pages` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_virtual_tlb_flush_entires` | _Not yet documented_ | counter | None
`windows_hyperv_root_partition_virtual_tlb_pages` | _Not yet documented_ | counter | None
`windows_hyperv_hypervisor_virtual_processors` | _Not yet documented_ | counter | None
`windows_hyperv_hypervisor_logical_processors` | _Not yet documented_ | counter | None
`windows_hyperv_host_lp_guest_run_time_percent` | _Not yet documented_ | counter | `core`
`windows_hyperv_host_lp_hypervisor_run_time_percent` | _Not yet documented_ | counter | `core`
`windows_hyperv_host_lp_total_run_time_percent` | _Not yet documented_ | counter | `core`
`windows_hyperv_host_cpu_guest_run_time` | _Not yet documented_ | counter | `core`
`windows_hyperv_host_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `core`
`windows_hyperv_host_cpu_remote_run_time` | _Not yet documented_ | counter | `core`
`windows_hyperv_host_cpu_total_run_time` | _Not yet documented_ | counter | `core`
`windows_hyperv_host_cpu_wait_time_per_dispatch_total` | _Not yet documented_ | counter | `core`
`windows_hyperv_vm_cpu_guest_run_time` | _Not yet documented_ | counter | `vm`, `core`
`windows_hyperv_vm_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `vm`, `core`
`windows_hyperv_vm_cpu_remote_run_time` | _Not yet documented_ | counter | `vm`, `core`
`windows_hyperv_vm_cpu_wait_time_per_dispatch_total` | _Not yet documented_ | counter | `vm`, `core`
`windows_hyperv_vm_memory_added_total` | _Not yet documented_ | counter | `vm`
`windows_hyperv_vm_memory_pressure_average` | _Not yet documented_ | gauge | `vm`
`windows_hyperv_vm_memory_pressure_current` | _Not yet documented_ | counter | `vm`
`windows_hyperv_vm_memory_physical_guest_visible` | _Not yet documented_ | gauge | `vm`
`windows_hyperv_vm_memory_pressure_maximum` | _Not yet documented_ | gauge | `vm`
`windows_hyperv_vm_memory_add_operations_total` | _Not yet documented_ | counter | `vm`
`windows_hyperv_vm_memory_remove_operations_total` | _Not yet documented_ | counter | `vm`
`windows_hyperv_vm_memory_pressure_minumim` | _Not yet documented_ | gauge | `vm`
`windows_hyperv_vm_memory_physical` | _Not yet documented_ | gauge | `vm`
`windows_hyperv_vm_memory_removed_total` | _Not yet documented_ | counter | `vm`
`windows_hyperv_vm_cpu_total_run_time` | _Not yet documented_ | counter | `vm`, `core`
`windows_hyperv_vswitch_broadcast_packets_received_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_broadcast_packets_sent_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_bytes_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_bytes_received_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_bytes_sent_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_directed_packets_received_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_directed_packets_send_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_dropped_packets_incoming_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_dropped_packets_outcoming_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_extensions_dropped_packets_incoming_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_extensions_dropped_packets_outcoming_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_learned_mac_addresses_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_multicast_packets_received_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_multicast_packets_sent_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_number_of_send_channel_moves_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_number_of_vmq_moves_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_packets_flooded_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_packets_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_packets_received_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_packets_sent_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_vswitch_purged_mac_addresses_total` | _Not yet documented_ | counter | `vswitch`
`windows_hyperv_ethernet_bytes_dropped` | _Not yet documented_ | counter | `adapter`
`windows_hyperv_ethernet_bytes_received` | _Not yet documented_ | counter | `adapter`
`windows_hyperv_ethernet_bytes_sent` | _Not yet documented_ | counter | `adapter`
`windows_hyperv_ethernet_frames_dropped` | _Not yet documented_ | counter | `adapter`
`windows_hyperv_ethernet_frames_received` | _Not yet documented_ | counter | `adapter`
`windows_hyperv_ethernet_frames_sent` | _Not yet documented_ | counter | `adapter`
`windows_hyperv_vm_device_error_count` | _Not yet documented_ | counter | `vm_device`
`windows_hyperv_vm_device_queue_length` | _Not yet documented_ | counter | `vm_device`
`windows_hyperv_vm_device_bytes_read` | _Not yet documented_ | counter | `vm_device`
`windows_hyperv_vm_device_operations_read` | _Not yet documented_ | counter | `vm_device`
`windows_hyperv_vm_device_bytes_written` | _Not yet documented_ | counter | `vm_device`
`windows_hyperv_vm_device_operations_written` | _Not yet documented_ | counter | `vm_device`
`windows_hyperv_vm_interface_bytes_received` | _Not yet documented_ | counter | `vm_interface`
`windows_hyperv_vm_interface_bytes_sent` | _Not yet documented_ | counter | `vm_interface`
`windows_hyperv_vm_interface_packets_incoming_dropped` | _Not yet documented_ | counter | `vm_interface`
`windows_hyperv_vm_interface_packets_outgoing_dropped` | _Not yet documented_ | counter | `vm_interface`
`windows_hyperv_vm_interface_packets_received` | _Not yet documented_ | counter | `vm_interface`
`windows_hyperv_vm_interface_packets_sent` | _Not yet documented_ | counter | `vm_interface`
### Hyper-V Datastore
### Hyper-V Datastore Metrics Documentation
This documentation outlines the available metrics for monitoring Hyper-V Datastore performance and resource usage using Prometheus. All metrics are prefixed with `windows_hyperv_datastore`.
| Metric Name | Description | Type | Labels |
|------------------------------------------------------------------------|---------------------------------------------------------------------------------|---------|-----------|
| `windows_hyperv_datastore_fragmentation_ratio` | Represents the fragmentation ratio of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_sector_size_bytes` | Represents the sector size of the DataStore in bytes. | gauge | datastore |
| `windows_hyperv_datastore_data_alignment_bytes` | Represents the data alignment of the DataStore in bytes. | gauge | datastore |
| `windows_hyperv_datastore_current_replay_log_size_bytes` | Represents the current replay log size of the DataStore in bytes. | gauge | datastore |
| `windows_hyperv_datastore_available_entries` | Represents the number of available entries inside object tables. | gauge | datastore |
| `windows_hyperv_datastore_empty_entries` | Represents the number of empty entries inside object tables. | gauge | datastore |
| `windows_hyperv_datastore_free_bytes` | Represents the number of free bytes inside key tables. | gauge | datastore |
| `windows_hyperv_datastore_data_end_bytes` | Represents the data end of the DataStore in bytes. | gauge | datastore |
| `windows_hyperv_datastore_file_objects` | Represents the number of file objects in the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_object_tables` | Represents the number of object tables in the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_key_tables` | Represents the number of key tables in the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_file_data_size_bytes` | Represents the file data size in bytes of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_table_data_size_bytes` | Represents the table data size in bytes of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_names_size_bytes` | Represents the names size in bytes of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_number_of_keys` | Represents the number of keys in the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_reconnect_latency_microseconds` | Represents the reconnect latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_disconnect_count` | Represents the disconnect count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_write_to_file_byte_latency_microseconds` | Represents the write-to-file byte latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_write_to_file_byte_count` | Represents the write-to-file byte count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_write_to_file_count` | Represents the write-to-file count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_read_from_file_byte_latency_microseconds` | Represents the read-from-file byte latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_read_from_file_byte_count` | Represents the read-from-file byte count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_read_from_file_count` | Represents the read-from-file count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_write_to_storage_byte_latency_microseconds` | Represents the write-to-storage byte latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_write_to_storage_byte_count` | Represents the write-to-storage byte count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_write_to_storage_count` | Represents the write-to-storage count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_read_from_storage_byte_latency_microseconds` | Represents the read-from-storage byte latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_read_from_storage_byte_count` | Represents the read-from-storage byte count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_read_from_storage_count` | Represents the read-from-storage count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_commit_byte_latency_microseconds` | Represents the commit byte latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_commit_byte_count` | Represents the commit byte count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_commit_count` | Represents the commit count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_cache_update_operation_latency_microseconds` | Represents the cache update operation latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_cache_update_operation_count` | Represents the cache update operation count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_commit_operation_latency_microseconds` | Represents the commit operation latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_commit_operation_count` | Represents the commit operation count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_compact_operation_latency_microseconds` | Represents the compact operation latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_compact_operation_count` | Represents the compact operation count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_load_file_operation_latency_microseconds` | Represents the load file operation latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_load_file_operation_count` | Represents the load file operation count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_remove_operation_latency_microseconds` | Represents the remove operation latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_remove_operation_count` | Represents the remove operation count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_query_size_operation_latency_microseconds` | Represents the query size operation latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_query_size_operation_count` | Represents the query size operation count of the DataStore. | counter | datastore |
| `windows_hyperv_datastore_set_operation_latency_microseconds` | Represents the set operation latency in microseconds of the DataStore. | gauge | datastore |
| `windows_hyperv_datastore_set_operation_count` | Represents the set operation count of the DataStore. | counter | datastore |
### Hyper-V Dynamic Memory Balancer
Some metrics explained: https://learn.microsoft.com/en-us/archive/blogs/chrisavis/monitoring-dynamic-memory-in-windows-server-hyper-v-2012
| Name | Description | Type | Labels |
|-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|-------|------------|
| `windows_hyperv_dynamic_memory_balancer_available_memory_bytes` | Represents the amount of memory left on the node. | gauge | `balancer` |
| `windows_hyperv_dynamic_memory_balancer_available_memory_for_balancing_bytes` | Represents the available memory for balancing purposes. | gauge | `balancer` |
| `windows_hyperv_dynamic_memory_balancer_average_pressure_ratio` | Represents the average system pressure on the balancer node among all balanced objects. | gauge | `balancer` |
| `windows_hyperv_dynamic_memory_balancer_system_current_pressure_ratio` | Represents the current pressure in the system. | gauge | `balancer` |
### Hyper-V Dynamic Memory VM
| Name | Description | Type | Labels |
|------------------------------------------------------------------------|-----------------------------------------------------------------------------------|---------|--------|
| `windows_hyperv_dynamic_memory_vm_added_bytes_total` | Represents the cumulative amount of memory added to the VM. | counter | `vm` |
| `windows_hyperv_dynamic_memory_vm_pressure_current_ratio` | Represents the current pressure in the VM. | gauge | `vm` |
| `windows_hyperv_dynamic_memory_vm_guest_available_bytes` | Represents the current amount of available memory in the VM (reported by the VM). | gauge | `vm` |
| `windows_hyperv_dynamic_memory_vm_guest_visible_physical_memory_bytes` | Represents the amount of memory visible in the VM | gauge | `vm` |
| `windows_hyperv_dynamic_memory_vm_pressure_maximum_ratio` | Represents the maximum pressure band in the VM. | gauge | `vm` |
| `windows_hyperv_dynamic_memory_vm_add_operations_total` | Represents the total number of add operations for the VM. | counter | `vm` |
| `windows_hyperv_dynamic_memory_vm_remove_operations_total` | Represents the total number of remove operations for the VM. | counter | `vm` |
| `windows_hyperv_dynamic_memory_vm_pressure_minimum_ratio` | Represents the minimum pressure band in the VM. | gauge | `vm` |
| `windows_hyperv_dynamic_memory_vm_physical` | Represents the current amount of memory in the VM. | gauge | `vm` |
| `windows_hyperv_dynamic_memory_vm_removed_bytes_total` | Represents the cumulative amount of memory removed from the VM. | counter | `vm` |
### Hyper-V Hypervisor Logical Processor
| Name | Description | Type | Labels |
|----------------------------------------------------------------------|------------------------------------------------------------------------|---------|----------------|
| `windows_hyperv_hypervisor_logical_processor_time_total` | Time that processor spent in different modes (hypervisor, guest, idle) | counter | `core`.`state` |
| `windows_hyperv_hypervisor_logical_processor_context_switches_total` | The rate of virtual processor context switches on the processor. | counter | `core` |
### Hyper-V Hypervisor Root Partition
| Name | Description | Type | Labels |
|------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|---------|--------|
| `windows_hyperv_root_partition_address_spaces` | The number of address spaces in the virtual TLB of the partition | gauge | None |
| `windows_hyperv_root_partition_attached_devices` | The number of devices attached to the partition | gauge | None |
| `windows_hyperv_root_partition_deposited_pages` | The number of pages deposited into the partition | gauge | None |
| `windows_hyperv_root_partition_device_dma_errors` | An indicator of illegal DMA requests generated by all devices assigned to the partition | gauge | None |
| `windows_hyperv_root_partition_device_interrupt_errors` | An indicator of illegal interrupt requests generated by all devices assigned to the partition | gauge | None |
| `windows_hyperv_root_partition_device_interrupt_mappings` | The number of device interrupt mappings used by the partition | gauge | None |
| `windows_hyperv_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 | gauge | None |
| `windows_hyperv_root_partition_preferred_numa_node_index` | The number of pages present in the GPA space of the partition (zero for root partition) | gauge | None |
| `windows_hyperv_root_partition_gpa_space_modifications` | The rate of modifications to the GPA space of the partition | counter | None |
| `windows_hyperv_root_partition_io_tlb_flush_cost` | The average time (in nanoseconds) spent processing an I/O TLB flush | gauge | None |
| `windows_hyperv_root_partition_io_tlb_flush` | The rate of flushes of I/O TLBs of the partition | counter | None |
| `windows_hyperv_root_partition_recommended_virtual_tlb_size` | The recommended number of pages to be deposited for the virtual TLB | gauge | None |
| `windows_hyperv_root_partition_physical_pages_allocated` | The number of timer interrupts skipped for the partition | gauge | None |
| `windows_hyperv_root_partition_1G_device_pages` | The number of 1G pages present in the device space of the partition | gauge | None |
| `windows_hyperv_root_partition_1G_gpa_pages` | The number of 1G pages present in the GPA space of the partition | gauge | None |
| `windows_hyperv_root_partition_2M_device_pages` | The number of 2M pages present in the device space of the partition | gauge | None |
| `windows_hyperv_root_partition_2M_gpa_pages` | The number of 2M pages present in the GPA space of the partition | gauge | None |
| `windows_hyperv_root_partition_4K_device_pages` | The number of 4K pages present in the device space of the partition | gauge | None |
| `windows_hyperv_root_partition_4K_gpa_pages` | The number of 4K pages present in the GPA space of the partition | gauge | None |
| `windows_hyperv_root_partition_virtual_tlb_flush_entries` | The rate of flushes of the entire virtual TLB | counter | None |
| `windows_hyperv_root_partition_virtual_tlb_pages` | The number of pages used by the virtual TLB of the partition | gauge | None |
### Hyper-V Hypervisor Root Virtual Processor
| Name | Description | Type | Labels |
|---------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|---------|----------------|
| `windows_hyperv_hypervisor_root_virtual_processor_time_total` | Time that processor spent in different modes (hypervisor, guest_run, guest_idle, remote, total) | counter | `core`.`state` |
| `windows_hyperv_hypervisor_root_virtual_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 | `core` |
### Hyper-V Legacy Network Adapter
| Name | Description | Type | Labels |
|---------------------------------------------------------------|-------------------------------------------------------------------------|---------|-----------|
| `windows_hyperv_legacy_network_adapter_bytes_dropped_total` | Bytes Dropped is the number of bytes dropped on the network adapter | counter | `adapter` |
| `windows_hyperv_legacy_network_adapter_bytes_received_total` | Bytes received is the number of bytes received on the network adapter | counter | `adapter` |
| `windows_hyperv_legacy_network_adapter_bytes_sent_total` | Bytes sent is the number of bytes sent over the network adapter | counter | `adapter` |
| `windows_hyperv_legacy_network_adapter_frames_dropped_total` | Frames Dropped is the number of frames dropped on the network adapter | counter | `adapter` |
| `windows_hyperv_legacy_network_adapter_frames_received_total` | Frames received is the number of frames received on the network adapter | counter | `adapter` |
| `windows_hyperv_legacy_network_adapter_frames_sent_total` | Frames sent is the number of frames sent over the network adapter | counter | `adapter` |
### Hyper-V Hypervisor Virtual Processor
| Name | Description | Type | Labels |
|--------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|---------|--------------|
| `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_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` |
### Hyper-V Virtual Network Adapter
| Name | Description | Type | Labels |
|-------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|---------|-----------|
| `windows_hyperv_virtual_network_adapter_received_bytes_total` | Represents the total number of bytes received per second by the network adapter | counter | `adapter` |
| `windows_hyperv_virtual_network_adapter_sent_bytes_total` | Represents the total number of bytes sent per second by the network adapter | counter | `adapter` |
| `windows_hyperv_virtual_network_adapter_incoming_dropped_packets_total` | Represents the total number of dropped packets per second in the incoming direction of the network adapter | counter | `adapter` |
| `windows_hyperv_virtual_network_adapter_outgoing_dropped_packets_total` | Represents the total number of dropped packets per second in the outgoing direction of the network adapter | counter | `adapter` |
| `windows_hyperv_virtual_network_adapter_received_packets_total` | Represents the total number of packets received per second by the network adapter | counter | `adapter` |
| `windows_hyperv_virtual_network_adapter_sent_packets_total` | Represents the total number of packets sent per second by the network adapter | counter | `adapter` |
### Hyper-V Virtual Network Adapter Drop Reasons
| Name | Description | Type | Labels |
|-------------------------------------------------------|----------------------------------------------|---------|--------------------------------|
| `windows_hyperv_virtual_network_adapter_drop_reasons` | Hyper-V Virtual Network Adapter Drop Reasons | counter | `adapter`,`direction`,`reason` |
### Hyper-V Virtual SMB
| Name | Description | Type | Labels |
|-------------------------------------------------------|-----------------------------------------------------------------------------------|---------|------------|
| `windows_hyperv_virtual_smb_direct_mapped_sections` | Represents the number of direct-mapped sections in the virtual SMB` | gauge | `instance` |
| `windows_hyperv_virtual_smb_direct_mapped_pages` | Represents the number of direct-mapped pages in the virtual SMB` | gauge | `instance` |
| `windows_hyperv_virtual_smb_write_bytes_rdma` | Represents the number of bytes written per second using RDMA in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_write_bytes` | Represents the number of bytes written per second in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_read_bytes_rdma` | Represents the number of bytes read per second using RDMA in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_read_bytes` | Represents the number of bytes read per second in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_flush_requests` | Represents the number of flush requests per second in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_write_requests_rdma` | Represents the number of write requests per second using RDMA in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_write_requests` | Represents the number of write requests per second in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_read_requests_rdma` | Represents the number of read requests per second using RDMA in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_read_requests` | Represents the number of read requests per second in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_current_pending_requests` | Represents the current number of pending requests in the virtual SMB` | gauge | `instance` |
| `windows_hyperv_virtual_smb_current_open_file_count` | Represents the current number of open files in the virtual SMB` | gauge | `instance` |
| `windows_hyperv_virtual_smb_tree_connect_count` | Represents the number of tree connects in the virtual SMB` | gauge | `instance` |
| `windows_hyperv_virtual_smb_requests` | Represents the number of requests per second in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_sent_bytes` | Represents the number of bytes sent per second in the virtual SMB` | counter | `instance` |
| `windows_hyperv_virtual_smb_received_bytes` | Represents the number of bytes received per second in the virtual SMB` | counter | `instance` |
### Hyper-V Virtual Switch
| Name | Description | Type | Labels |
|---------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|---------|-----------|
| `windows_hyperv_vswitch_broadcast_packets_received_total` | Represents the total number of broadcast packets received per second by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_broadcast_packets_sent_total` | Represents the total number of broadcast packets sent per second by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_bytes_total` | Represents the total number of bytes per second traversing the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_bytes_received_total` | Represents the total number of bytes received per second by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_bytes_sent_total` | Represents the total number of bytes sent per second by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_directed_packets_received_total` | Represents the total number of directed packets received per second by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_directed_packets_send_total` | Represents the total number of directed packets sent per second by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_dropped_packets_incoming_total` | Represents the total number of packet dropped per second by the virtual switch in the incoming direction | counter | `vswitch` |
| `windows_hyperv_vswitch_dropped_packets_outcoming_total` | Represents the total number of packet dropped per second by the virtual switch in the outgoing direction | counter | `vswitch` |
| `windows_hyperv_vswitch_extensions_dropped_packets_incoming_total` | Represents the total number of packet dropped per second by the virtual switch extensions in the incoming direction | counter | `vswitch` |
| `windows_hyperv_vswitch_extensions_dropped_packets_outcoming_total` | Represents the total number of packet dropped per second by the virtual switch extensions in the outgoing direction | counter | `vswitch` |
| `windows_hyperv_vswitch_learned_mac_addresses_total` | Represents the total number of learned MAC addresses of the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_multicast_packets_received_total` | Represents the total number of multicast packets received per second by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_multicast_packets_sent_total` | Represents the total number of multicast packets sent per second by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_number_of_send_channel_moves_total` | Represents the total number of send channel moves per second on this virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_number_of_vmq_moves_total` | Represents the total number of VMQ moves per second on this virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_packets_flooded_total` | Represents the total number of packets flooded by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_packets_total` | Represents the total number of packets per second traversing the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_packets_received_total` | Represents the total number of packets received per second by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_packets_sent_total` | Represents the total number of packets send per second by the virtual switch | counter | `vswitch` |
| `windows_hyperv_vswitch_purged_mac_addresses_total` | Represents the total number of purged MAC addresses of the virtual switch | counter | `vswitch` |
### Hyper-V Virtual Storage Device
| Name | Description | Type | Labels |
|---------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|---------|----------|
| `windows_hyperv_virtual_storage_device_error_count_total` | Represents the total number of errors that have occurred on this virtual device. | counter | `device` |
| `windows_hyperv_virtual_storage_device_queue_length` | Represents the average queue length on this virtual device. | gauge | `device` |
| `windows_hyperv_virtual_storage_device_bytes_read` | Represents the total number of bytes that have been read on this virtual device. | counter | `device` |
| `windows_hyperv_virtual_storage_device_operations_read_total` | Represents the total number of read operations that have occurred on this virtual device. | counter | `device` |
| `windows_hyperv_virtual_storage_device_bytes_written` | Represents the total number of bytes that have been written on this virtual device. | counter | `device` |
| `windows_hyperv_virtual_storage_device_operations_written_total` | Represents the total number of write operations that have occurred on this virtual device. | counter | `device` |
| `windows_hyperv_virtual_storage_device_latency_seconds` | Represents the average IO transfer latency for this virtual device. | gauge | `device` |
| `windows_hyperv_virtual_storage_device_throughput` | Represents the average number of 8KB IO transfers completed by this virtual device. | gauge | `device` |
| `windows_hyperv_virtual_storage_device_normalized_throughput` | Represents the average number of IO transfers completed by this virtual device. | gauge | `device` |
| `windows_hyperv_virtual_storage_device_lower_queue_length` | Represents the average queue length on the underlying storage subsystem for this device. | gauge | `device` |
| `windows_hyperv_virtual_storage_device_lower_latency_seconds` | Represents the average IO transfer latency on the underlying storage subsystem for this virtual device. | gauge | `device` |
| `windows_hyperv_virtual_storage_device_io_quota_replenishment_rate` | Represents the IO quota replenishment rate for this virtual device. | gauge | `device` |
### Hyper-V VM Vid Partition
| Name | Description | Type | Labels |
|------------------------------------------------|-------------------------------------------------------------------------|-------|--------|
| `windows_hyperv_vid_physical_pages_allocated` | The number of physical pages allocated | gauge | `vm` |
| `windows_hyperv_vid_preferred_numa_node_index` | The preferred NUMA node index associated with this partition | gauge | `vm` |
| `windows_hyperv_vid_remote_physical_pages` | The number of physical pages not allocated from the preferred NUMA node | gauge | `vm` |
### Hyper-V Virtual Machine Health Summary
| Name | Description | Type | Labels |
|------------------------------------------------------|-------------------------------------------------------|-------|--------|
| `windows_hyperv_virtual_machine_health_total_count` | Represents the number of virtual machines with health | gauge | None |
### Example metric
_This collector does not yet have explained examples, we would appreciate your help adding them!_
@@ -113,19 +265,19 @@ _This collector does not yet have explained examples, we would appreciate your h
## Useful queries
Percent of physical CPU resources used per VM (on instance "localhost")
```
(sum (rate(windows_hyperv_vm_cpu_hypervisor_run_time{instance="localhost"}[1m]))) / ignoring(vm) group_left max (windows_cs_logical_processors{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)
```
(sum by (instance)(rate(windows_hyperv_vm_cpu_total_run_time{}[1m]))) / max by (instance)(windows_cs_logical_processors{}) / 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)
```
(sum by (instance)(rate(windows_hyperv_host_cpu_total_run_time{}[1m]))) / sum by (instance)(windows_cs_logical_processors{}) / 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)
```
(sum by (instance)(rate(windows_hyperv_host_lp_total_run_time_percent{}[1m]))) / sum by (instance)(windows_hyperv_hypervisor_logical_processors{}) / 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

View File

@@ -2,26 +2,22 @@
The msmq collector exposes metrics about the queues on a MSMQ server
|||
-|-
Metric name prefix | `msmq`
Classes | `Win32_PerfRawData_MSMQ_MSMQQueue`
Enabled by default? | No
| | |
|---------------------|----------------------|
| Metric name prefix | `msmq` |
| Spource | Performance Counters |
| Enabled by default? | No |
## Flags
### `--collector.msmq.msmq-where`
A WMI filter on which queues to include. `%` is a wildcard, and can be used to match on substrings.
## Metrics
Name | Description | Type | Labels
-----|-------------|------|-------
`windows_msmq_bytes_in_journal_queue` | Size of queue journal in bytes | gauge | `name`
`windows_msmq_bytes_in_queue` | Size of queue in bytes | gauge | `name`
`windows_msmq_messages_in_journal_queue` | Count messages in queue journal | gauge | `name`
`windows_msmq_messages_in_queue` | Count messages in queue | gauge | `name`
| Name | Description | Type | Labels |
|------------------------------------------|---------------------------------|-------|--------|
| `windows_msmq_bytes_in_journal_queue` | Size of queue journal in bytes | gauge | `name` |
| `windows_msmq_bytes_in_queue` | Size of queue in bytes | gauge | `name` |
| `windows_msmq_messages_in_journal_queue` | Count messages in queue journal | gauge | `name` |
| `windows_msmq_messages_in_queue` | Count messages in queue | gauge | `name` |
### Example metric
_This collector does not yet have explained examples, we would appreciate your help adding them!_

View File

@@ -16,246 +16,247 @@ Comma-separated list of MSSQL WMI classes to use. Supported values are `accessme
### `--collectors.mssql.class-print`
If true, print available mssql WMI classes and exit. Only displays if the mssql collector is enabled.
If true, print available mssql WMI classes and exit. Only displays if the mssql collector is enabled.fman`, `databases`, `dbreplica`, `genstats`, `locks`, `memmgr`, `sqlstats`, `sqlerrors`, `transactions`, and `waitstats`.
## Metrics
Name | Description | Type | Labels
-----|-------------|------|-------
`windows_mssql_collector_duration_seconds` | The time taken for each sub-collector to return | gauge | `collector`, `mssql_instance`
`windows_mssql_collector_success` | 1 if sub-collector succeeded, 0 otherwise | gauge | `collector`, `mssql_instance`
`windows_mssql_accessmethods_au_batch_cleanups` | The total number of batches that were completed successfully by the background task that cleans up deferred dropped allocation units | counter | `mssql_instance`
`windows_mssql_accessmethods_au_cleanups` | The total number of allocation units that were successfully dropped the background task that cleans up deferred dropped allocation units. Each allocation unit drop requires multiple batches | counter | `mssql_instance`
`windows_mssql_accessmethods_by_reference_lob_creates` | The total count of large object (lob) values that were passed by reference. By-reference lobs are used in certain bulk operations to avoid the cost of passing them by value | counter | `mssql_instance`
`windows_mssql_accessmethods_by_reference_lob_uses` | The total count of by-reference lob values that were used. By-reference lobs are used in certain bulk operations to avoid the cost of passing them by-value | counter | `mssql_instance`
`windows_mssql_accessmethods_lob_read_aheads` | The total count of lob pages on which readahead was issued | counter | `mssql_instance`
`windows_mssql_accessmethods_column_value_pulls` | The total count of column values that were pulled in-row from off-row | counter | `mssql_instance`
`windows_mssql_accessmethods_column_value_pushes` | The total count of column values that were pushed from in-row to off-row | counter | `mssql_instance`
`windows_mssql_accessmethods_deferred_dropped_aus` | The total number of allocation units waiting to be dropped by the background task that cleans up deferred dropped allocation units | gauge | `mssql_instance`
`windows_mssql_accessmethods_deferred_dropped_rowsets` | The number of rowsets created as a result of aborted online index build operations that are waiting to be dropped by the background task that cleans up deferred dropped rowsets | gauge | `mssql_instance`
`windows_mssql_accessmethods_dropped_rowset_cleanups` | The number of rowsets per second created as a result of aborted online index build operations that were successfully dropped by the background task that cleans up deferred dropped rowsets | counter | `mssql_instance`
`windows_mssql_accessmethods_dropped_rowset_skips` | The number of rowsets per second created as a result of aborted online index build operations that were skipped by the background task that cleans up deferred dropped rowsets created | counter | `mssql_instance`
`windows_mssql_accessmethods_extent_deallocations` | Number of extents deallocated per second in all databases in this instance of SQL Server | counter | `mssql_instance`
`windows_mssql_accessmethods_extent_allocations` | Number of extents allocated per second in all databases in this instance of SQL Server | counter | `mssql_instance`
`windows_mssql_accessmethods_au_batch_cleanup_failures` | The number of batches per second that failed and required retry, by the background task that cleans up deferred dropped allocation units. Failure could be due to lack of memory or disk space, hardware failure and other reasons | counter | `mssql_instance`
`windows_mssql_accessmethods_leaf_page_cookie_failures` | The number of times that a leaf page cookie could not be used during an index search since changes happened on the leaf page. The cookie is used to speed up index search | counter | `mssql_instance`
`windows_mssql_accessmethods_tree_page_cookie_failures` | The number of times that a tree page cookie could not be used during an index search since changes happened on the parent pages of those tree pages. The cookie is used to speed up index search | counter | `mssql_instance`
`windows_mssql_accessmethods_forwarded_records` | Number of records per second fetched through forwarded record pointers | counter | `mssql_instance`
`windows_mssql_accessmethods_free_space_page_fetches` | Number of pages fetched per second by free space scans. These scans search for free space within pages already allocated to an allocation unit, to satisfy requests to insert or modify record fragments | counter | `mssql_instance`
`windows_mssql_accessmethods_free_space_scans` | Number of scans per second that were initiated to search for free space within pages already allocated to an allocation unit to insert or modify record fragment. Each scan may find multiple pages | counter | `mssql_instance`
`windows_mssql_accessmethods_full_scans` | Number of unrestricted full scans per second. These can be either base-table or full-index scans | counter | `mssql_instance`
`windows_mssql_accessmethods_index_searches` | Number of index searches per second. These are used to start a range scan, reposition a range scan, revalidate a scan point, fetch a single index record, and search down the index to locate where to insert a new row | counter | `mssql_instance`
`windows_mssql_accessmethods_insysxact_waits` | Number of times a reader needs to wait for a page because the InSysXact bit is set | counter | `mssql_instance`
`windows_mssql_accessmethods_lob_handle_creates` | Count of temporary lobs created | counter | `mssql_instance`
`windows_mssql_accessmethods_lob_handle_destroys` | Count of temporary lobs destroyed | counter | `mssql_instance`
`windows_mssql_accessmethods_lob_ss_provider_creates` | Count of LOB Storage Service Providers (LobSSP) created. One worktable created per LobSSP | counter | `mssql_instance`
`windows_mssql_accessmethods_lob_ss_provider_destroys` | Count of LobSSP destroyed | counter | `mssql_instance`
`windows_mssql_accessmethods_lob_ss_provider_truncations` | Count of LobSSP truncated | counter | `mssql_instance`
`windows_mssql_accessmethods_mixed_page_allocations` | Number of pages allocated per second from mixed extents. These could be used for storing the IAM pages and the first eight pages that are allocated to an allocation unit | counter | `mssql_instance`
`windows_mssql_accessmethods_page_compression_attempts` | Number of pages evaluated for page-level compression. Includes pages that were not compressed because significant savings could be achieved. Includes all objects in the instance of SQL Server | counter | `mssql_instance`
`windows_mssql_accessmethods_page_deallocations` | Number of pages deallocated per second in all databases in this instance of SQL Server. These include pages from mixed extents and uniform extents | counter | `mssql_instance`
`windows_mssql_accessmethods_page_allocations` | Number of pages allocated per second in all databases in this instance of SQL Server. These include pages allocations from both mixed extents and uniform extents | counter | `mssql_instance`
`windows_mssql_accessmethods_page_compressions` | Number of data pages that are compressed by using PAGE compression. Includes all objects in the instance of SQL Server | counter | `mssql_instance`
`windows_mssql_accessmethods_page_splits` | Number of page splits per second that occur as the result of overflowing index pages | counter | `mssql_instance`
`windows_mssql_accessmethods_probe_scans` | Number of probe scans per second that are used to find at most one single qualified row in an index or base table directly | counter | `mssql_instance`
`windows_mssql_accessmethods_range_scans` | Number of qualified range scans through indexes per second | counter | `mssql_instance`
`windows_mssql_accessmethods_scan_point_revalidations` | Number of times per second that the scan point had to be revalidated to continue the scan | counter | `mssql_instance`
`windows_mssql_accessmethods_ghost_record_skips` | Number of ghosted records per second skipped during scans | counter | `mssql_instance`
`windows_mssql_accessmethods_table_lock_escalations` | Number of times locks on a table were escalated to the TABLE or HoBT granularity | counter | `mssql_instance`
`windows_mssql_accessmethods_leaf_page_cookie_uses` | Number of times a leaf page cookie is used successfully during an index search since no change happened on the leaf page. The cookie is used to speed up index search | counter | `mssql_instance`
`windows_mssql_accessmethods_tree_page_cookie_uses` | Number of times a tree page cookie is used successfully during an index search since no change happened on the parent page of the tree page. The cookie is used to speed up index search | counter | `mssql_instance`
`windows_mssql_accessmethods_workfile_creates` | Number of work files created per second. For example, work files could be used to store temporary results for hash joins and hash aggregates | counter | `mssql_instance`
`windows_mssql_accessmethods_worktables_creates` | Number of work tables created per second. For example, work tables could be used to store temporary results for query spool, lob variables, XML variables, and cursors | counter | `mssql_instance`
`windows_mssql_accessmethods_worktables_from_cache_ratio` | Percentage of work tables created where the initial two pages of the work table were not allocated but were immediately available from the work table cache | counter | `mssql_instance`
`windows_mssql_availreplica_received_from_replica_bytes` | Number of bytes received from the availability replica per second. Pings and status updates will generate network traffic even on databases with no user updates | counter | `mssql_instance`, `replica`
`windows_mssql_availreplica_sent_to_replica_bytes` | Number of bytes sent to the remote availability replica per second. On the primary replica this is the number of bytes sent to the secondary replica. On the secondary replica this is the number of bytes sent to the primary replica | counter | `mssql_instance`, `replica`
`windows_mssql_availreplica_sent_to_transport_bytes` | Actual number of bytes sent per second over the network to the remote availability replica. On the primary replica this is the number of bytes sent to the secondary replica. On the secondary replica this is the number of bytes sent to the primary replica | counter | `mssql_instance`, `replica`
`windows_mssql_availreplica_initiated_flow_controls` | Time in milliseconds that log stream messages waited for send flow control, in the last second | counter | `mssql_instance`, `replica`
`windows_mssql_availreplica_flow_control_wait_seconds` | Number of times flow-control initiated in the last second. Flow Control Time (ms/sec) divided by Flow Control/sec is the average time per wait | counter | `mssql_instance`, `replica`
`windows_mssql_availreplica_receives_from_replica` | Number of Always On messages received from thereplica per second | counter | `mssql_instance`, `replica`
`windows_mssql_availreplica_resent_messages` | Number of Always On messages resent in the last second | counter | `mssql_instance`, `replica`
`windows_mssql_availreplica_sends_to_replica` | Number of Always On messages sent to this availability replica per second | counter | `mssql_instance`, `replica`
`windows_mssql_availreplica_sends_to_transport` | Actual number of Always On messages sent per second over the network to the remote availability replica | counter | `mssql_instance`, `replica`
`windows_mssql_bufman_background_writer_pages` | Number of pages flushed to enforce the recovery interval settings | counter | `mssql_instance`
`windows_mssql_bufman_buffer_cache_hit_ratio` | Indicates the percentage of pages found in the buffer cache without having to read from disk. The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses | gauge | `mssql_instance`
`windows_mssql_bufman_checkpoint_pages` | Indicates the number of pages flushed to disk per second by a checkpoint or other operation that require all dirty pages to be flushed | counter | `mssql_instance`
`windows_mssql_bufman_database_pages` | Indicates the number of pages in the buffer pool with database content | gauge | `mssql_instance`
`windows_mssql_bufman_extension_allocated_pages` | Total number of non-free cache pages in the buffer pool extension file | gauge | `mssql_instance`
`windows_mssql_bufman_extension_free_pages` | Total number of free cache pages in the buffer pool extension file | gauge | `mssql_instance`
`windows_mssql_bufman_extension_in_use_as_percentage` | _Not yet documented_ | gauge | `mssql_instance`
`windows_mssql_bufman_extension_outstanding_io` | Percentage of the buffer pool extension paging file occupied by buffer manager pages | gauge | `mssql_instance`
`windows_mssql_bufman_extension_page_evictions` | Number of pages evicted from the buffer pool extension file per second | counter | `mssql_instance`
`windows_mssql_bufman_extension_page_reads` | Number of pages read from the buffer pool extension file per second | counter | `mssql_instance`
`windows_mssql_bufman_extension_page_unreferenced_seconds` | Average seconds a page will stay in the buffer pool extension without references to it | gauge | `mssql_instance`
`windows_mssql_bufman_extension_page_writes` | Number of pages written to the buffer pool extension file per second | counter | `mssql_instance`
`windows_mssql_bufman_free_list_stalls` | Indicates the number of requests per second that had to wait for a free page | counter | `mssql_instance`
`windows_mssql_bufman_integral_controller_slope` | The slope that integral controller for the buffer pool last used, times -10 billion | gauge | `mssql_instance`
`windows_mssql_bufman_lazywrites` | Indicates the number of buffers written per second by the buffer manager's lazy writer | counter | `mssql_instance`
`windows_mssql_bufman_page_life_expectancy_seconds` | Indicates the number of seconds a page will stay in the buffer pool without references | gauge | `mssql_instance`
`windows_mssql_bufman_page_lookups` | Indicates the number of requests per second to find a page in the buffer pool | counter | `mssql_instance`
`windows_mssql_bufman_page_reads` | Indicates the number of physical database page reads that are issued per second | counter | `mssql_instance`
`windows_mssql_bufman_page_writes` | Indicates the number of physical database page writes that are issued per second | counter | `mssql_instance`
`windows_mssql_bufman_read_ahead_pages` | Indicates the number of pages read per second in anticipation of use | counter | `mssql_instance`
`windows_mssql_bufman_read_ahead_issuing_seconds` | Time (microseconds) spent issuing readahead | counter | `mssql_instance`
`windows_mssql_bufman_target_pages` | Ideal number of pages in the buffer pool | gauge | `mssql_instance`
`windows_mssql_dbreplica_database_flow_control_wait_seconds` | _Not yet documented_ | gauge | `mssql_instance`, `replica`
`windows_mssql_dbreplica_database_initiated_flow_controls` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_received_file_bytes` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_group_commits` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_group_commit_stall_seconds` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_apply_pending_queue` | _Not yet documented_ | gauge | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_apply_ready_queue` | _Not yet documented_ | gauge | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_compressed_bytes` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_decompressed_bytes` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_received_bytes` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_compression_cachehits` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_compression_cachemisses` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_compressions` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_decompressions` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_remaining_for_undo` | The amount of log, in bytes, remaining to complete the undo phase | gauge | `mssql_instance`, `replica`
`windows_mssql_dbreplica_log_send_queue` | Amount of log records in the log files of the primary database, in kilobytes, that haven't been sent to the secondary replica | gauge | `mssql_instance`, `replica`
`windows_mssql_dbreplica_mirrored_write_transactions` | Number of transactions that were written to the primary database and then waited to commit until the log was sent to the secondary database, in the last second | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_recovery_queue_records` | Amount of log records in the log files of the secondary replica that have not been redone | gauge | `mssql_instance`, `replica`
`windows_mssql_dbreplica_redo_blocks` | Number of times the redo thread was blocked on locks held by readers of the database | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_redo_remaining_bytes` | The amount of log, in kilobytes, remaining to be redone to finish the reverting phase | gauge | `mssql_instance`, `replica`
`windows_mssql_dbreplica_redone_bytes` | Amount of log records redone on the secondary database in the last second | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_redones` | _Not yet documented_ | counter | `mssql_instance`, `replica`
`windows_mssql_dbreplica_total_log_requiring_undo` | Total kilobytes of log that must be undone | gauge | `mssql_instance`, `replica`
`windows_mssql_dbreplica_transaction_delay_seconds` | Delay in waiting for unterminated commit acknowledgment for all the current transactions | gauge | `mssql_instance`, `replica`
`windows_mssql_databases_active_transactions` | Number of active transactions for the database | gauge | `mssql_instance`, `database`
`windows_mssql_databases_backup_restore_operations` | Read/write throughput for backup and restore operations of a database per second | counter | `mssql_instance`, `database`
`windows_mssql_databases_bulk_copy_rows` | Number of rows bulk copied per second | counter | `mssql_instance`, `database`
`windows_mssql_databases_bulk_copy_bytes` | Amount of data bulk copied (in kilobytes) per second | counter | `mssql_instance`, `database`
`windows_mssql_databases_commit_table_entries` | he size (row count) of the in-memory portion of the commit table for the database | gauge | `mssql_instance`, `database`
`windows_mssql_databases_data_files_size_bytes` | Cumulative size (in kilobytes) of all the data files in the database including any automatic growth. Monitoring this counter is useful, for example, for determining the correct size of tempdb | gauge | `mssql_instance`, `database`
`windows_mssql_databases_dbcc_logical_scan_bytes` | Number of logical read scan bytes per second for database console commands (DBCC) | counter | `mssql_instance`, `database`
`windows_mssql_databases_group_commit_stall_seconds` | Group stall time (microseconds) per second | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_flushed_bytes` | Total number of log bytes flushed | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_cache_hit_ratio` | Percentage of log cache reads satisfied from the log cache | gauge | `mssql_instance`, `database`
`windows_mssql_databases_log_cache_reads` | Reads performed per second through the log manager cache | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_files_size_bytes` | Cumulative size (in kilobytes) of all the transaction log files in the database | gauge | `mssql_instance`, `database`
`windows_mssql_databases_log_files_used_size_bytes` | The cumulative used size of all the log files in the database | gauge | `mssql_instance`, `database`
`windows_mssql_databases_log_flushes` | Total wait time (in milliseconds) to flush the log. On an Always On secondary database, this value indicates the wait time for log records to be hardened to disk | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_flush_waits` | Number of commits per second waiting for the log flush | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_flush_wait_seconds` | Number of commits per second waiting for the log flush | gauge | `mssql_instance`, `database`
`windows_mssql_databases_log_flush_write_seconds` | Time in milliseconds for performing writes of log flushes that were completed in the last second | gauge | `mssql_instance`, `database`
`windows_mssql_databases_log_growths` | Total number of times the transaction log for the database has been expanded | gauge | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_cache_misses` | Number of requests for which the log block was not available in the log pool | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_disk_reads` | Number of disk reads that the log pool issued to fetch log blocks | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_hash_deletes` | Rate of raw hash entry deletes from the Log Pool | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_hash_inserts` | Rate of raw hash entry inserts into the Log Pool | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_invalid_hash_entries` | Rate of hash lookups failing due to being invalid | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_log_scan_pushes` | Rate of Log block pushes by log scans, which may come from disk or memory | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_log_writer_pushes` | Rate of Log block pushes by log writer thread | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_empty_free_pool_pushes` | Rate of Log block push fails due to empty free pool | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_low_memory_pushes` | Rate of Log block push fails due to being low on memory | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_no_free_buffer_pushes` | Rate of Log block push fails due to free buffer unavailable | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_req_behind_trunc` | Log pool cache misses due to block requested being behind truncation LSN | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_requests_old_vlf` | Log Pool requests that were not in the last VLF of the log | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_requests` | The number of log-block requests processed by the log pool | counter | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_total_active_log_bytes` | Current total active log stored in the shared cache buffer manager in bytes | gauge | `mssql_instance`, `database`
`windows_mssql_databases_log_pool_total_shared_pool_bytes` | Current total memory usage of the shared cache buffer manager in bytes | gauge | `mssql_instance`, `database`
`windows_mssql_databases_log_shrinks` | Total number of log shrinks for this database | gauge | `mssql_instance`, `database`
`windows_mssql_databases_log_truncations` | The number of times the transaction log has been truncated (in Simple Recovery Model) | gauge | `mssql_instance`, `database`
`windows_mssql_databases_log_used_percent` | Percentage of space in the log that is in use | gauge | `mssql_instance`, `database`
`windows_mssql_databases_pending_repl_transactions` | Number of transactions in the transaction log of the publication database marked for replication, but not yet delivered to the distribution database | gauge | `mssql_instance`, `database`
`windows_mssql_databases_repl_transactions` | Number of transactions per second read out of the transaction log of the publication database and delivered to the distribution database | counter | `mssql_instance`, `database`
`windows_mssql_databases_shrink_data_movement_bytes` | Amount of data being moved per second by autoshrink operations, or DBCC SHRINKDATABASE or DBCC SHRINKFILE statements | counter | `mssql_instance`, `database`
`windows_mssql_databases_tracked_transactions` | Number of committed transactions recorded in the commit table for the database | counter | `mssql_instance`, `database`
`windows_mssql_databases_transactions` | Number of transactions started for the database per second | counter | `mssql_instance`, `database`
`windows_mssql_databases_write_transactions` | Number of transactions that wrote to the database and committed, in the last second | counter | `mssql_instance`, `database`
`windows_mssql_databases_xtp_controller_dlc_fetch_latency_seconds` | Average latency in microseconds between log blocks entering the Direct Log Consumer and being retrieved by the XTP controller, per second | gauge | `mssql_instance`, `database`
`windows_mssql_databases_xtp_controller_dlc_peak_latency_seconds` | The largest recorded latency, in microseconds, of a fetch from the Direct Log Consumer by the XTP controller | gauge | `mssql_instance`, `database`
`windows_mssql_databases_xtp_controller_log_processed_bytes` | The amount of log bytes processed by the XTP controller thread, per second | counter | `mssql_instance`, `database`
`windows_mssql_databases_xtp_memory_used_bytes` | The amount of memory used by XTP in the database | gauge | `mssql_instance`, `database`
`windows_mssql_genstats_active_temp_tables` | Number of temporary tables/table variables in use | gauge | `mssql_instance`
`windows_mssql_genstats_connection_resets` | Total number of logins started from the connection pool | counter | `mssql_instance`
`windows_mssql_genstats_event_notifications_delayed_drop` | Number of event notifications waiting to be dropped by a system thread | gauge | `mssql_instance`
`windows_mssql_genstats_http_authenticated_requests` | Number of authenticated HTTP requests started per second | gauge | `mssql_instance`
`windows_mssql_genstats_logical_connections` | Number of logical connections to the system | gauge | `mssql_instance`
`windows_mssql_genstats_logins` | Total number of logins started per second. This does not include pooled connections | counter | `mssql_instance`
`windows_mssql_genstats_logouts` | Total number of logout operations started per second | counter | `mssql_instance`
`windows_mssql_genstats_mars_deadlocks` | Number of MARS deadlocks detected | gauge | `mssql_instance`
`windows_mssql_genstats_non_atomic_yields` | Number of non-atomic yields per second | counter | `mssql_instance`
`windows_mssql_genstats_blocked_processes` | Number of currently blocked processes | gauge | `mssql_instance`
`windows_mssql_genstats_soap_empty_requests` | Number of empty SOAP requests started per second | gauge | `mssql_instance`
`windows_mssql_genstats_soap_method_invocations` | Number of SOAP method invocations started per second | gauge | `mssql_instance`
`windows_mssql_genstats_soap_session_initiate_requests` | Number of SOAP Session initiate requests started per second | gauge | `mssql_instance`
`windows_mssql_genstats_soap_session_terminate_requests` | Number of SOAP Session terminate requests started per second | gauge | `mssql_instance`
`windows_mssql_genstats_soapsql_requests` | Number of SOAP SQL requests started per second | gauge | `mssql_instance`
`windows_mssql_genstats_soapwsdl_requests` | Number of SOAP Web Service Description Language requests started per second | gauge | `mssql_instance`
`windows_mssql_genstats_sql_trace_io_provider_lock_waits` | Number of waits for the File IO Provider lock per second | gauge | `mssql_instance`
`windows_mssql_genstats_tempdb_recovery_unit_ids_generated` | Number of duplicate tempdb recovery unit id generated | gauge | `mssql_instance`
`windows_mssql_genstats_tempdb_rowset_ids_generated` | Number of duplicate tempdb rowset id generated | gauge | `mssql_instance`
`windows_mssql_genstats_temp_tables_creations` | Number of temporary tables/table variables created per second | counter | `mssql_instance`
`windows_mssql_genstats_temp_tables_awaiting_destruction` | Number of temporary tables/table variables waiting to be destroyed by the cleanup system thread | gauge | `mssql_instance`
`windows_mssql_genstats_trace_event_notification_queue_size` | Number of trace event notification instances waiting in the internal queue to be sent through Service Broker | gauge | `mssql_instance`
`windows_mssql_genstats_transactions` | Number of transaction enlistments (local, DTC, bound all combined) | gauge | `mssql_instance`
`windows_mssql_genstats_user_connections` | Counts the number of users currently connected to SQL Server | gauge | `mssql_instance`
`windows_mssql_locks_average_wait_seconds` | Average amount of wait time (in milliseconds) for each lock request that resulted in a wait | gauge | `mssql_instance`, `resource`
`windows_mssql_locks_lock_requests` | Number of new locks and lock conversions per second requested from the lock manager | counter | `mssql_instance`, `resource`
`windows_mssql_locks_lock_timeouts` | Number of lock requests per second that timed out, including requests for NOWAIT locks | counter | `mssql_instance`, `resource`
`windows_mssql_locks_lock_timeouts_excluding_NOWAIT` | Number of lock requests per second that timed out, but excluding requests for NOWAIT locks | counter | `mssql_instance`, `resource`
`windows_mssql_locks_lock_waits` | Total wait time (in milliseconds) for locks in the last second | counter | `mssql_instance`, `resource`
`windows_mssql_locks_lock_wait_seconds` | Number of lock requests per second that required the caller to wait | gauge | `mssql_instance`, `resource`
`windows_mssql_locks_deadlocks` | Number of lock requests per second that resulted in a deadlock | counter | `mssql_instance`, `resource`
`windows_mssql_memmgr_connection_memory_bytes` | Specifies the total amount of dynamic memory the server is using for maintaining connections | gauge | `mssql_instance`
`windows_mssql_memmgr_database_cache_memory_bytes` | Specifies the amount of memory the server is currently using for the database pages cache | gauge | `mssql_instance`
`windows_mssql_memmgr_external_benefit_of_memory` | An internal estimation of the performance benefit from adding memory to a specific cache | gauge | `mssql_instance`
`windows_mssql_memmgr_free_memory_bytes` | Specifies the amount of committed memory currently not used by the server | gauge | `mssql_instance`
`windows_mssql_memmgr_granted_workspace_memory_bytes` | Specifies the total amount of memory currently granted to executing processes, such as hash, sort, bulk copy, and index creation operations | gauge | `mssql_instance`
`windows_mssql_memmgr_lock_blocks` | Specifies the current number of lock blocks in use on the server (refreshed periodically). A lock block represents an individual locked resource, such as a table, page, or row | gauge | `mssql_instance`
`windows_mssql_memmgr_allocated_lock_blocks` | Specifies the current number of allocated lock blocks. At server startup, the number of allocated lock blocks plus the number of allocated lock owner blocks depends on the SQL Server Locks configuration option. If more lock blocks are needed, the value increases | gauge | `mssql_instance`
`windows_mssql_memmgr_lock_memory_bytes` | Specifies the total amount of dynamic memory the server is using for locks | gauge | `mssql_instance`
`windows_mssql_memmgr_lock_owner_blocks` | Specifies the current number of allocated lock owner blocks. At server startup, the number of allocated lock owner blocks and the number of allocated lock blocks depend on the SQL Server Locks configuration option. If more lock owner blocks are needed, the value increases dynamically | gauge | `mssql_instance`
`windows_mssql_memmgr_allocated_lock_owner_blocks` | _Not yet documented_ | gauge | `mssql_instance`
`windows_mssql_memmgr_log_pool_memory_bytes` | Total amount of dynamic memory the server is using for Log Pool | gauge | `mssql_instance`
`windows_mssql_memmgr_maximum_workspace_memory_bytes` | Indicates the maximum amount of memory available for executing processes, such as hash, sort, bulk copy, and index creation operations | gauge | `mssql_instance`
`windows_mssql_memmgr_outstanding_memory_grants` | Specifies the total number of processes that have successfully acquired a workspace memory grant | gauge | `mssql_instance`
`windows_mssql_memmgr_pending_memory_grants` | Specifies the total number of processes waiting for a workspace memory grant | gauge | `mssql_instance`
`windows_mssql_memmgr_optimizer_memory_bytes` | Specifies the total amount of dynamic memory the server is using for query optimization | gauge | `mssql_instance`
`windows_mssql_memmgr_reserved_server_memory_bytes` | ndicates the amount of memory the server has reserved for future usage. This counter shows the current unused amount of memory initially granted that is shown in Granted Workspace Memory | gauge | `mssql_instance`
`windows_mssql_memmgr_sql_cache_memory_bytes` | Specifies the total amount of dynamic memory the server is using for the dynamic SQL cache | gauge | `mssql_instance`
`windows_mssql_memmgr_stolen_server_memory_bytes` | Specifies the amount of memory the server is using for purposes other than database pages | gauge | `mssql_instance`
`windows_mssql_memmgr_target_server_memory_bytes` | Indicates the ideal amount of memory the server can consume | gauge | `mssql_instance`
`windows_mssql_memmgr_total_server_memory_bytes` | Specifies the amount of memory the server has committed using the memory manager | gauge | `mssql_instance`
`windows_mssql_sqlstats_auto_parameterization_attempts` | Number of failed auto-parameterization attempts per second. This should be small. Note that auto-parameterizations are also known as simple parameterizations in later versions of SQL Server | counter | `mssql_instance`
`windows_mssql_sqlstats_batch_requests` | _Not yet documented_ | counter | `mssql_instance`
`windows_mssql_sqlstats_failed_auto_parameterization_attempts` | _Not yet documented_ | counter | `mssql_instance`
`windows_mssql_sqlstats_forced_parameterizations` | Number of successful forced parameterizations per second | counter | `mssql_instance`
`windows_mssql_sqlstats_guided_plan_executions` | Number of plan executions per second in which the query plan has been generated by using a plan guide | counter | `mssql_instance`
`windows_mssql_sqlstats_misguided_plan_executions` | Number of plan executions per second in which a plan guide could not be honored during plan generation | counter | `mssql_instance`
`windows_mssql_sqlstats_safe_auto_parameterization_attempts` | Number of safe auto-parameterization attempts per second | counter | `mssql_instance`
`windows_mssql_sqlstats_sql_attentions` | Number of attentions per second | counter | `mssql_instance`
`windows_mssql_sqlstats_sql_compilations` | Number of SQL compilations per second | counter | `mssql_instance`
`windows_mssql_sqlstats_sql_recompilations` | Number of statement recompiles per second | counter | `mssql_instance`
`windows_mssql_sqlstats_unsafe_auto_parameterization_attempts` | Number of unsafe auto-parameterization attempts per second. | counter | `mssql_instance`
`windows_mssql_sql_errors_total` | Information for all errors | counter | `mssql_instance`, `resource`
`windows_mssql_transactions_tempdb_free_space_bytes` | The amount of space (in kilobytes) available in tempdb | gauge | `mssql_instance`
`windows_mssql_transactions_longest_transaction_running_seconds` | The length of time (in seconds) since the start of the transaction that has been active longer than any other current transaction | gauge | `mssql_instance`
`windows_mssql_transactions_nonsnapshot_version_active_total` | The number of currently active transactions that are not using snapshot isolation level and have made data modifications that have generated row versions in the tempdb version store | counter | `mssql_instance`
`windows_mssql_transactions_snapshot_active_total` | The number of currently active transactions using the snapshot isolation level | counter | `mssql_instance`
`windows_mssql_transactions_active` | The number of currently active transactions of all types | gauge | `mssql_instance`
`windows_mssql_transactions_update_conflicts_total` | The percentage of those transactions using the snapshot isolation level that have encountered update conflicts within the last second | counter | `mssql_instance`
`windows_mssql_transactions_update_snapshot_active_total` | The number of currently active transactions using the snapshot isolation level and have modified data | counter | `mssql_instance`
`windows_mssql_transactions_version_cleanup_rate_bytes` | The rate (in kilobytes per second) at which row versions are removed from the snapshot isolation version store in tempdb | gauge | `mssql_instance`
`windows_mssql_transactions_version_generation_rate_bytes` | The rate (in kilobytes per second) at which new row versions are added to the snapshot isolation version store in tempdb | gauge | `mssql_instance`
`windows_mssql_transactions_version_store_size_bytes` | he amount of space (in kilobytes) in tempdb being used to store snapshot isolation level row versions | gauge | `mssql_instance`
`windows_mssql_transactions_version_store_units` | The number of active allocation units in the snapshot isolation version store in tempdb | counter | `mssql_instance`
`windows_mssql_transactions_version_store_creation_units` | The number of allocation units that have been created in the snapshot isolation store since the instance of the Database Engine was started | counter | `mssql_instance`
`windows_mssql_transactions_version_store_truncation_units` | The number of allocation units that have been removed from the snapshot isolation store since the instance of the Database Engine was started | counter | `mssql_instance`
`windows_mssql_waitstats_lock_waits` | Statistics for processes waiting on a lock | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_memory_grant_queue_waits` | Statistics for processes waiting for memory grant to become available | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_thread_safe_memory_objects_waits` | Statistics for processes waiting on thread-safe memory allocators | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_log_write_waits` | Statistics for processes waiting for log buffer to be written | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_log_buffer_waits` | Statistics for processes waiting for log buffer to be available | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_network_io_waits` | Statistics relevant to wait on network I/O | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_page_io_latch_waits` | Statistics relevant to page I/O latches | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_page_latch_waits` | Statistics relevant to page latches, not including I/O latches | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_nonpage_latch_waits` | Statistics relevant to non-page latches | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_wait_for_the_worker_waits` | Statistics relevant to processes waiting for worker to become available | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_workspace_synchronization_waits` | Statistics relevant to processes synchronizing access to workspace | gauge | `mssql_instance`, `item`
`windows_mssql_waitstats_transaction_ownership_waits` | Statistics relevant to processes synchronizing access to transaction | gauge | `mssql_instance`, `item`
| Name | Description | Type | Labels |
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-------------------------------|
| `windows_mssql_collector_duration_seconds` | The time taken for each sub-collector to return | gauge | `collector`, `mssql_instance` |
| `windows_mssql_collector_success` | 1 if sub-collector succeeded, 0 otherwise | gauge | `collector`, `mssql_instance` |
| `windows_mssql_accessmethods_au_batch_cleanups` | The total number of batches that were completed successfully by the background task that cleans up deferred dropped allocation units | counter | `mssql_instance` |
| `windows_mssql_accessmethods_au_cleanups` | The total number of allocation units that were successfully dropped the background task that cleans up deferred dropped allocation units. Each allocation unit drop requires multiple batches | counter | `mssql_instance` |
| `windows_mssql_accessmethods_by_reference_lob_creates` | The total count of large object (lob) values that were passed by reference. By-reference lobs are used in certain bulk operations to avoid the cost of passing them by value | counter | `mssql_instance` |
| `windows_mssql_accessmethods_by_reference_lob_uses` | The total count of by-reference lob values that were used. By-reference lobs are used in certain bulk operations to avoid the cost of passing them by-value | counter | `mssql_instance` |
| `windows_mssql_accessmethods_lob_read_aheads` | The total count of lob pages on which readahead was issued | counter | `mssql_instance` |
| `windows_mssql_accessmethods_column_value_pulls` | The total count of column values that were pulled in-row from off-row | counter | `mssql_instance` |
| `windows_mssql_accessmethods_column_value_pushes` | The total count of column values that were pushed from in-row to off-row | counter | `mssql_instance` |
| `windows_mssql_accessmethods_deferred_dropped_aus` | The total number of allocation units waiting to be dropped by the background task that cleans up deferred dropped allocation units | gauge | `mssql_instance` |
| `windows_mssql_accessmethods_deferred_dropped_rowsets` | The number of rowsets created as a result of aborted online index build operations that are waiting to be dropped by the background task that cleans up deferred dropped rowsets | gauge | `mssql_instance` |
| `windows_mssql_accessmethods_dropped_rowset_cleanups` | The number of rowsets per second created as a result of aborted online index build operations that were successfully dropped by the background task that cleans up deferred dropped rowsets | counter | `mssql_instance` |
| `windows_mssql_accessmethods_dropped_rowset_skips` | The number of rowsets per second created as a result of aborted online index build operations that were skipped by the background task that cleans up deferred dropped rowsets created | counter | `mssql_instance` |
| `windows_mssql_accessmethods_extent_deallocations` | Number of extents deallocated per second in all databases in this instance of SQL Server | counter | `mssql_instance` |
| `windows_mssql_accessmethods_extent_allocations` | Number of extents allocated per second in all databases in this instance of SQL Server | counter | `mssql_instance` |
| `windows_mssql_accessmethods_au_batch_cleanup_failures` | The number of batches per second that failed and required retry, by the background task that cleans up deferred dropped allocation units. Failure could be due to lack of memory or disk space, hardware failure and other reasons | counter | `mssql_instance` |
| `windows_mssql_accessmethods_leaf_page_cookie_failures` | The number of times that a leaf page cookie could not be used during an index search since changes happened on the leaf page. The cookie is used to speed up index search | counter | `mssql_instance` |
| `windows_mssql_accessmethods_tree_page_cookie_failures` | The number of times that a tree page cookie could not be used during an index search since changes happened on the parent pages of those tree pages. The cookie is used to speed up index search | counter | `mssql_instance` |
| `windows_mssql_accessmethods_forwarded_records` | Number of records per second fetched through forwarded record pointers | counter | `mssql_instance` |
| `windows_mssql_accessmethods_free_space_page_fetches` | Number of pages fetched per second by free space scans. These scans search for free space within pages already allocated to an allocation unit, to satisfy requests to insert or modify record fragments | counter | `mssql_instance` |
| `windows_mssql_accessmethods_free_space_scans` | Number of scans per second that were initiated to search for free space within pages already allocated to an allocation unit to insert or modify record fragment. Each scan may find multiple pages | counter | `mssql_instance` |
| `windows_mssql_accessmethods_full_scans` | Number of unrestricted full scans per second. These can be either base-table or full-index scans | counter | `mssql_instance` |
| `windows_mssql_accessmethods_index_searches` | Number of index searches per second. These are used to start a range scan, reposition a range scan, revalidate a scan point, fetch a single index record, and search down the index to locate where to insert a new row | counter | `mssql_instance` |
| `windows_mssql_accessmethods_insysxact_waits` | Number of times a reader needs to wait for a page because the InSysXact bit is set | counter | `mssql_instance` |
| `windows_mssql_accessmethods_lob_handle_creates` | Count of temporary lobs created | counter | `mssql_instance` |
| `windows_mssql_accessmethods_lob_handle_destroys` | Count of temporary lobs destroyed | counter | `mssql_instance` |
| `windows_mssql_accessmethods_lob_ss_provider_creates` | Count of LOB Storage Service Providers (LobSSP) created. One worktable created per LobSSP | counter | `mssql_instance` |
| `windows_mssql_accessmethods_lob_ss_provider_destroys` | Count of LobSSP destroyed | counter | `mssql_instance` |
| `windows_mssql_accessmethods_lob_ss_provider_truncations` | Count of LobSSP truncated | counter | `mssql_instance` |
| `windows_mssql_accessmethods_mixed_page_allocations` | Number of pages allocated per second from mixed extents. These could be used for storing the IAM pages and the first eight pages that are allocated to an allocation unit | counter | `mssql_instance` |
| `windows_mssql_accessmethods_page_compression_attempts` | Number of pages evaluated for page-level compression. Includes pages that were not compressed because significant savings could be achieved. Includes all objects in the instance of SQL Server | counter | `mssql_instance` |
| `windows_mssql_accessmethods_page_deallocations` | Number of pages deallocated per second in all databases in this instance of SQL Server. These include pages from mixed extents and uniform extents | counter | `mssql_instance` |
| `windows_mssql_accessmethods_page_allocations` | Number of pages allocated per second in all databases in this instance of SQL Server. These include pages allocations from both mixed extents and uniform extents | counter | `mssql_instance` |
| `windows_mssql_accessmethods_page_compressions` | Number of data pages that are compressed by using PAGE compression. Includes all objects in the instance of SQL Server | counter | `mssql_instance` |
| `windows_mssql_accessmethods_page_splits` | Number of page splits per second that occur as the result of overflowing index pages | counter | `mssql_instance` |
| `windows_mssql_accessmethods_probe_scans` | Number of probe scans per second that are used to find at most one single qualified row in an index or base table directly | counter | `mssql_instance` |
| `windows_mssql_accessmethods_range_scans` | Number of qualified range scans through indexes per second | counter | `mssql_instance` |
| `windows_mssql_accessmethods_scan_point_revalidations` | Number of times per second that the scan point had to be revalidated to continue the scan | counter | `mssql_instance` |
| `windows_mssql_accessmethods_ghost_record_skips` | Number of ghosted records per second skipped during scans | counter | `mssql_instance` |
| `windows_mssql_accessmethods_table_lock_escalations` | Number of times locks on a table were escalated to the TABLE or HoBT granularity | counter | `mssql_instance` |
| `windows_mssql_accessmethods_leaf_page_cookie_uses` | Number of times a leaf page cookie is used successfully during an index search since no change happened on the leaf page. The cookie is used to speed up index search | counter | `mssql_instance` |
| `windows_mssql_accessmethods_tree_page_cookie_uses` | Number of times a tree page cookie is used successfully during an index search since no change happened on the parent page of the tree page. The cookie is used to speed up index search | counter | `mssql_instance` |
| `windows_mssql_accessmethods_workfile_creates` | Number of work files created per second. For example, work files could be used to store temporary results for hash joins and hash aggregates | counter | `mssql_instance` |
| `windows_mssql_accessmethods_worktables_creates` | Number of work tables created per second. For example, work tables could be used to store temporary results for query spool, lob variables, XML variables, and cursors | counter | `mssql_instance` |
| `windows_mssql_accessmethods_worktables_from_cache_ratio` | Percentage of work tables created where the initial two pages of the work table were not allocated but were immediately available from the work table cache | counter | `mssql_instance` |
| `windows_mssql_availreplica_received_from_replica_bytes` | Number of bytes received from the availability replica per second. Pings and status updates will generate network traffic even on databases with no user updates | counter | `mssql_instance`, `replica` |
| `windows_mssql_availreplica_sent_to_replica_bytes` | Number of bytes sent to the remote availability replica per second. On the primary replica this is the number of bytes sent to the secondary replica. On the secondary replica this is the number of bytes sent to the primary replica | counter | `mssql_instance`, `replica` |
| `windows_mssql_availreplica_sent_to_transport_bytes` | Actual number of bytes sent per second over the network to the remote availability replica. On the primary replica this is the number of bytes sent to the secondary replica. On the secondary replica this is the number of bytes sent to the primary replica | counter | `mssql_instance`, `replica` |
| `windows_mssql_availreplica_initiated_flow_controls` | Time in milliseconds that log stream messages waited for send flow control, in the last second | counter | `mssql_instance`, `replica` |
| `windows_mssql_availreplica_flow_control_wait_seconds` | Number of times flow-control initiated in the last second. Flow Control Time (ms/sec) divided by Flow Control/sec is the average time per wait | counter | `mssql_instance`, `replica` |
| `windows_mssql_availreplica_receives_from_replica` | Number of Always On messages received from thereplica per second | counter | `mssql_instance`, `replica` |
| `windows_mssql_availreplica_resent_messages` | Number of Always On messages resent in the last second | counter | `mssql_instance`, `replica` |
| `windows_mssql_availreplica_sends_to_replica` | Number of Always On messages sent to this availability replica per second | counter | `mssql_instance`, `replica` |
| `windows_mssql_availreplica_sends_to_transport` | Actual number of Always On messages sent per second over the network to the remote availability replica | counter | `mssql_instance`, `replica` |
| `windows_mssql_bufman_background_writer_pages` | Number of pages flushed to enforce the recovery interval settings | counter | `mssql_instance` |
| `windows_mssql_bufman_buffer_cache_hit_ratio` | Indicates the percentage of pages found in the buffer cache without having to read from disk. The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses | gauge | `mssql_instance` |
| `windows_mssql_bufman_checkpoint_pages` | Indicates the number of pages flushed to disk per second by a checkpoint or other operation that require all dirty pages to be flushed | counter | `mssql_instance` |
| `windows_mssql_bufman_database_pages` | Indicates the number of pages in the buffer pool with database content | gauge | `mssql_instance` |
| `windows_mssql_bufman_extension_allocated_pages` | Total number of non-free cache pages in the buffer pool extension file | gauge | `mssql_instance` |
| `windows_mssql_bufman_extension_free_pages` | Total number of free cache pages in the buffer pool extension file | gauge | `mssql_instance` |
| `windows_mssql_bufman_extension_in_use_as_percentage` | _Not yet documented_ | gauge | `mssql_instance` |
| `windows_mssql_bufman_extension_outstanding_io` | Percentage of the buffer pool extension paging file occupied by buffer manager pages | gauge | `mssql_instance` |
| `windows_mssql_bufman_extension_page_evictions` | Number of pages evicted from the buffer pool extension file per second | counter | `mssql_instance` |
| `windows_mssql_bufman_extension_page_reads` | Number of pages read from the buffer pool extension file per second | counter | `mssql_instance` |
| `windows_mssql_bufman_extension_page_unreferenced_seconds` | Average seconds a page will stay in the buffer pool extension without references to it | gauge | `mssql_instance` |
| `windows_mssql_bufman_extension_page_writes` | Number of pages written to the buffer pool extension file per second | counter | `mssql_instance` |
| `windows_mssql_bufman_free_list_stalls` | Indicates the number of requests per second that had to wait for a free page | counter | `mssql_instance` |
| `windows_mssql_bufman_integral_controller_slope` | The slope that integral controller for the buffer pool last used, times -10 billion | gauge | `mssql_instance` |
| `windows_mssql_bufman_lazywrites` | Indicates the number of buffers written per second by the buffer manager's lazy writer | counter | `mssql_instance` |
| `windows_mssql_bufman_page_life_expectancy_seconds` | Indicates the number of seconds a page will stay in the buffer pool without references | gauge | `mssql_instance` |
| `windows_mssql_bufman_page_lookups` | Indicates the number of requests per second to find a page in the buffer pool | counter | `mssql_instance` |
| `windows_mssql_bufman_page_reads` | Indicates the number of physical database page reads that are issued per second | counter | `mssql_instance` |
| `windows_mssql_bufman_page_writes` | Indicates the number of physical database page writes that are issued per second | counter | `mssql_instance` |
| `windows_mssql_bufman_read_ahead_pages` | Indicates the number of pages read per second in anticipation of use | counter | `mssql_instance` |
| `windows_mssql_bufman_read_ahead_issuing_seconds` | Time (microseconds) spent issuing readahead | counter | `mssql_instance` |
| `windows_mssql_bufman_target_pages` | Ideal number of pages in the buffer pool | gauge | `mssql_instance` |
| `windows_mssql_dbreplica_database_flow_control_wait_seconds` | _Not yet documented_ | gauge | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_database_initiated_flow_controls` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_received_file_bytes` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_group_commits` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_group_commit_stall_seconds` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_apply_pending_queue` | _Not yet documented_ | gauge | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_apply_ready_queue` | _Not yet documented_ | gauge | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_compressed_bytes` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_decompressed_bytes` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_received_bytes` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_compression_cachehits` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_compression_cachemisses` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_compressions` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_decompressions` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_remaining_for_undo` | The amount of log, in bytes, remaining to complete the undo phase | gauge | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_log_send_queue` | Amount of log records in the log files of the primary database, in kilobytes, that haven't been sent to the secondary replica | gauge | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_mirrored_write_transactions` | Number of transactions that were written to the primary database and then waited to commit until the log was sent to the secondary database, in the last second | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_recovery_queue_records` | Amount of log records in the log files of the secondary replica that have not been redone | gauge | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_redo_blocks` | Number of times the redo thread was blocked on locks held by readers of the database | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_redo_remaining_bytes` | The amount of log, in kilobytes, remaining to be redone to finish the reverting phase | gauge | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_redone_bytes` | Amount of log records redone on the secondary database in the last second | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_redones` | _Not yet documented_ | counter | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_total_log_requiring_undo` | Total kilobytes of log that must be undone | gauge | `mssql_instance`, `replica` |
| `windows_mssql_dbreplica_transaction_delay_seconds` | Delay in waiting for unterminated commit acknowledgment for all the current transactions | gauge | `mssql_instance`, `replica` |
| `windows_mssql_databases_active_transactions` | Number of active transactions for the database | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_backup_restore_operations` | Read/write throughput for backup and restore operations of a database per second | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_bulk_copy_rows` | Number of rows bulk copied per second | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_bulk_copy_bytes` | Amount of data bulk copied (in kilobytes) per second | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_commit_table_entries` | he size (row count) of the in-memory portion of the commit table for the database | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_data_files_size_bytes` | Cumulative size (in kilobytes) of all the data files in the database including any automatic growth. Monitoring this counter is useful, for example, for determining the correct size of tempdb | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_dbcc_logical_scan_bytes` | Number of logical read scan bytes per second for database console commands (DBCC) | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_group_commit_stall_seconds` | Group stall time (microseconds) per second | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_flushed_bytes` | Total number of log bytes flushed | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_cache_hit_ratio` | Percentage of log cache reads satisfied from the log cache | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_log_cache_reads` | Reads performed per second through the log manager cache | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_files_size_bytes` | Cumulative size (in kilobytes) of all the transaction log files in the database | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_log_files_used_size_bytes` | The cumulative used size of all the log files in the database | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_log_flushes` | Total wait time (in milliseconds) to flush the log. On an Always On secondary database, this value indicates the wait time for log records to be hardened to disk | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_flush_waits` | Number of commits per second waiting for the log flush | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_flush_wait_seconds` | Number of commits per second waiting for the log flush | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_log_flush_write_seconds` | Time in milliseconds for performing writes of log flushes that were completed in the last second | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_log_growths` | Total number of times the transaction log for the database has been expanded | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_cache_misses` | Number of requests for which the log block was not available in the log pool | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_disk_reads` | Number of disk reads that the log pool issued to fetch log blocks | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_hash_deletes` | Rate of raw hash entry deletes from the Log Pool | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_hash_inserts` | Rate of raw hash entry inserts into the Log Pool | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_invalid_hash_entries` | Rate of hash lookups failing due to being invalid | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_log_scan_pushes` | Rate of Log block pushes by log scans, which may come from disk or memory | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_log_writer_pushes` | Rate of Log block pushes by log writer thread | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_empty_free_pool_pushes` | Rate of Log block push fails due to empty free pool | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_low_memory_pushes` | Rate of Log block push fails due to being low on memory | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_no_free_buffer_pushes` | Rate of Log block push fails due to free buffer unavailable | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_req_behind_trunc` | Log pool cache misses due to block requested being behind truncation LSN | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_requests_old_vlf` | Log Pool requests that were not in the last VLF of the log | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_requests` | The number of log-block requests processed by the log pool | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_total_active_log_bytes` | Current total active log stored in the shared cache buffer manager in bytes | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_log_pool_total_shared_pool_bytes` | Current total memory usage of the shared cache buffer manager in bytes | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_log_shrinks` | Total number of log shrinks for this database | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_log_truncations` | The number of times the transaction log has been truncated (in Simple Recovery Model) | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_log_used_percent` | Percentage of space in the log that is in use | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_pending_repl_transactions` | Number of transactions in the transaction log of the publication database marked for replication, but not yet delivered to the distribution database | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_repl_transactions` | Number of transactions per second read out of the transaction log of the publication database and delivered to the distribution database | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_shrink_data_movement_bytes` | Amount of data being moved per second by autoshrink operations, or DBCC SHRINKDATABASE or DBCC SHRINKFILE statements | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_tracked_transactions` | Number of committed transactions recorded in the commit table for the database | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_transactions` | Number of transactions started for the database per second | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_write_transactions` | Number of transactions that wrote to the database and committed, in the last second | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_xtp_controller_dlc_fetch_latency_seconds` | Average latency in microseconds between log blocks entering the Direct Log Consumer and being retrieved by the XTP controller, per second | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_xtp_controller_dlc_peak_latency_seconds` | The largest recorded latency, in microseconds, of a fetch from the Direct Log Consumer by the XTP controller | gauge | `mssql_instance`, `database` |
| `windows_mssql_databases_xtp_controller_log_processed_bytes` | The amount of log bytes processed by the XTP controller thread, per second | counter | `mssql_instance`, `database` |
| `windows_mssql_databases_xtp_memory_used_bytes` | The amount of memory used by XTP in the database | gauge | `mssql_instance`, `database` |
| `windows_mssql_genstats_active_temp_tables` | Number of temporary tables/table variables in use | gauge | `mssql_instance` |
| `windows_mssql_genstats_connection_resets` | Total number of logins started from the connection pool | counter | `mssql_instance` |
| `windows_mssql_genstats_event_notifications_delayed_drop` | Number of event notifications waiting to be dropped by a system thread | gauge | `mssql_instance` |
| `windows_mssql_genstats_http_authenticated_requests` | Number of authenticated HTTP requests started per second | gauge | `mssql_instance` |
| `windows_mssql_genstats_logical_connections` | Number of logical connections to the system | gauge | `mssql_instance` |
| `windows_mssql_genstats_logins` | Total number of logins started per second. This does not include pooled connections | counter | `mssql_instance` |
| `windows_mssql_genstats_logouts` | Total number of logout operations started per second | counter | `mssql_instance` |
| `windows_mssql_genstats_mars_deadlocks` | Number of MARS deadlocks detected | gauge | `mssql_instance` |
| `windows_mssql_genstats_non_atomic_yields` | Number of non-atomic yields per second | counter | `mssql_instance` |
| `windows_mssql_genstats_blocked_processes` | Number of currently blocked processes | gauge | `mssql_instance` |
| `windows_mssql_genstats_soap_empty_requests` | Number of empty SOAP requests started per second | gauge | `mssql_instance` |
| `windows_mssql_genstats_soap_method_invocations` | Number of SOAP method invocations started per second | gauge | `mssql_instance` |
| `windows_mssql_genstats_soap_session_initiate_requests` | Number of SOAP Session initiate requests started per second | gauge | `mssql_instance` |
| `windows_mssql_genstats_soap_session_terminate_requests` | Number of SOAP Session terminate requests started per second | gauge | `mssql_instance` |
| `windows_mssql_genstats_soapsql_requests` | Number of SOAP SQL requests started per second | gauge | `mssql_instance` |
| `windows_mssql_genstats_soapwsdl_requests` | Number of SOAP Web Service Description Language requests started per second | gauge | `mssql_instance` |
| `windows_mssql_genstats_sql_trace_io_provider_lock_waits` | Number of waits for the File IO Provider lock per second | gauge | `mssql_instance` |
| `windows_mssql_genstats_tempdb_recovery_unit_ids_generated` | Number of duplicate tempdb recovery unit id generated | gauge | `mssql_instance` |
| `windows_mssql_genstats_tempdb_rowset_ids_generated` | Number of duplicate tempdb rowset id generated | gauge | `mssql_instance` |
| `windows_mssql_genstats_temp_tables_creations` | Number of temporary tables/table variables created per second | counter | `mssql_instance` |
| `windows_mssql_genstats_temp_tables_awaiting_destruction` | Number of temporary tables/table variables waiting to be destroyed by the cleanup system thread | gauge | `mssql_instance` |
| `windows_mssql_genstats_trace_event_notification_queue_size` | Number of trace event notification instances waiting in the internal queue to be sent through Service Broker | gauge | `mssql_instance` |
| `windows_mssql_genstats_transactions` | Number of transaction enlistments (local, DTC, bound all combined) | gauge | `mssql_instance` |
| `windows_mssql_genstats_user_connections` | Counts the number of users currently connected to SQL Server | gauge | `mssql_instance` |
| `windows_mssql_instance_info ` | Returns information about the MSSQL server running on port 1433 | gauge | `version` |
| `windows_mssql_locks_average_wait_seconds` | Average amount of wait time (in milliseconds) for each lock request that resulted in a wait | gauge | `mssql_instance`, `resource` |
| `windows_mssql_locks_lock_requests` | Number of new locks and lock conversions per second requested from the lock manager | counter | `mssql_instance`, `resource` |
| `windows_mssql_locks_lock_timeouts` | Number of lock requests per second that timed out, including requests for NOWAIT locks | counter | `mssql_instance`, `resource` |
| `windows_mssql_locks_lock_timeouts_excluding_NOWAIT` | Number of lock requests per second that timed out, but excluding requests for NOWAIT locks | counter | `mssql_instance`, `resource` |
| `windows_mssql_locks_lock_waits` | Total wait time (in milliseconds) for locks in the last second | counter | `mssql_instance`, `resource` |
| `windows_mssql_locks_lock_wait_seconds` | Number of lock requests per second that required the caller to wait | gauge | `mssql_instance`, `resource` |
| `windows_mssql_locks_deadlocks` | Number of lock requests per second that resulted in a deadlock | counter | `mssql_instance`, `resource` |
| `windows_mssql_memmgr_connection_memory_bytes` | Specifies the total amount of dynamic memory the server is using for maintaining connections | gauge | `mssql_instance` |
| `windows_mssql_memmgr_database_cache_memory_bytes` | Specifies the amount of memory the server is currently using for the database pages cache | gauge | `mssql_instance` |
| `windows_mssql_memmgr_external_benefit_of_memory` | An internal estimation of the performance benefit from adding memory to a specific cache | gauge | `mssql_instance` |
| `windows_mssql_memmgr_free_memory_bytes` | Specifies the amount of committed memory currently not used by the server | gauge | `mssql_instance` |
| `windows_mssql_memmgr_granted_workspace_memory_bytes` | Specifies the total amount of memory currently granted to executing processes, such as hash, sort, bulk copy, and index creation operations | gauge | `mssql_instance` |
| `windows_mssql_memmgr_lock_blocks` | Specifies the current number of lock blocks in use on the server (refreshed periodically). A lock block represents an individual locked resource, such as a table, page, or row | gauge | `mssql_instance` |
| `windows_mssql_memmgr_allocated_lock_blocks` | Specifies the current number of allocated lock blocks. At server startup, the number of allocated lock blocks plus the number of allocated lock owner blocks depends on the SQL Server Locks configuration option. If more lock blocks are needed, the value increases | gauge | `mssql_instance` |
| `windows_mssql_memmgr_lock_memory_bytes` | Specifies the total amount of dynamic memory the server is using for locks | gauge | `mssql_instance` |
| `windows_mssql_memmgr_lock_owner_blocks` | Specifies the current number of allocated lock owner blocks. At server startup, the number of allocated lock owner blocks and the number of allocated lock blocks depend on the SQL Server Locks configuration option. If more lock owner blocks are needed, the value increases dynamically | gauge | `mssql_instance` |
| `windows_mssql_memmgr_allocated_lock_owner_blocks` | _Not yet documented_ | gauge | `mssql_instance` |
| `windows_mssql_memmgr_log_pool_memory_bytes` | Total amount of dynamic memory the server is using for Log Pool | gauge | `mssql_instance` |
| `windows_mssql_memmgr_maximum_workspace_memory_bytes` | Indicates the maximum amount of memory available for executing processes, such as hash, sort, bulk copy, and index creation operations | gauge | `mssql_instance` |
| `windows_mssql_memmgr_outstanding_memory_grants` | Specifies the total number of processes that have successfully acquired a workspace memory grant | gauge | `mssql_instance` |
| `windows_mssql_memmgr_pending_memory_grants` | Specifies the total number of processes waiting for a workspace memory grant | gauge | `mssql_instance` |
| `windows_mssql_memmgr_optimizer_memory_bytes` | Specifies the total amount of dynamic memory the server is using for query optimization | gauge | `mssql_instance` |
| `windows_mssql_memmgr_reserved_server_memory_bytes` | ndicates the amount of memory the server has reserved for future usage. This counter shows the current unused amount of memory initially granted that is shown in Granted Workspace Memory | gauge | `mssql_instance` |
| `windows_mssql_memmgr_sql_cache_memory_bytes` | Specifies the total amount of dynamic memory the server is using for the dynamic SQL cache | gauge | `mssql_instance` |
| `windows_mssql_memmgr_stolen_server_memory_bytes` | Specifies the amount of memory the server is using for purposes other than database pages | gauge | `mssql_instance` |
| `windows_mssql_memmgr_target_server_memory_bytes` | Indicates the ideal amount of memory the server can consume | gauge | `mssql_instance` |
| `windows_mssql_memmgr_total_server_memory_bytes` | Specifies the amount of memory the server has committed using the memory manager | gauge | `mssql_instance` |
| `windows_mssql_sqlstats_auto_parameterization_attempts` | Number of failed auto-parameterization attempts per second. This should be small. Note that auto-parameterizations are also known as simple parameterizations in later versions of SQL Server | counter | `mssql_instance` |
| `windows_mssql_sqlstats_batch_requests` | _Not yet documented_ | counter | `mssql_instance` |
| `windows_mssql_sqlstats_failed_auto_parameterization_attempts` | _Not yet documented_ | counter | `mssql_instance` |
| `windows_mssql_sqlstats_forced_parameterizations` | Number of successful forced parameterizations per second | counter | `mssql_instance` |
| `windows_mssql_sqlstats_guided_plan_executions` | Number of plan executions per second in which the query plan has been generated by using a plan guide | counter | `mssql_instance` |
| `windows_mssql_sqlstats_misguided_plan_executions` | Number of plan executions per second in which a plan guide could not be honored during plan generation | counter | `mssql_instance` |
| `windows_mssql_sqlstats_safe_auto_parameterization_attempts` | Number of safe auto-parameterization attempts per second | counter | `mssql_instance` |
| `windows_mssql_sqlstats_sql_attentions` | Number of attentions per second | counter | `mssql_instance` |
| `windows_mssql_sqlstats_sql_compilations` | Number of SQL compilations per second | counter | `mssql_instance` |
| `windows_mssql_sqlstats_sql_recompilations` | Number of statement recompiles per second | counter | `mssql_instance` |
| `windows_mssql_sqlstats_unsafe_auto_parameterization_attempts` | Number of unsafe auto-parameterization attempts per second. | counter | `mssql_instance` |
| `windows_mssql_sql_errors_total` | Information for all errors | counter | `mssql_instance`, `resource` |
| `windows_mssql_transactions_tempdb_free_space_bytes` | The amount of space (in kilobytes) available in tempdb | gauge | `mssql_instance` |
| `windows_mssql_transactions_longest_transaction_running_seconds` | The length of time (in seconds) since the start of the transaction that has been active longer than any other current transaction | gauge | `mssql_instance` |
| `windows_mssql_transactions_nonsnapshot_version_active_total` | The number of currently active transactions that are not using snapshot isolation level and have made data modifications that have generated row versions in the tempdb version store | counter | `mssql_instance` |
| `windows_mssql_transactions_snapshot_active_total` | The number of currently active transactions using the snapshot isolation level | counter | `mssql_instance` |
| `windows_mssql_transactions_active` | The number of currently active transactions of all types | gauge | `mssql_instance` |
| `windows_mssql_transactions_update_conflicts_total` | The percentage of those transactions using the snapshot isolation level that have encountered update conflicts within the last second | counter | `mssql_instance` |
| `windows_mssql_transactions_update_snapshot_active_total` | The number of currently active transactions using the snapshot isolation level and have modified data | counter | `mssql_instance` |
| `windows_mssql_transactions_version_cleanup_rate_bytes` | The rate (in kilobytes per second) at which row versions are removed from the snapshot isolation version store in tempdb | gauge | `mssql_instance` |
| `windows_mssql_transactions_version_generation_rate_bytes` | The rate (in kilobytes per second) at which new row versions are added to the snapshot isolation version store in tempdb | gauge | `mssql_instance` |
| `windows_mssql_transactions_version_store_size_bytes` | he amount of space (in kilobytes) in tempdb being used to store snapshot isolation level row versions | gauge | `mssql_instance` |
| `windows_mssql_transactions_version_store_units` | The number of active allocation units in the snapshot isolation version store in tempdb | counter | `mssql_instance` |
| `windows_mssql_transactions_version_store_creation_units` | The number of allocation units that have been created in the snapshot isolation store since the instance of the Database Engine was started | counter | `mssql_instance` |
| `windows_mssql_transactions_version_store_truncation_units` | The number of allocation units that have been removed from the snapshot isolation store since the instance of the Database Engine was started | counter | `mssql_instance` |
| `windows_mssql_waitstats_lock_waits` | Statistics for processes waiting on a lock | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_memory_grant_queue_waits` | Statistics for processes waiting for memory grant to become available | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_thread_safe_memory_objects_waits` | Statistics for processes waiting on thread-safe memory allocators | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_log_write_waits` | Statistics for processes waiting for log buffer to be written | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_log_buffer_waits` | Statistics for processes waiting for log buffer to be available | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_network_io_waits` | Statistics relevant to wait on network I/O | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_page_io_latch_waits` | Statistics relevant to page I/O latches | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_page_latch_waits` | Statistics relevant to page latches, not including I/O latches | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_nonpage_latch_waits` | Statistics relevant to non-page latches | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_wait_for_the_worker_waits` | Statistics relevant to processes waiting for worker to become available | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_workspace_synchronization_waits` | Statistics relevant to processes synchronizing access to workspace | gauge | `mssql_instance`, `item` |
| `windows_mssql_waitstats_transaction_ownership_waits` | Statistics relevant to processes synchronizing access to transaction | gauge | `mssql_instance`, `item` |
### Example metric
@@ -311,4 +312,4 @@ groups:
summary: "SQl EXpress Database size exceeded 10GB"
description: "The database size has grown larger than 10GB. Instance: {{ $labels.instance }}"
```
```

View File

@@ -1,114 +0,0 @@
# Perfdata collector
The perfdata collector exposes any configured metric.
| | |
|---------------------|-------------------------|
| Metric name prefix | `perfdata` |
| Data source | Performance Data Helper |
| Enabled by default? | No |
## Flags
### `--collector.perfdata.objects`
Objects is a list of objects to collect metrics from. The value takes the form of a JSON array of strings. YAML is also supported.
The collector supports only english named counter. Localized counter-names are not supported.
#### Schema
YAML:
```yaml
- object: "Processor Information"
instances: ["*"]
instance_label: "core"
counters:
"% Processor Time": {}
- object: "Memory"
counters:
"Cache Faults/sec":
type: "counter"
```
JSON:
```json
[
{"object":"Processor Information","instance_label": "core","instances":["*"],"counters": {"% Processor Time": {}}},
{"object":"Memory","counters": {"Cache Faults/sec": {"type": "counter"}}}
]
```
#### name
ObjectName is the Object to query for, like Processor, DirectoryServices, LogicalDisk or similar.
The collector supports only english named counter. Localized counter-names are not supported.
#### instances
The instances key (this is an array) declares the instances of a counter you would like returned, it can be one or more values.
Example: Instances = `["C:","D:","E:"]`
This will return only for the instances C:, D: and E: where relevant. To get all instances of a Counter, use `["*"]` only.
Some Objects like `Memory` do not have instances to select from at all. In this case, the `instances` key can be omitted.
#### counters
The Counters key (this is an object) declares the counters of the ObjectName you would like returned, it can also be one or more values.
Example: Counters = `{"% Idle Time": {}, "% Disk Read Time": {}, "% Disk Write Time": {}}`
This must be specified for every counter you want the results. Wildcards are not supported.
#### counters Sub-Schema
##### type
This key is optional. It indicates the type of the counter. The value can be `counter` or `gauge`.
If not specified, the windows_exporter will try to determine the type based on the counter type.
### Example
```
# HELP windows_perfdata_memory_cache_faults_sec
# TYPE windows_perfdata_memory_cache_faults_sec counter
windows_perfdata_memory_cache_faults_sec 2.369977e+07
# HELP windows_perfdata_processor_information__processor_time
# TYPE windows_perfdata_processor_information__processor_time gauge
windows_perfdata_processor_information__processor_time{instance="0,0"} 1.7259640625e+11
windows_perfdata_processor_information__processor_time{instance="0,1"} 1.7576796875e+11
windows_perfdata_processor_information__processor_time{instance="0,10"} 2.2704234375e+11
windows_perfdata_processor_information__processor_time{instance="0,11"} 2.3069296875e+11
windows_perfdata_processor_information__processor_time{instance="0,12"} 2.3302265625e+11
windows_perfdata_processor_information__processor_time{instance="0,13"} 2.32851875e+11
windows_perfdata_processor_information__processor_time{instance="0,14"} 2.3282421875e+11
windows_perfdata_processor_information__processor_time{instance="0,15"} 2.3271234375e+11
windows_perfdata_processor_information__processor_time{instance="0,16"} 2.329590625e+11
windows_perfdata_processor_information__processor_time{instance="0,17"} 2.32800625e+11
windows_perfdata_processor_information__processor_time{instance="0,18"} 2.3194359375e+11
windows_perfdata_processor_information__processor_time{instance="0,19"} 2.32380625e+11
windows_perfdata_processor_information__processor_time{instance="0,2"} 1.954765625e+11
windows_perfdata_processor_information__processor_time{instance="0,20"} 2.3259765625e+11
windows_perfdata_processor_information__processor_time{instance="0,21"} 2.3268515625e+11
windows_perfdata_processor_information__processor_time{instance="0,22"} 2.3301765625e+11
windows_perfdata_processor_information__processor_time{instance="0,23"} 2.3264328125e+11
windows_perfdata_processor_information__processor_time{instance="0,3"} 1.94745625e+11
windows_perfdata_processor_information__processor_time{instance="0,4"} 2.2011453125e+11
windows_perfdata_processor_information__processor_time{instance="0,5"} 2.27244375e+11
windows_perfdata_processor_information__processor_time{instance="0,6"} 2.25501875e+11
windows_perfdata_processor_information__processor_time{instance="0,7"} 2.2995265625e+11
windows_perfdata_processor_information__processor_time{instance="0,8"} 2.2929890625e+11
windows_perfdata_processor_information__processor_time{instance="0,9"} 2.313540625e+11
windows_perfdata_processor_information__processor_time{instance="0,_Total"} 2.23009459635e+11
```
## Metrics
The perfdata collector returns metrics based on the user configuration.
The metrics are named based on the object name and the counter name.
The instance name is added as a label to the metric.

View File

@@ -0,0 +1,233 @@
# performancecounter collector
The performancecounter collector exposes any configured metric.
| | |
|---------------------|-------------------------|
| Metric name prefix | `performancecounter` |
| Data source | Performance Data Helper |
| Enabled by default? | No |
## Flags
### `--collector.performancecounter.objects`
Objects is a list of objects to collect metrics from. The value takes the form of a JSON array of strings.
YAML is supported.
The collector supports only English-named counter. Localized counter-names arent supported.
> [!CAUTION]
> If you are using a configuration file, the value must be kept as a string.
>
> Use a `|-` to keep the value as a string.
#### Example
```yaml
collector:
performancecounter:
objects: |-
- name: memory
object: "Memory"
counters:
- name: "Cache Faults/sec"
type: "counter" # optional
```
#### Schema
YAML:
<details>
<summary>Click to expand YAML schema</summary>
```yaml
- name: cpu # free text name
object: "Processor Information" # Performance counter object name
instances: ["*"]
instance_label: "core"
counters:
- name: "% Processor Time"
metric: windows_performancecounter_processor_information_processor_time # optional
labels:
state: active
- name: "% Idle Time"
metric: windows_performancecounter_processor_information_processor_time # optional
labels:
state: idle
- name: memory
object: "Memory"
counters:
- name: "Cache Faults/sec"
type: "counter" # optional
```
</details>
<details>
<summary>Click to expand JSON schema</summary>
```json
[
{
"name": "cpu",
"object": "Processor Information",
"instances": [
"*"
],
"instance_label": "core",
"counters": [
{
"name": "% Processor Time",
"metric": "windows_performancecounter_processor_information_processor_time",
"labels": {
"state": "active"
}
},
{
"name": "% Idle Time",
"metric": "windows_performancecounter_processor_information_processor_time",
"labels": {
"state": "idle"
}
}
]
},
{
"name": "memory",
"object": "Memory",
"counters": [
{
"name": "Cache Faults/sec",
"type": "counter"
}
]
}
]
```
</details>
#### name
The name is used to identify the object in the logs and metrics.
Must unique across all objects.
#### object
ObjectName is the Object to query for, like Processor, DirectoryServices, LogicalDisk or similar.
The collector supports only english named counter. Localized counter-names are not supported.
#### instances
The instances key (this is an array) declares the instances of a counter you would like returned, it can be one or more values.
Example: Instances = `["C:","D:","E:"]`
This will return only for the instances C:, D: and E: where relevant. To get all instances of a Counter, use `["*"]` only.
Some Objects like `Memory` do not have instances to select from at all. In this case, the `instances` key can be omitted.
#### counters
List of counters to collect from the object. See the counters sub-schema for more information.
#### counters Sub-Schema
##### name
The name of the counter to collect.
##### metric
It indicates the name of the metric to be exposed. If not specified, the metric name will be generated based on the object name and the counter name.
This key is optional.
##### type
It indicates the type of the counter. The value can be `counter` or `gauge`.
If not specified, the windows_exporter will try to determine the type based on the counter type.
This key is optional.
##### labels
Labels is a map of key-value pairs that will be added as labels to the metric.
### Example
```
# HELP windows_performancecounter_memory_cache_faults_sec
# TYPE windows_performancecounter_memory_cache_faults_sec counter
windows_performancecounter_memory_cache_faults_sec 7.028097e+06
# HELP windows_performancecounter_processor_information_processor_time
# TYPE windows_performancecounter_processor_information_processor_time counter
windows_performancecounter_processor_information_processor_time{core="0,0",state="active"} 8.3809375e+10
windows_performancecounter_processor_information_processor_time{core="0,0",state="idle"} 8380.9375
windows_performancecounter_processor_information_processor_time{core="0,1",state="active"} 8.2868125e+10
windows_performancecounter_processor_information_processor_time{core="0,1",state="idle"} 8286.8125
windows_performancecounter_processor_information_processor_time{core="0,10",state="active"} 9.720046875e+10
windows_performancecounter_processor_information_processor_time{core="0,10",state="idle"} 9720.046875
windows_performancecounter_processor_information_processor_time{core="0,11",state="active"} 9.994921875e+10
windows_performancecounter_processor_information_processor_time{core="0,11",state="idle"} 9994.921875
windows_performancecounter_processor_information_processor_time{core="0,12",state="active"} 1.014403125e+11
windows_performancecounter_processor_information_processor_time{core="0,12",state="idle"} 10144.03125
windows_performancecounter_processor_information_processor_time{core="0,13",state="active"} 1.0155453125e+11
windows_performancecounter_processor_information_processor_time{core="0,13",state="idle"} 10155.453125
windows_performancecounter_processor_information_processor_time{core="0,14",state="active"} 1.01290625e+11
windows_performancecounter_processor_information_processor_time{core="0,14",state="idle"} 10129.0625
windows_performancecounter_processor_information_processor_time{core="0,15",state="active"} 1.0134890625e+11
windows_performancecounter_processor_information_processor_time{core="0,15",state="idle"} 10134.890625
windows_performancecounter_processor_information_processor_time{core="0,16",state="active"} 1.01405625e+11
windows_performancecounter_processor_information_processor_time{core="0,16",state="idle"} 10140.5625
windows_performancecounter_processor_information_processor_time{core="0,17",state="active"} 1.0153421875e+11
windows_performancecounter_processor_information_processor_time{core="0,17",state="idle"} 10153.421875
windows_performancecounter_processor_information_processor_time{core="0,18",state="active"} 1.0086390625e+11
windows_performancecounter_processor_information_processor_time{core="0,18",state="idle"} 10086.390625
windows_performancecounter_processor_information_processor_time{core="0,19",state="active"} 1.0123453125e+11
windows_performancecounter_processor_information_processor_time{core="0,19",state="idle"} 10123.453125
windows_performancecounter_processor_information_processor_time{core="0,2",state="active"} 8.3548125e+10
windows_performancecounter_processor_information_processor_time{core="0,2",state="idle"} 8354.8125
windows_performancecounter_processor_information_processor_time{core="0,20",state="active"} 1.011703125e+11
windows_performancecounter_processor_information_processor_time{core="0,20",state="idle"} 10117.03125
windows_performancecounter_processor_information_processor_time{core="0,21",state="active"} 1.0140984375e+11
windows_performancecounter_processor_information_processor_time{core="0,21",state="idle"} 10140.984375
windows_performancecounter_processor_information_processor_time{core="0,22",state="active"} 1.014615625e+11
windows_performancecounter_processor_information_processor_time{core="0,22",state="idle"} 10146.15625
windows_performancecounter_processor_information_processor_time{core="0,23",state="active"} 1.0145125e+11
windows_performancecounter_processor_information_processor_time{core="0,23",state="idle"} 10145.125
windows_performancecounter_processor_information_processor_time{core="0,3",state="active"} 8.488953125e+10
windows_performancecounter_processor_information_processor_time{core="0,3",state="idle"} 8488.953125
windows_performancecounter_processor_information_processor_time{core="0,4",state="active"} 9.338234375e+10
windows_performancecounter_processor_information_processor_time{core="0,4",state="idle"} 9338.234375
windows_performancecounter_processor_information_processor_time{core="0,5",state="active"} 9.776453125e+10
windows_performancecounter_processor_information_processor_time{core="0,5",state="idle"} 9776.453125
windows_performancecounter_processor_information_processor_time{core="0,6",state="active"} 9.736265625e+10
windows_performancecounter_processor_information_processor_time{core="0,6",state="idle"} 9736.265625
windows_performancecounter_processor_information_processor_time{core="0,7",state="active"} 9.959375e+10
windows_performancecounter_processor_information_processor_time{core="0,7",state="idle"} 9959.375
windows_performancecounter_processor_information_processor_time{core="0,8",state="active"} 9.939421875e+10
windows_performancecounter_processor_information_processor_time{core="0,8",state="idle"} 9939.421875
windows_performancecounter_processor_information_processor_time{core="0,9",state="active"} 1.0059484375e+11
windows_performancecounter_processor_information_processor_time{core="0,9",state="idle"} 10059.484375
```
> [!NOTE]
> If you are using a configuration file, the value must be keep as string.
Example:
```yaml
collector:
performancecounter:
objects: |
```
## Metrics
The perfdata collector returns metrics based on the user configuration.
The metrics are named based on the object name and the counter name.
The instance name is added as a label to the metric.

View File

@@ -14,16 +14,16 @@ None
## Metrics
| Name | Description | Type | Labels |
|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|--------|
| `windows_system_context_switches_total` | Total number of [context switches](https://en.wikipedia.org/wiki/Context_switch) | counter | None |
| `windows_system_exception_dispatches_total` | Total exceptions dispatched by the system | counter | None |
| `windows_system_processes` | Number of process contexts currently loaded or running on the operating system | gauge | None |
| `windows_system_process_limit` | The size of the user-mode portion of the virtual address space of the calling process, in bytes. This value depends on the type of process, the type of processor, and the configuration of the operating system. | gauge | None |
| `windows_system_processor_queue_length` | Number of threads in the processor queue. There is a single queue for processor time even on computers with multiple processors. | gauge | None |
| `windows_system_system_calls_total` | Total combined calls to Windows NT system service routines by all processes running on the computer | counter | None |
| `windows_system_system_up_time` | Time of last boot of system | gauge | None |
| `windows_system_threads` | Number of Windows system [threads](https://en.wikipedia.org/wiki/Thread_(computing)) | gauge | None |
| Name | Description | Type | Labels |
|----------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|--------|
| `windows_system_boot_time_timestamp_seconds` | Unix timestamp of last system boot | gauge | None |
| `windows_system_context_switches_total` | Total number of [context switches](https://en.wikipedia.org/wiki/Context_switch) | counter | None |
| `windows_system_exception_dispatches_total` | Total exceptions dispatched by the system | counter | None |
| `windows_system_processes` | Number of process contexts currently loaded or running on the operating system | gauge | None |
| `windows_system_process_limit` | The size of the user-mode portion of the virtual address space of the calling process, in bytes. This value depends on the type of process, the type of processor, and the configuration of the operating system. | gauge | None |
| `windows_system_processor_queue_length` | Number of threads in the processor queue. There is a single queue for processor time even on computers with multiple processors. | gauge | None |
| `windows_system_system_calls_total` | Total combined calls to Windows NT system service routines by all processes running on the computer | counter | None |
| `windows_system_threads` | Number of Windows system [threads](https://en.wikipedia.org/wiki/Thread_(computing)) | gauge | None |
@@ -41,7 +41,7 @@ windows_system_processes{instance="localhost"}
## Useful queries
Find hosts that have rebooted in the last 24 hours
```
time() - windows_system_system_up_time < 86400
time() - windows_system_boot_time_timestamp_seconds < 86400
```
## Alerting examples

32
go.mod
View File

@@ -11,10 +11,10 @@ require (
github.com/google/uuid v1.6.0
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/client_model v0.6.1
github.com/prometheus/common v0.60.1
github.com/prometheus/exporter-toolkit v0.13.1
github.com/stretchr/testify v1.9.0
golang.org/x/sys v0.27.0
github.com/prometheus/common v0.61.0
github.com/prometheus/exporter-toolkit v0.13.2
github.com/stretchr/testify v1.10.0
golang.org/x/sys v0.29.0
gopkg.in/yaml.v3 v3.0.1
)
@@ -23,14 +23,14 @@ require (
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/cgroups/v3 v3.0.3 // indirect
github.com/containerd/errdefs v0.3.0 // indirect
github.com/containerd/cgroups/v3 v3.0.4 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
github.com/containerd/typeurl/v2 v2.2.0 // indirect
github.com/containerd/typeurl/v2 v2.2.3 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
@@ -43,13 +43,13 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.32.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/grpc v1.68.0 // indirect
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

65
go.sum
View File

@@ -17,14 +17,14 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0=
github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0=
github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4=
github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
github.com/containerd/cgroups/v3 v3.0.4 h1:2fs7l3P0Qxb1nKWuJNFiwhp2CqiKzho71DQkDrHJIo4=
github.com/containerd/cgroups/v3 v3.0.4/go.mod h1:SA5DLYnXO8pTGYiAHXz94qvLQTKfVM5GEVisn4jpins=
github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI=
github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE=
github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk=
github.com/containerd/typeurl/v2 v2.2.0 h1:6NBDbQzr7I5LHgp34xAXYF5DOTQDn05X58lsPEmzLso=
github.com/containerd/typeurl/v2 v2.2.0/go.mod h1:8XOOxnyatxSWuG8OfsZXVnAF4iZfedjS/8UHSPJnX4g=
github.com/containerd/typeurl/v2 v2.2.3 h1:yNA/94zxWdvYACdYO8zofhrTVuQY73fFU1y++dYSw40=
github.com/containerd/typeurl/v2 v2.2.3/go.mod h1:95ljDnPfD3bAbDJRugOiShd/DlAAsxGtUBhJxIn7SCk=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -43,8 +43,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -55,6 +55,8 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@@ -95,10 +97,10 @@ github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/j
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
github.com/prometheus/exporter-toolkit v0.13.1 h1:Evsh0gWQo2bdOHlnz9+0Nm7/OFfIwhE2Ws4A2jIlR04=
github.com/prometheus/exporter-toolkit v0.13.1/go.mod h1:ujdv2YIOxtdFxxqtloLpbqmxd5J0Le6IITUvIRSWjj0=
github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFSRQQ=
github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s=
github.com/prometheus/exporter-toolkit v0.13.2 h1:Z02fYtbqTMy2i/f+xZ+UK5jy/bl1Ex3ndzh06T/Q9DQ=
github.com/prometheus/exporter-toolkit v0.13.2/go.mod h1:tCqnfx21q6qN1KA4U3Bfb8uWzXfijIrJz3/kTIqMV7g=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
@@ -114,8 +116,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -125,8 +128,8 @@ go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
@@ -142,30 +145,30 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
@@ -183,15 +186,15 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 h1:LWZqQOEjDyONlF1H6afSWpAL/znlREo2tHfLoe+8LMA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -201,8 +204,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

View File

@@ -1,5 +1,20 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<!--
~ Copyright 2024 The Prometheus Authors
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<Wix xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<DirectoryRef Id="APPLICATIONFOLDER">
<Component Transitive="yes">
@@ -13,7 +28,7 @@
Start="auto"
Type="ownProcess"
Vital="yes"
Arguments="--log.file eventlog [ConfigFileFlag] [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirsFlag] [ExtraFlags]">
Arguments="[ConfigFileFlag] [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirsFlag] [ExtraFlags]">
<util:ServiceConfig
ResetPeriodInDays="1"
FirstFailureActionType="restart"

View File

@@ -9,9 +9,24 @@
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:fw="http://wixtoolset.org/schemas/v4/wxs/firewall"
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<!--
~ Copyright 2024 The Prometheus Authors
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<Wix xmlns:fw="http://wixtoolset.org/schemas/v4/wxs/firewall"
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui"
xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package UpgradeCode="66a6eb5b-1fc2-4b14-a362-5ceec6413308" Name="$(var.ProductName)" Version="$(var.Version)"
Manufacturer="prometheus-community" Language="1033" Scope="perMachine">
<SummaryInformation Manufacturer="prometheus-community" Description="$(var.ProductName) $(var.Version) installer" />

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package ad_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, ad.Name, ad.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, ad.New, nil)
}

View File

@@ -1,207 +0,0 @@
package ad
const (
abANRPerSec = "AB ANR/sec"
abBrowsesPerSec = "AB Browses/sec"
abClientSessions = "AB Client Sessions"
abMatchesPerSec = "AB Matches/sec"
abPropertyReadsPerSec = "AB Property Reads/sec"
abProxyLookupsPerSec = "AB Proxy Lookups/sec"
abSearchesPerSec = "AB Searches/sec"
approximateHighestDNT = "Approximate highest DNT"
atqEstimatedQueueDelay = "ATQ Estimated Queue Delay"
atqOutstandingQueuedRequests = "ATQ Outstanding Queued Requests"
_ = "ATQ Queue Latency"
atqRequestLatency = "ATQ Request Latency"
atqThreadsLDAP = "ATQ Threads LDAP"
atqThreadsOther = "ATQ Threads Other"
atqThreadsTotal = "ATQ Threads Total"
baseSearchesPerSec = "Base searches/sec"
databaseAddsPerSec = "Database adds/sec"
databaseDeletesPerSec = "Database deletes/sec"
databaseModifiesPerSec = "Database modifys/sec"
databaseRecyclesPerSec = "Database recycles/sec"
digestBindsPerSec = "Digest Binds/sec"
_ = "DirSync session throttling rate"
_ = "DirSync sessions in progress"
draHighestUSNCommittedHighPart = "DRA Highest USN Committed (High part)"
draHighestUSNCommittedLowPart = "DRA Highest USN Committed (Low part)"
draHighestUSNIssuedHighPart = "DRA Highest USN Issued (High part)"
draHighestUSNIssuedLowPart = "DRA Highest USN Issued (Low part)"
draInboundBytesCompressedBetweenSitesAfterCompressionSinceBoot = "DRA Inbound Bytes Compressed (Between Sites, After Compression) Since Boot"
draInboundBytesCompressedBetweenSitesAfterCompressionPerSec = "DRA Inbound Bytes Compressed (Between Sites, After Compression)/sec"
draInboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot = "DRA Inbound Bytes Compressed (Between Sites, Before Compression) Since Boot"
draInboundBytesCompressedBetweenSitesBeforeCompressionPerSec = "DRA Inbound Bytes Compressed (Between Sites, Before Compression)/sec"
draInboundBytesNotCompressedWithinSiteSinceBoot = "DRA Inbound Bytes Not Compressed (Within Site) Since Boot"
draInboundBytesNotCompressedWithinSitePerSec = "DRA Inbound Bytes Not Compressed (Within Site)/sec"
draInboundBytesTotalSinceBoot = "DRA Inbound Bytes Total Since Boot"
draInboundBytesTotalPerSec = "DRA Inbound Bytes Total/sec"
draInboundFullSyncObjectsRemaining = "DRA Inbound Full Sync Objects Remaining"
draInboundLinkValueUpdatesRemainingInPacket = "DRA Inbound Link Value Updates Remaining in Packet"
_ = "DRA Inbound Link Values/sec"
draInboundObjectUpdatesRemainingInPacket = "DRA Inbound Object Updates Remaining in Packet"
draInboundObjectsAppliedPerSec = "DRA Inbound Objects Applied/sec"
draInboundObjectsFilteredPerSec = "DRA Inbound Objects Filtered/sec"
draInboundObjectsPerSec = "DRA Inbound Objects/sec"
draInboundPropertiesAppliedPerSec = "DRA Inbound Properties Applied/sec"
draInboundPropertiesFilteredPerSec = "DRA Inbound Properties Filtered/sec"
draInboundPropertiesTotalPerSec = "DRA Inbound Properties Total/sec"
_ = "DRA Inbound Sync Link Deletion/sec"
draInboundTotalUpdatesRemainingInPacket = "DRA Inbound Total Updates Remaining in Packet"
draInboundValuesDNsOnlyPerSec = "DRA Inbound Values (DNs only)/sec"
draInboundValuesTotalPerSec = "DRA Inbound Values Total/sec"
_ = "DRA number of NC replication calls since boot"
_ = "DRA number of successful NC replication calls since boot"
draOutboundBytesCompressedBetweenSitesAfterCompressionSinceBoot = "DRA Outbound Bytes Compressed (Between Sites, After Compression) Since Boot"
draOutboundBytesCompressedBetweenSitesAfterCompressionPerSec = "DRA Outbound Bytes Compressed (Between Sites, After Compression)/sec"
draOutboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot = "DRA Outbound Bytes Compressed (Between Sites, Before Compression) Since Boot"
draOutboundBytesCompressedBetweenSitesBeforeCompressionPerSec = "DRA Outbound Bytes Compressed (Between Sites, Before Compression)/sec"
draOutboundBytesNotCompressedWithinSiteSinceBoot = "DRA Outbound Bytes Not Compressed (Within Site) Since Boot"
draOutboundBytesNotCompressedWithinSitePerSec = "DRA Outbound Bytes Not Compressed (Within Site)/sec"
draOutboundBytesTotalSinceBoot = "DRA Outbound Bytes Total Since Boot"
draOutboundBytesTotalPerSec = "DRA Outbound Bytes Total/sec"
draOutboundObjectsFilteredPerSec = "DRA Outbound Objects Filtered/sec"
draOutboundObjectsPerSec = "DRA Outbound Objects/sec"
draOutboundPropertiesPerSec = "DRA Outbound Properties/sec"
draOutboundValuesDNsOnlyPerSec = "DRA Outbound Values (DNs only)/sec"
draOutboundValuesTotalPerSec = "DRA Outbound Values Total/sec"
draPendingReplicationOperations = "DRA Pending Replication Operations"
draPendingReplicationSynchronizations = "DRA Pending Replication Synchronizations"
draSyncFailuresOnSchemaMismatch = "DRA Sync Failures on Schema Mismatch"
draSyncRequestsMade = "DRA Sync Requests Made"
draSyncRequestsSuccessful = "DRA Sync Requests Successful"
draThreadsGettingNCChanges = "DRA Threads Getting NC Changes"
draThreadsGettingNCChangesHoldingSemaphore = "DRA Threads Getting NC Changes Holding Semaphore"
_ = "DRA total number of Busy failures since boot"
_ = "DRA total number of MissingParent failures since boot"
_ = "DRA total number of NotEnoughAttrs/MissingObject failures since boot"
_ = "DRA total number of Preempted failures since boot"
_ = "DRA total time of applying replication package since boot"
_ = "DRA total time of NC replication calls since boot"
_ = "DRA total time of successful NC replication calls since boot"
_ = "DRA total time of successfully applying replication package since boot"
_ = "DRA total time on waiting async replication packages since boot"
_ = "DRA total time on waiting sync replication packages since boot"
dsPercentReadsFromDRA = "DS % Reads from DRA"
dsPercentReadsFromKCC = "DS % Reads from KCC"
dsPercentReadsFromLSA = "DS % Reads from LSA"
dsPercentReadsFromNSPI = "DS % Reads from NSPI"
dsPercentReadsFromNTDSAPI = "DS % Reads from NTDSAPI"
dsPercentReadsFromSAM = "DS % Reads from SAM"
dsPercentReadsOther = "DS % Reads Other"
dsPercentSearchesFromDRA = "DS % Searches from DRA"
dsPercentSearchesFromKCC = "DS % Searches from KCC"
dsPercentSearchesFromLDAP = "DS % Searches from LDAP"
dsPercentSearchesFromLSA = "DS % Searches from LSA"
dsPercentSearchesFromNSPI = "DS % Searches from NSPI"
dsPercentSearchesFromNTDSAPI = "DS % Searches from NTDSAPI"
dsPercentSearchesFromSAM = "DS % Searches from SAM"
dsPercentSearchesOther = "DS % Searches Other"
dsPercentWritesFromDRA = "DS % Writes from DRA"
dsPercentWritesFromKCC = "DS % Writes from KCC"
dsPercentWritesFromLDAP = "DS % Writes from LDAP"
dsPercentWritesFromLSA = "DS % Writes from LSA"
dsPercentWritesFromNSPI = "DS % Writes from NSPI"
dsPercentWritesFromNTDSAPI = "DS % Writes from NTDSAPI"
dsPercentWritesFromSAM = "DS % Writes from SAM"
dsPercentWritesOther = "DS % Writes Other"
dsClientBindsPerSec = "DS Client Binds/sec"
dsClientNameTranslationsPerSec = "DS Client Name Translations/sec"
dsDirectoryReadsPerSec = "DS Directory Reads/sec"
dsDirectorySearchesPerSec = "DS Directory Searches/sec"
dsDirectoryWritesPerSec = "DS Directory Writes/sec"
dsMonitorListSize = "DS Monitor List Size"
dsNameCacheHitRate = "DS Name Cache hit rate"
dsNotifyQueueSize = "DS Notify Queue Size"
dsSearchSubOperationsPerSec = "DS Search sub-operations/sec"
dsSecurityDescriptorPropagationsEvents = "DS Security Descriptor Propagations Events"
dsSecurityDescriptorPropagatorAverageExclusionTime = "DS Security Descriptor Propagator Average Exclusion Time"
dsSecurityDescriptorPropagatorRuntimeQueue = "DS Security Descriptor Propagator Runtime Queue"
dsSecurityDescriptorSubOperationsPerSec = "DS Security Descriptor sub-operations/sec"
dsServerBindsPerSec = "DS Server Binds/sec"
dsServerNameTranslationsPerSec = "DS Server Name Translations/sec"
dsThreadsInUse = "DS Threads in Use"
_ = "Error eventlogs since boot"
_ = "Error events since boot"
externalBindsPerSec = "External Binds/sec"
fastBindsPerSec = "Fast Binds/sec"
_ = "Fatal events since boot"
_ = "Info eventlogs since boot"
ldapActiveThreads = "LDAP Active Threads"
_ = "LDAP Add Operations"
_ = "LDAP Add Operations/sec"
_ = "LDAP batch slots available"
ldapBindTime = "LDAP Bind Time"
_ = "LDAP busy retries"
_ = "LDAP busy retries/sec"
ldapClientSessions = "LDAP Client Sessions"
ldapClosedConnectionsPerSec = "LDAP Closed Connections/sec"
_ = "LDAP Delete Operations"
_ = "LDAP Delete Operations/sec"
_ = "LDAP Modify DN Operations"
_ = "LDAP Modify DN Operations/sec"
_ = "LDAP Modify Operations"
_ = "LDAP Modify Operations/sec"
ldapNewConnectionsPerSec = "LDAP New Connections/sec"
ldapNewSSLConnectionsPerSec = "LDAP New SSL Connections/sec"
_ = "LDAP Outbound Bytes"
_ = "LDAP Outbound Bytes/sec"
_ = "LDAP Page Search Cache entries count"
_ = "LDAP Page Search Cache size"
ldapSearchesPerSec = "LDAP Searches/sec"
ldapSuccessfulBindsPerSec = "LDAP Successful Binds/sec"
_ = "LDAP Threads Sleeping on BUSY"
ldapUDPOperationsPerSec = "LDAP UDP operations/sec"
ldapWritesPerSec = "LDAP Writes/sec"
linkValuesCleanedPerSec = "Link Values Cleaned/sec"
_ = "Links added"
_ = "Links added/sec"
_ = "Links visited"
_ = "Links visited/sec"
_ = "Logical link deletes"
_ = "Logical link deletes/sec"
negotiatedBindsPerSec = "Negotiated Binds/sec"
ntlmBindsPerSec = "NTLM Binds/sec"
_ = "Objects returned"
_ = "Objects returned/sec"
_ = "Objects visited"
_ = "Objects visited/sec"
oneLevelSearchesPerSec = "Onelevel searches/sec"
_ = "PDC failed password update notifications"
_ = "PDC password update notifications/sec"
_ = "PDC successful password update notifications"
phantomsCleanedPerSec = "Phantoms Cleaned/sec"
phantomsVisitedPerSec = "Phantoms Visited/sec"
_ = "Physical link deletes"
_ = "Physical link deletes/sec"
_ = "Replicate Single Object operations"
_ = "Replicate Single Object operations/sec"
_ = "RID Pool invalidations since boot"
_ = "RID Pool request failures since boot"
_ = "RID Pool request successes since boot"
samAccountGroupEvaluationLatency = "SAM Account Group Evaluation Latency"
samDisplayInformationQueriesPerSec = "SAM Display Information Queries/sec"
samDomainLocalGroupMembershipEvaluationsPerSec = "SAM Domain Local Group Membership Evaluations/sec"
samEnumerationsPerSec = "SAM Enumerations/sec"
samGCEvaluationsPerSec = "SAM GC Evaluations/sec"
samGlobalGroupMembershipEvaluationsPerSec = "SAM Global Group Membership Evaluations/sec"
samMachineCreationAttemptsPerSec = "SAM Machine Creation Attempts/sec"
samMembershipChangesPerSec = "SAM Membership Changes/sec"
samNonTransitiveMembershipEvaluationsPerSec = "SAM Non-Transitive Membership Evaluations/sec"
samPasswordChangesPerSec = "SAM Password Changes/sec"
samResourceGroupEvaluationLatency = "SAM Resource Group Evaluation Latency"
samSuccessfulComputerCreationsPerSecIncludesAllRequests = "SAM Successful Computer Creations/sec: Includes all requests"
samSuccessfulUserCreationsPerSec = "SAM Successful User Creations/sec"
samTransitiveMembershipEvaluationsPerSec = "SAM Transitive Membership Evaluations/sec"
samUniversalGroupMembershipEvaluationsPerSec = "SAM Universal Group Membership Evaluations/sec"
samUserCreationAttemptsPerSec = "SAM User Creation Attempts/sec"
simpleBindsPerSec = "Simple Binds/sec"
subtreeSearchesPerSec = "Subtree searches/sec"
tombstonesGarbageCollectedPerSec = "Tombstones Garbage Collected/sec"
tombstonesVisitedPerSec = "Tombstones Visited/sec"
transitiveOperationsMillisecondsRun = "Transitive operations milliseconds run"
transitiveOperationsPerSec = "Transitive operations/sec"
transitiveSubOperationsPerSec = "Transitive suboperations/sec"
_ = "Warning eventlogs since boot"
_ = "Warning events since boot"
)

View File

@@ -0,0 +1,223 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package ad
type perfDataCounterValues struct {
AbANRPerSec float64 `perfdata:"AB ANR/sec"`
AbBrowsesPerSec float64 `perfdata:"AB Browses/sec"`
AbClientSessions float64 `perfdata:"AB Client Sessions"`
AbMatchesPerSec float64 `perfdata:"AB Matches/sec"`
AbPropertyReadsPerSec float64 `perfdata:"AB Property Reads/sec"`
AbProxyLookupsPerSec float64 `perfdata:"AB Proxy Lookups/sec"`
AbSearchesPerSec float64 `perfdata:"AB Searches/sec"`
ApproximateHighestDNT float64 `perfdata:"Approximate highest DNT"`
AtqEstimatedQueueDelay float64 `perfdata:"ATQ Estimated Queue Delay"`
AtqOutstandingQueuedRequests float64 `perfdata:"ATQ Outstanding Queued Requests"`
_ float64 `perfdata:"ATQ Queue Latency"`
AtqRequestLatency float64 `perfdata:"ATQ Request Latency"`
AtqThreadsLDAP float64 `perfdata:"ATQ Threads LDAP"`
AtqThreadsOther float64 `perfdata:"ATQ Threads Other"`
AtqThreadsTotal float64 `perfdata:"ATQ Threads Total"`
BaseSearchesPerSec float64 `perfdata:"Base searches/sec"`
DatabaseAddsPerSec float64 `perfdata:"Database adds/sec"`
DatabaseDeletesPerSec float64 `perfdata:"Database deletes/sec"`
DatabaseModifiesPerSec float64 `perfdata:"Database modifys/sec"`
DatabaseRecyclesPerSec float64 `perfdata:"Database recycles/sec"`
DigestBindsPerSec float64 `perfdata:"Digest Binds/sec"`
_ float64 `perfdata:"DirSync session throttling rate"`
_ float64 `perfdata:"DirSync sessions in progress"`
DRAHighestUSNCommittedHighPart float64 `perfdata:"DRA Highest USN Committed (High part)"`
DRAHighestUSNCommittedLowPart float64 `perfdata:"DRA Highest USN Committed (Low part)"`
DRAHighestUSNIssuedHighPart float64 `perfdata:"DRA Highest USN Issued (High part)"`
DRAHighestUSNIssuedLowPart float64 `perfdata:"DRA Highest USN Issued (Low part)"`
DRAInboundBytesCompressedBetweenSitesAfterCompressionSinceBoot float64 `perfdata:"DRA Inbound Bytes Compressed (Between Sites, After Compression) Since Boot"`
DRAInboundBytesCompressedBetweenSitesAfterCompressionPerSec float64 `perfdata:"DRA Inbound Bytes Compressed (Between Sites, After Compression)/sec"`
DRAInboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot float64 `perfdata:"DRA Inbound Bytes Compressed (Between Sites, Before Compression) Since Boot"`
DRAInboundBytesCompressedBetweenSitesBeforeCompressionPerSec float64 `perfdata:"DRA Inbound Bytes Compressed (Between Sites, Before Compression)/sec"`
DRAInboundBytesNotCompressedWithinSiteSinceBoot float64 `perfdata:"DRA Inbound Bytes Not Compressed (Within Site) Since Boot"`
DRAInboundBytesNotCompressedWithinSitePerSec float64 `perfdata:"DRA Inbound Bytes Not Compressed (Within Site)/sec"`
DRAInboundBytesTotalSinceBoot float64 `perfdata:"DRA Inbound Bytes Total Since Boot"`
DRAInboundBytesTotalPerSec float64 `perfdata:"DRA Inbound Bytes Total/sec"`
DRAInboundFullSyncObjectsRemaining float64 `perfdata:"DRA Inbound Full Sync Objects Remaining"`
DRAInboundLinkValueUpdatesRemainingInPacket float64 `perfdata:"DRA Inbound Link Value Updates Remaining in Packet"`
_ float64 `perfdata:"DRA Inbound Link Values/sec"`
DRAInboundObjectUpdatesRemainingInPacket float64 `perfdata:"DRA Inbound Object Updates Remaining in Packet"`
DRAInboundObjectsAppliedPerSec float64 `perfdata:"DRA Inbound Objects Applied/sec"`
DRAInboundObjectsFilteredPerSec float64 `perfdata:"DRA Inbound Objects Filtered/sec"`
DRAInboundObjectsPerSec float64 `perfdata:"DRA Inbound Objects/sec"`
DRAInboundPropertiesAppliedPerSec float64 `perfdata:"DRA Inbound Properties Applied/sec"`
DRAInboundPropertiesFilteredPerSec float64 `perfdata:"DRA Inbound Properties Filtered/sec"`
DRAInboundPropertiesTotalPerSec float64 `perfdata:"DRA Inbound Properties Total/sec"`
_ float64 `perfdata:"DRA Inbound Sync Link Deletion/sec"`
DRAInboundTotalUpdatesRemainingInPacket float64 `perfdata:"DRA Inbound Total Updates Remaining in Packet"`
DRAInboundValuesDNsOnlyPerSec float64 `perfdata:"DRA Inbound Values (DNs only)/sec"`
DRAInboundValuesTotalPerSec float64 `perfdata:"DRA Inbound Values Total/sec"`
_ float64 `perfdata:"DRA number of NC replication calls since boot"`
_ float64 `perfdata:"DRA number of successful NC replication calls since boot"`
DRAOutboundBytesCompressedBetweenSitesAfterCompressionSinceBoot float64 `perfdata:"DRA Outbound Bytes Compressed (Between Sites, After Compression) Since Boot"`
DRAOutboundBytesCompressedBetweenSitesAfterCompressionPerSec float64 `perfdata:"DRA Outbound Bytes Compressed (Between Sites, After Compression)/sec"`
DRAOutboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot float64 `perfdata:"DRA Outbound Bytes Compressed (Between Sites, Before Compression) Since Boot"`
DRAOutboundBytesCompressedBetweenSitesBeforeCompressionPerSec float64 `perfdata:"DRA Outbound Bytes Compressed (Between Sites, Before Compression)/sec"`
DRAOutboundBytesNotCompressedWithinSiteSinceBoot float64 `perfdata:"DRA Outbound Bytes Not Compressed (Within Site) Since Boot"`
DRAOutboundBytesNotCompressedWithinSitePerSec float64 `perfdata:"DRA Outbound Bytes Not Compressed (Within Site)/sec"`
DRAOutboundBytesTotalSinceBoot float64 `perfdata:"DRA Outbound Bytes Total Since Boot"`
DRAOutboundBytesTotalPerSec float64 `perfdata:"DRA Outbound Bytes Total/sec"`
DRAOutboundObjectsFilteredPerSec float64 `perfdata:"DRA Outbound Objects Filtered/sec"`
DRAOutboundObjectsPerSec float64 `perfdata:"DRA Outbound Objects/sec"`
DRAOutboundPropertiesPerSec float64 `perfdata:"DRA Outbound Properties/sec"`
DRAOutboundValuesDNsOnlyPerSec float64 `perfdata:"DRA Outbound Values (DNs only)/sec"`
DRAOutboundValuesTotalPerSec float64 `perfdata:"DRA Outbound Values Total/sec"`
DRAPendingReplicationOperations float64 `perfdata:"DRA Pending Replication Operations"`
DRAPendingReplicationSynchronizations float64 `perfdata:"DRA Pending Replication Synchronizations"`
DRASyncFailuresOnSchemaMismatch float64 `perfdata:"DRA Sync Failures on Schema Mismatch"`
DRASyncRequestsMade float64 `perfdata:"DRA Sync Requests Made"`
DRASyncRequestsSuccessful float64 `perfdata:"DRA Sync Requests Successful"`
DRAThreadsGettingNCChanges float64 `perfdata:"DRA Threads Getting NC Changes"`
DRAThreadsGettingNCChangesHoldingSemaphore float64 `perfdata:"DRA Threads Getting NC Changes Holding Semaphore"`
_ float64 `perfdata:"DRA total number of Busy failures since boot"`
_ float64 `perfdata:"DRA total number of MissingParent failures since boot"`
_ float64 `perfdata:"DRA total number of NotEnoughAttrs/MissingObject failures since boot"`
_ float64 `perfdata:"DRA total number of Preempted failures since boot"`
_ float64 `perfdata:"DRA total time of applying replication package since boot"`
_ float64 `perfdata:"DRA total time of NC replication calls since boot"`
_ float64 `perfdata:"DRA total time of successful NC replication calls since boot"`
_ float64 `perfdata:"DRA total time of successfully applying replication package since boot"`
_ float64 `perfdata:"DRA total time on waiting async replication packages since boot"`
_ float64 `perfdata:"DRA total time on waiting sync replication packages since boot"`
DsPercentReadsFromDRA float64 `perfdata:"DS % Reads from DRA"`
DsPercentReadsFromKCC float64 `perfdata:"DS % Reads from KCC"`
DsPercentReadsFromLSA float64 `perfdata:"DS % Reads from LSA"`
DsPercentReadsFromNSPI float64 `perfdata:"DS % Reads from NSPI"`
DsPercentReadsFromNTDSAPI float64 `perfdata:"DS % Reads from NTDSAPI"`
DsPercentReadsFromSAM float64 `perfdata:"DS % Reads from SAM"`
DsPercentReadsOther float64 `perfdata:"DS % Reads Other"`
DsPercentSearchesFromDRA float64 `perfdata:"DS % Searches from DRA"`
DsPercentSearchesFromKCC float64 `perfdata:"DS % Searches from KCC"`
DsPercentSearchesFromLDAP float64 `perfdata:"DS % Searches from LDAP"`
DsPercentSearchesFromLSA float64 `perfdata:"DS % Searches from LSA"`
DsPercentSearchesFromNSPI float64 `perfdata:"DS % Searches from NSPI"`
DsPercentSearchesFromNTDSAPI float64 `perfdata:"DS % Searches from NTDSAPI"`
DsPercentSearchesFromSAM float64 `perfdata:"DS % Searches from SAM"`
DsPercentSearchesOther float64 `perfdata:"DS % Searches Other"`
DsPercentWritesFromDRA float64 `perfdata:"DS % Writes from DRA"`
DsPercentWritesFromKCC float64 `perfdata:"DS % Writes from KCC"`
DsPercentWritesFromLDAP float64 `perfdata:"DS % Writes from LDAP"`
DsPercentWritesFromLSA float64 `perfdata:"DS % Writes from LSA"`
DsPercentWritesFromNSPI float64 `perfdata:"DS % Writes from NSPI"`
DsPercentWritesFromNTDSAPI float64 `perfdata:"DS % Writes from NTDSAPI"`
DsPercentWritesFromSAM float64 `perfdata:"DS % Writes from SAM"`
DsPercentWritesOther float64 `perfdata:"DS % Writes Other"`
DsClientBindsPerSec float64 `perfdata:"DS Client Binds/sec"`
DsClientNameTranslationsPerSec float64 `perfdata:"DS Client Name Translations/sec"`
DsDirectoryReadsPerSec float64 `perfdata:"DS Directory Reads/sec"`
DsDirectorySearchesPerSec float64 `perfdata:"DS Directory Searches/sec"`
DsDirectoryWritesPerSec float64 `perfdata:"DS Directory Writes/sec"`
DsMonitorListSize float64 `perfdata:"DS Monitor List Size"`
DsNameCacheHitRate float64 `perfdata:"DS Name Cache hit rate"`
DsNameCacheHitRateSecondValue float64 `perfdata:"DS Name Cache hit rate,secondvalue"`
DsNotifyQueueSize float64 `perfdata:"DS Notify Queue Size"`
DsSearchSubOperationsPerSec float64 `perfdata:"DS Search sub-operations/sec"`
DsSecurityDescriptorPropagationsEvents float64 `perfdata:"DS Security Descriptor Propagations Events"`
DsSecurityDescriptorPropagatorAverageExclusionTime float64 `perfdata:"DS Security Descriptor Propagator Average Exclusion Time"`
DsSecurityDescriptorPropagatorRuntimeQueue float64 `perfdata:"DS Security Descriptor Propagator Runtime Queue"`
DsSecurityDescriptorSubOperationsPerSec float64 `perfdata:"DS Security Descriptor sub-operations/sec"`
DsServerBindsPerSec float64 `perfdata:"DS Server Binds/sec"`
DsServerNameTranslationsPerSec float64 `perfdata:"DS Server Name Translations/sec"`
DsThreadsInUse float64 `perfdata:"DS Threads in Use"`
_ float64 `perfdata:"Error eventlogs since boot"`
_ float64 `perfdata:"Error events since boot"`
ExternalBindsPerSec float64 `perfdata:"External Binds/sec"`
FastBindsPerSec float64 `perfdata:"Fast Binds/sec"`
_ float64 `perfdata:"Fatal events since boot"`
_ float64 `perfdata:"Info eventlogs since boot"`
LdapActiveThreads float64 `perfdata:"LDAP Active Threads"`
_ float64 `perfdata:"LDAP Add Operations"`
_ float64 `perfdata:"LDAP Add Operations/sec"`
_ float64 `perfdata:"LDAP batch slots available"`
LdapBindTime float64 `perfdata:"LDAP Bind Time"`
_ float64 `perfdata:"LDAP busy retries"`
_ float64 `perfdata:"LDAP busy retries/sec"`
LdapClientSessions float64 `perfdata:"LDAP Client Sessions"`
LdapClosedConnectionsPerSec float64 `perfdata:"LDAP Closed Connections/sec"`
_ float64 `perfdata:"LDAP Delete Operations"`
_ float64 `perfdata:"LDAP Delete Operations/sec"`
_ float64 `perfdata:"LDAP Modify DN Operations"`
_ float64 `perfdata:"LDAP Modify DN Operations/sec"`
_ float64 `perfdata:"LDAP Modify Operations"`
_ float64 `perfdata:"LDAP Modify Operations/sec"`
LdapNewConnectionsPerSec float64 `perfdata:"LDAP New Connections/sec"`
LdapNewSSLConnectionsPerSec float64 `perfdata:"LDAP New SSL Connections/sec"`
_ float64 `perfdata:"LDAP Outbound Bytes"`
_ float64 `perfdata:"LDAP Outbound Bytes/sec"`
_ float64 `perfdata:"LDAP Page Search Cache entries count"`
_ float64 `perfdata:"LDAP Page Search Cache size"`
LdapSearchesPerSec float64 `perfdata:"LDAP Searches/sec"`
LdapSuccessfulBindsPerSec float64 `perfdata:"LDAP Successful Binds/sec"`
_ float64 `perfdata:"LDAP Threads Sleeping on BUSY"`
LdapUDPOperationsPerSec float64 `perfdata:"LDAP UDP operations/sec"`
LdapWritesPerSec float64 `perfdata:"LDAP Writes/sec"`
LinkValuesCleanedPerSec float64 `perfdata:"Link Values Cleaned/sec"`
_ float64 `perfdata:"Links added"`
_ float64 `perfdata:"Links added/sec"`
_ float64 `perfdata:"Links visited"`
_ float64 `perfdata:"Links visited/sec"`
_ float64 `perfdata:"Logical link deletes"`
_ float64 `perfdata:"Logical link deletes/sec"`
NegotiatedBindsPerSec float64 `perfdata:"Negotiated Binds/sec"`
NTLMBindsPerSec float64 `perfdata:"NTLM Binds/sec"`
_ float64 `perfdata:"Objects returned"`
_ float64 `perfdata:"Objects returned/sec"`
_ float64 `perfdata:"Objects visited"`
_ float64 `perfdata:"Objects visited/sec"`
OneLevelSearchesPerSec float64 `perfdata:"Onelevel searches/sec"`
_ float64 `perfdata:"PDC failed password update notifications"`
_ float64 `perfdata:"PDC password update notifications/sec"`
_ float64 `perfdata:"PDC successful password update notifications"`
PhantomsCleanedPerSec float64 `perfdata:"Phantoms Cleaned/sec"`
PhantomsVisitedPerSec float64 `perfdata:"Phantoms Visited/sec"`
_ float64 `perfdata:"Physical link deletes"`
_ float64 `perfdata:"Physical link deletes/sec"`
_ float64 `perfdata:"Replicate Single Object operations"`
_ float64 `perfdata:"Replicate Single Object operations/sec"`
_ float64 `perfdata:"RID Pool invalidations since boot"`
_ float64 `perfdata:"RID Pool request failures since boot"`
_ float64 `perfdata:"RID Pool request successes since boot"`
SamAccountGroupEvaluationLatency float64 `perfdata:"SAM Account Group Evaluation Latency"`
SamDisplayInformationQueriesPerSec float64 `perfdata:"SAM Display Information Queries/sec"`
SamDomainLocalGroupMembershipEvaluationsPerSec float64 `perfdata:"SAM Domain Local Group Membership Evaluations/sec"`
SamEnumerationsPerSec float64 `perfdata:"SAM Enumerations/sec"`
SamGCEvaluationsPerSec float64 `perfdata:"SAM GC Evaluations/sec"`
SamGlobalGroupMembershipEvaluationsPerSec float64 `perfdata:"SAM Global Group Membership Evaluations/sec"`
SamMachineCreationAttemptsPerSec float64 `perfdata:"SAM Machine Creation Attempts/sec"`
SamMembershipChangesPerSec float64 `perfdata:"SAM Membership Changes/sec"`
SamNonTransitiveMembershipEvaluationsPerSec float64 `perfdata:"SAM Non-Transitive Membership Evaluations/sec"`
SamPasswordChangesPerSec float64 `perfdata:"SAM Password Changes/sec"`
SamResourceGroupEvaluationLatency float64 `perfdata:"SAM Resource Group Evaluation Latency"`
SamSuccessfulComputerCreationsPerSecIncludesAllRequests float64 `perfdata:"SAM Successful Computer Creations/sec: Includes all requests"`
SamSuccessfulUserCreationsPerSec float64 `perfdata:"SAM Successful User Creations/sec"`
SamTransitiveMembershipEvaluationsPerSec float64 `perfdata:"SAM Transitive Membership Evaluations/sec"`
SamUniversalGroupMembershipEvaluationsPerSec float64 `perfdata:"SAM Universal Group Membership Evaluations/sec"`
SamUserCreationAttemptsPerSec float64 `perfdata:"SAM User Creation Attempts/sec"`
SimpleBindsPerSec float64 `perfdata:"Simple Binds/sec"`
SubtreeSearchesPerSec float64 `perfdata:"Subtree searches/sec"`
TombstonesGarbageCollectedPerSec float64 `perfdata:"Tombstones Garbage Collected/sec"`
TombstonesVisitedPerSec float64 `perfdata:"Tombstones Visited/sec"`
TransitiveOperationsMillisecondsRun float64 `perfdata:"Transitive operations milliseconds run"`
TransitiveOperationsPerSec float64 `perfdata:"Transitive operations/sec"`
TransitiveSubOperationsPerSec float64 `perfdata:"Transitive suboperations/sec"`
_ float64 `perfdata:"Warning eventlogs since boot"`
_ float64 `perfdata:"Warning events since boot"`
}

View File

@@ -1,15 +1,27 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package adcs
import (
"errors"
"fmt"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus/client_golang/prometheus"
@@ -19,12 +31,14 @@ const Name = "adcs"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
challengeResponseProcessingTime *prometheus.Desc
challengeResponsesPerSecond *prometheus.Desc
@@ -70,21 +84,7 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error
c.perfDataCollector, err = perfdata.NewCollector("Certification Authority", perfdata.InstanceAll, []string{
requestsPerSecond,
requestProcessingTime,
retrievalsPerSecond,
retrievalProcessingTime,
failedRequestsPerSecond,
issuedRequestsPerSecond,
pendingRequestsPerSecond,
requestCryptographicSigningTime,
requestPolicyModuleProcessingTime,
challengeResponsesPerSecond,
challengeResponseProcessingTime,
signedCertificateTimestampListsPerSecond,
signedCertificateTimestampListProcessingTime,
})
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues]("Certification Authority", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Certification Authority collector: %w", err)
}
@@ -172,93 +172,89 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
}
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollector.Collect()
err := c.perfDataCollector.Collect(&c.perfDataObject)
if err != nil {
return fmt.Errorf("failed to collect Certification Authority (ADCS) metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for Certification Authority (ADCS) returned empty result set")
}
for name, data := range perfData {
for _, data := range c.perfDataObject {
ch <- prometheus.MustNewConstMetric(
c.requestsPerSecond,
prometheus.CounterValue,
data[requestsPerSecond].FirstValue,
name,
data.RequestsPerSecond,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.requestProcessingTime,
prometheus.GaugeValue,
utils.MilliSecToSec(data[requestProcessingTime].FirstValue),
name,
utils.MilliSecToSec(data.RequestProcessingTime),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.retrievalsPerSecond,
prometheus.CounterValue,
data[retrievalsPerSecond].FirstValue,
name,
data.RetrievalsPerSecond,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.retrievalProcessingTime,
prometheus.GaugeValue,
utils.MilliSecToSec(data[retrievalProcessingTime].FirstValue),
name,
utils.MilliSecToSec(data.RetrievalProcessingTime),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.failedRequestsPerSecond,
prometheus.CounterValue,
data[failedRequestsPerSecond].FirstValue,
name,
data.FailedRequestsPerSecond,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.issuedRequestsPerSecond,
prometheus.CounterValue,
data[issuedRequestsPerSecond].FirstValue,
name,
data.IssuedRequestsPerSecond,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.pendingRequestsPerSecond,
prometheus.CounterValue,
data[pendingRequestsPerSecond].FirstValue,
name,
data.PendingRequestsPerSecond,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.requestCryptographicSigningTime,
prometheus.GaugeValue,
utils.MilliSecToSec(data[requestCryptographicSigningTime].FirstValue),
name,
utils.MilliSecToSec(data.RequestCryptographicSigningTime),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.requestPolicyModuleProcessingTime,
prometheus.GaugeValue,
utils.MilliSecToSec(data[requestPolicyModuleProcessingTime].FirstValue),
name,
utils.MilliSecToSec(data.RequestPolicyModuleProcessingTime),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.challengeResponsesPerSecond,
prometheus.CounterValue,
data[challengeResponsesPerSecond].FirstValue,
name,
data.ChallengeResponsesPerSecond,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.challengeResponseProcessingTime,
prometheus.GaugeValue,
utils.MilliSecToSec(data[challengeResponseProcessingTime].FirstValue),
name,
utils.MilliSecToSec(data.ChallengeResponseProcessingTime),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.signedCertificateTimestampListsPerSecond,
prometheus.CounterValue,
data[signedCertificateTimestampListsPerSecond].FirstValue,
name,
data.SignedCertificateTimestampListsPerSecond,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.signedCertificateTimestampListProcessingTime,
prometheus.GaugeValue,
utils.MilliSecToSec(data[signedCertificateTimestampListProcessingTime].FirstValue),
name,
utils.MilliSecToSec(data.SignedCertificateTimestampListProcessingTime),
data.Name,
)
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package adcs_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, adcs.Name, adcs.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, adcs.New, nil)
}

View File

@@ -1,19 +0,0 @@
//go:build windows
package adcs
const (
challengeResponseProcessingTime = "Challenge Response processing time (ms)"
challengeResponsesPerSecond = "Challenge Responses/sec"
failedRequestsPerSecond = "Failed Requests/sec"
issuedRequestsPerSecond = "Issued Requests/sec"
pendingRequestsPerSecond = "Pending Requests/sec"
requestCryptographicSigningTime = "Request cryptographic signing time (ms)"
requestPolicyModuleProcessingTime = "Request policy module processing time (ms)"
requestProcessingTime = "Request processing time (ms)"
requestsPerSecond = "Requests/sec"
retrievalProcessingTime = "Retrieval processing time (ms)"
retrievalsPerSecond = "Retrievals/sec"
signedCertificateTimestampListProcessingTime = "Signed Certificate Timestamp List processing time (ms)"
signedCertificateTimestampListsPerSecond = "Signed Certificate Timestamp Lists/sec"
)

View File

@@ -0,0 +1,34 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package adcs
type perfDataCounterValues struct {
Name string
ChallengeResponseProcessingTime float64 `perfdata:"Challenge Response processing time (ms)"`
ChallengeResponsesPerSecond float64 `perfdata:"Challenge Responses/sec"`
FailedRequestsPerSecond float64 `perfdata:"Failed Requests/sec"`
IssuedRequestsPerSecond float64 `perfdata:"Issued Requests/sec"`
PendingRequestsPerSecond float64 `perfdata:"Pending Requests/sec"`
RequestCryptographicSigningTime float64 `perfdata:"Request cryptographic signing time (ms)"`
RequestPolicyModuleProcessingTime float64 `perfdata:"Request policy module processing time (ms)"`
RequestProcessingTime float64 `perfdata:"Request processing time (ms)"`
RequestsPerSecond float64 `perfdata:"Requests/sec"`
RetrievalProcessingTime float64 `perfdata:"Retrieval processing time (ms)"`
RetrievalsPerSecond float64 `perfdata:"Retrievals/sec"`
SignedCertificateTimestampListProcessingTime float64 `perfdata:"Signed Certificate Timestamp List processing time (ms)"`
SignedCertificateTimestampListsPerSecond float64 `perfdata:"Signed Certificate Timestamp Lists/sec"`
}

View File

@@ -1,18 +1,28 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package adfs
import (
"errors"
"fmt"
"log/slog"
"maps"
"math"
"slices"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
@@ -21,12 +31,14 @@ const Name = "adfs"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
adLoginConnectionFailures *prometheus.Desc
artifactDBFailures *prometheus.Desc
@@ -102,51 +114,7 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error
c.perfDataCollector, err = perfdata.NewCollector("AD FS", perfdata.InstanceAll, []string{
adLoginConnectionFailures,
certificateAuthentications,
deviceAuthentications,
extranetAccountLockouts,
federatedAuthentications,
passportAuthentications,
passiveRequests,
passwordChangeFailed,
passwordChangeSucceeded,
tokenRequests,
windowsIntegratedAuthentications,
oAuthAuthZRequests,
oAuthClientAuthentications,
oAuthClientAuthenticationFailures,
oAuthClientCredentialRequestFailures,
oAuthClientCredentialRequests,
oAuthClientPrivateKeyJWTAuthenticationFailures,
oAuthClientPrivateKeyJWTAuthentications,
oAuthClientBasicAuthenticationFailures,
oAuthClientBasicAuthentications,
oAuthClientSecretPostAuthenticationFailures,
oAuthClientSecretPostAuthentications,
oAuthClientWindowsAuthenticationFailures,
oAuthClientWindowsAuthentications,
oAuthLogonCertRequestFailures,
oAuthLogonCertTokenRequests,
oAuthPasswordGrantRequestFailures,
oAuthPasswordGrantRequests,
oAuthTokenRequests,
samlPTokenRequests,
ssoAuthenticationFailures,
ssoAuthentications,
wsFedTokenRequests,
wsTrustTokenRequests,
usernamePasswordAuthenticationFailures,
usernamePasswordAuthentications,
externalAuthentications,
externalAuthNFailures,
artifactDBFailures,
avgArtifactDBQueryTime,
configDBFailures,
avgConfigDBQueryTime,
federationMetadataRequests,
})
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues]("AD FS", nil)
if err != nil {
return fmt.Errorf("failed to create AD FS collector: %w", err)
}
@@ -414,279 +382,267 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
}
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollector.Collect()
err := c.perfDataCollector.Collect(&c.perfDataObject)
if err != nil {
return fmt.Errorf("failed to collect ADFS metrics: %w", err)
}
instanceKey := slices.Collect(maps.Keys(data))
if len(instanceKey) == 0 {
return errors.New("perflib query for ADFS returned empty result set")
}
adfsData, ok := data[instanceKey[0]]
if !ok {
return errors.New("perflib query for ADFS returned empty result set")
}
ch <- prometheus.MustNewConstMetric(
c.adLoginConnectionFailures,
prometheus.CounterValue,
adfsData[adLoginConnectionFailures].FirstValue,
c.perfDataObject[0].AdLoginConnectionFailures,
)
ch <- prometheus.MustNewConstMetric(
c.certificateAuthentications,
prometheus.CounterValue,
adfsData[certificateAuthentications].FirstValue,
c.perfDataObject[0].CertificateAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.deviceAuthentications,
prometheus.CounterValue,
adfsData[deviceAuthentications].FirstValue,
c.perfDataObject[0].DeviceAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.extranetAccountLockouts,
prometheus.CounterValue,
adfsData[extranetAccountLockouts].FirstValue,
c.perfDataObject[0].ExtranetAccountLockouts,
)
ch <- prometheus.MustNewConstMetric(
c.federatedAuthentications,
prometheus.CounterValue,
adfsData[federatedAuthentications].FirstValue,
c.perfDataObject[0].FederatedAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.passportAuthentications,
prometheus.CounterValue,
adfsData[passportAuthentications].FirstValue,
c.perfDataObject[0].PassportAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.passiveRequests,
prometheus.CounterValue,
adfsData[passiveRequests].FirstValue,
c.perfDataObject[0].PassiveRequests,
)
ch <- prometheus.MustNewConstMetric(
c.passwordChangeFailed,
prometheus.CounterValue,
adfsData[passwordChangeFailed].FirstValue,
c.perfDataObject[0].PasswordChangeFailed,
)
ch <- prometheus.MustNewConstMetric(
c.passwordChangeSucceeded,
prometheus.CounterValue,
adfsData[passwordChangeSucceeded].FirstValue,
c.perfDataObject[0].PasswordChangeSucceeded,
)
ch <- prometheus.MustNewConstMetric(
c.tokenRequests,
prometheus.CounterValue,
adfsData[tokenRequests].FirstValue,
c.perfDataObject[0].TokenRequests,
)
ch <- prometheus.MustNewConstMetric(
c.windowsIntegratedAuthentications,
prometheus.CounterValue,
adfsData[windowsIntegratedAuthentications].FirstValue,
c.perfDataObject[0].WindowsIntegratedAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthAuthZRequests,
prometheus.CounterValue,
adfsData[oAuthAuthZRequests].FirstValue,
c.perfDataObject[0].OAuthAuthZRequests,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientAuthentications,
prometheus.CounterValue,
adfsData[oAuthClientAuthentications].FirstValue,
c.perfDataObject[0].OAuthClientAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientAuthenticationsFailures,
prometheus.CounterValue,
adfsData[oAuthClientAuthenticationFailures].FirstValue,
c.perfDataObject[0].OAuthClientAuthenticationFailures,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientCredentialsRequestFailures,
prometheus.CounterValue,
adfsData[oAuthClientCredentialRequestFailures].FirstValue,
c.perfDataObject[0].OAuthClientCredentialRequestFailures,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientCredentialsRequests,
prometheus.CounterValue,
adfsData[oAuthClientCredentialRequests].FirstValue,
c.perfDataObject[0].OAuthClientCredentialRequests,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientPrivateKeyJwtAuthenticationFailures,
prometheus.CounterValue,
adfsData[oAuthClientPrivateKeyJWTAuthenticationFailures].FirstValue,
c.perfDataObject[0].OAuthClientPrivateKeyJWTAuthenticationFailures,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientPrivateKeyJwtAuthentications,
prometheus.CounterValue,
adfsData[oAuthClientPrivateKeyJWTAuthentications].FirstValue,
c.perfDataObject[0].OAuthClientPrivateKeyJWTAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientSecretBasicAuthenticationFailures,
prometheus.CounterValue,
adfsData[oAuthClientBasicAuthenticationFailures].FirstValue,
c.perfDataObject[0].OAuthClientBasicAuthenticationFailures,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientSecretBasicAuthentications,
prometheus.CounterValue,
adfsData[oAuthClientBasicAuthentications].FirstValue,
c.perfDataObject[0].OAuthClientBasicAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientSecretPostAuthenticationFailures,
prometheus.CounterValue,
adfsData[oAuthClientSecretPostAuthenticationFailures].FirstValue,
c.perfDataObject[0].OAuthClientSecretPostAuthenticationFailures,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientSecretPostAuthentications,
prometheus.CounterValue,
adfsData[oAuthClientSecretPostAuthentications].FirstValue,
c.perfDataObject[0].OAuthClientSecretPostAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientWindowsIntegratedAuthenticationFailures,
prometheus.CounterValue,
adfsData[oAuthClientWindowsAuthenticationFailures].FirstValue,
c.perfDataObject[0].OAuthClientWindowsAuthenticationFailures,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthClientWindowsIntegratedAuthentications,
prometheus.CounterValue,
adfsData[oAuthClientWindowsAuthentications].FirstValue,
c.perfDataObject[0].OAuthClientWindowsAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthLogonCertificateRequestFailures,
prometheus.CounterValue,
adfsData[oAuthLogonCertRequestFailures].FirstValue,
c.perfDataObject[0].OAuthLogonCertRequestFailures,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthLogonCertificateTokenRequests,
prometheus.CounterValue,
adfsData[oAuthLogonCertTokenRequests].FirstValue,
c.perfDataObject[0].OAuthLogonCertTokenRequests,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthPasswordGrantRequestFailures,
prometheus.CounterValue,
adfsData[oAuthPasswordGrantRequestFailures].FirstValue,
c.perfDataObject[0].OAuthPasswordGrantRequestFailures,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthPasswordGrantRequests,
prometheus.CounterValue,
adfsData[oAuthPasswordGrantRequests].FirstValue,
c.perfDataObject[0].OAuthPasswordGrantRequests,
)
ch <- prometheus.MustNewConstMetric(
c.oAuthTokenRequests,
prometheus.CounterValue,
adfsData[oAuthTokenRequests].FirstValue,
c.perfDataObject[0].OAuthTokenRequests,
)
ch <- prometheus.MustNewConstMetric(
c.samlPTokenRequests,
prometheus.CounterValue,
adfsData[samlPTokenRequests].FirstValue,
c.perfDataObject[0].SamlPTokenRequests,
)
ch <- prometheus.MustNewConstMetric(
c.ssoAuthenticationFailures,
prometheus.CounterValue,
adfsData[ssoAuthenticationFailures].FirstValue,
c.perfDataObject[0].SsoAuthenticationFailures,
)
ch <- prometheus.MustNewConstMetric(
c.ssoAuthentications,
prometheus.CounterValue,
adfsData[ssoAuthentications].FirstValue,
c.perfDataObject[0].SsoAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.wsFedTokenRequests,
prometheus.CounterValue,
adfsData[wsFedTokenRequests].FirstValue,
c.perfDataObject[0].WsFedTokenRequests,
)
ch <- prometheus.MustNewConstMetric(
c.wsTrustTokenRequests,
prometheus.CounterValue,
adfsData[wsTrustTokenRequests].FirstValue,
c.perfDataObject[0].WsTrustTokenRequests,
)
ch <- prometheus.MustNewConstMetric(
c.upAuthenticationFailures,
prometheus.CounterValue,
adfsData[usernamePasswordAuthenticationFailures].FirstValue,
c.perfDataObject[0].UsernamePasswordAuthenticationFailures,
)
ch <- prometheus.MustNewConstMetric(
c.upAuthentications,
prometheus.CounterValue,
adfsData[usernamePasswordAuthentications].FirstValue,
c.perfDataObject[0].UsernamePasswordAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.externalAuthenticationFailures,
prometheus.CounterValue,
adfsData[externalAuthNFailures].FirstValue,
c.perfDataObject[0].ExternalAuthNFailures,
)
ch <- prometheus.MustNewConstMetric(
c.externalAuthentications,
prometheus.CounterValue,
adfsData[externalAuthentications].FirstValue,
c.perfDataObject[0].ExternalAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.artifactDBFailures,
prometheus.CounterValue,
adfsData[artifactDBFailures].FirstValue,
c.perfDataObject[0].ArtifactDBFailures,
)
ch <- prometheus.MustNewConstMetric(
c.avgArtifactDBQueryTime,
prometheus.CounterValue,
adfsData[avgArtifactDBQueryTime].FirstValue*math.Pow(10, -8),
c.perfDataObject[0].AvgArtifactDBQueryTime*math.Pow(10, -8),
)
ch <- prometheus.MustNewConstMetric(
c.configDBFailures,
prometheus.CounterValue,
adfsData[configDBFailures].FirstValue,
c.perfDataObject[0].ConfigDBFailures,
)
ch <- prometheus.MustNewConstMetric(
c.avgConfigDBQueryTime,
prometheus.CounterValue,
adfsData[avgConfigDBQueryTime].FirstValue*math.Pow(10, -8),
c.perfDataObject[0].AvgConfigDBQueryTime*math.Pow(10, -8),
)
ch <- prometheus.MustNewConstMetric(
c.federationMetadataRequests,
prometheus.CounterValue,
adfsData[federationMetadataRequests].FirstValue,
c.perfDataObject[0].FederationMetadataRequests,
)
return nil

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package adfs_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, adfs.Name, adfs.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, adfs.New, nil)
}

View File

@@ -1,49 +0,0 @@
//go:build windows
package adfs
const (
adLoginConnectionFailures = "AD Login Connection Failures"
artifactDBFailures = "Artifact Database Connection Failures"
avgArtifactDBQueryTime = "Average Artifact Database Query Time"
avgConfigDBQueryTime = "Average Config Database Query Time"
certificateAuthentications = "Certificate Authentications"
configDBFailures = "Configuration Database Connection Failures"
deviceAuthentications = "Device Authentications"
externalAuthentications = "External Authentications"
externalAuthNFailures = "External Authentication Failures"
extranetAccountLockouts = "Extranet Account Lockouts"
federatedAuthentications = "Federated Authentications"
federationMetadataRequests = "Federation Metadata Requests"
oAuthAuthZRequests = "OAuth AuthZ Requests"
oAuthClientAuthenticationFailures = "OAuth Client Authentications Failures"
oAuthClientAuthentications = "OAuth Client Authentications"
oAuthClientBasicAuthenticationFailures = "OAuth Client Secret Basic Authentication Failures"
oAuthClientBasicAuthentications = "OAuth Client Secret Basic Authentication Requests"
oAuthClientCredentialRequestFailures = "OAuth Client Credentials Request Failures"
oAuthClientCredentialRequests = "OAuth Client Credentials Requests"
oAuthClientPrivateKeyJWTAuthenticationFailures = "OAuth Client Private Key Jwt Authentication Failures"
oAuthClientPrivateKeyJWTAuthentications = "OAuth Client Private Key Jwt Authentications"
oAuthClientSecretPostAuthenticationFailures = "OAuth Client Secret Post Authentication Failures"
oAuthClientSecretPostAuthentications = "OAuth Client Secret Post Authentications"
oAuthClientWindowsAuthenticationFailures = "OAuth Client Windows Integrated Authentication Failures"
oAuthClientWindowsAuthentications = "OAuth Client Windows Integrated Authentications"
oAuthLogonCertRequestFailures = "OAuth Logon Certificate Request Failures"
oAuthLogonCertTokenRequests = "OAuth Logon Certificate Token Requests"
oAuthPasswordGrantRequestFailures = "OAuth Password Grant Request Failures"
oAuthPasswordGrantRequests = "OAuth Password Grant Requests"
oAuthTokenRequests = "OAuth Token Requests"
passiveRequests = "Passive Requests"
passportAuthentications = "Microsoft Passport Authentications"
passwordChangeFailed = "Password Change Failed Requests"
passwordChangeSucceeded = "Password Change Successful Requests"
samlPTokenRequests = "SAML-P Token Requests"
ssoAuthenticationFailures = "SSO Authentication Failures"
ssoAuthentications = "SSO Authentications"
tokenRequests = "Token Requests"
usernamePasswordAuthenticationFailures = "U/P Authentication Failures"
usernamePasswordAuthentications = "U/P Authentications"
windowsIntegratedAuthentications = "Windows Integrated Authentications"
wsFedTokenRequests = "WS-Fed Token Requests"
wsTrustTokenRequests = "WS-Trust Token Requests"
)

View File

@@ -0,0 +1,62 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package adfs
type perfDataCounterValues struct {
AdLoginConnectionFailures float64 `perfdata:"AD Login Connection Failures"`
ArtifactDBFailures float64 `perfdata:"Artifact Database Connection Failures"`
AvgArtifactDBQueryTime float64 `perfdata:"Average Artifact Database Query Time"`
AvgConfigDBQueryTime float64 `perfdata:"Average Config Database Query Time"`
CertificateAuthentications float64 `perfdata:"Certificate Authentications"`
ConfigDBFailures float64 `perfdata:"Configuration Database Connection Failures"`
DeviceAuthentications float64 `perfdata:"Device Authentications"`
ExternalAuthentications float64 `perfdata:"External Authentications"`
ExternalAuthNFailures float64 `perfdata:"External Authentication Failures"`
ExtranetAccountLockouts float64 `perfdata:"Extranet Account Lockouts"`
FederatedAuthentications float64 `perfdata:"Federated Authentications"`
FederationMetadataRequests float64 `perfdata:"Federation Metadata Requests"`
OAuthAuthZRequests float64 `perfdata:"OAuth AuthZ Requests"`
OAuthClientAuthenticationFailures float64 `perfdata:"OAuth Client Authentications Failures"`
OAuthClientAuthentications float64 `perfdata:"OAuth Client Authentications"`
OAuthClientBasicAuthenticationFailures float64 `perfdata:"OAuth Client Secret Basic Authentication Failures"`
OAuthClientBasicAuthentications float64 `perfdata:"OAuth Client Secret Basic Authentications"`
OAuthClientCredentialRequestFailures float64 `perfdata:"OAuth Client Credentials Request Failures"`
OAuthClientCredentialRequests float64 `perfdata:"OAuth Client Credentials Requests"`
OAuthClientPrivateKeyJWTAuthenticationFailures float64 `perfdata:"OAuth Client Private Key Jwt Authentication Failures"`
OAuthClientPrivateKeyJWTAuthentications float64 `perfdata:"OAuth Client Private Key Jwt Authentications"`
OAuthClientSecretPostAuthenticationFailures float64 `perfdata:"OAuth Client Secret Post Authentication Failures"`
OAuthClientSecretPostAuthentications float64 `perfdata:"OAuth Client Secret Post Authentications"`
OAuthClientWindowsAuthenticationFailures float64 `perfdata:"OAuth Client Windows Integrated Authentication Failures"`
OAuthClientWindowsAuthentications float64 `perfdata:"OAuth Client Windows Integrated Authentications"`
OAuthLogonCertRequestFailures float64 `perfdata:"OAuth Logon Certificate Request Failures"`
OAuthLogonCertTokenRequests float64 `perfdata:"OAuth Logon Certificate Token Requests"`
OAuthPasswordGrantRequestFailures float64 `perfdata:"OAuth Password Grant Request Failures"`
OAuthPasswordGrantRequests float64 `perfdata:"OAuth Password Grant Requests"`
OAuthTokenRequests float64 `perfdata:"OAuth Token Requests"`
PassiveRequests float64 `perfdata:"Passive Requests"`
PassportAuthentications float64 `perfdata:"Microsoft Passport Authentications"`
PasswordChangeFailed float64 `perfdata:"Password Change Failed Requests"`
PasswordChangeSucceeded float64 `perfdata:"Password Change Successful Requests"`
SamlPTokenRequests float64 `perfdata:"SAML-P Token Requests"`
SsoAuthenticationFailures float64 `perfdata:"SSO Authentication Failures"`
SsoAuthentications float64 `perfdata:"SSO Authentications"`
TokenRequests float64 `perfdata:"Token Requests"`
UsernamePasswordAuthenticationFailures float64 `perfdata:"U/P Authentication Failures"`
UsernamePasswordAuthentications float64 `perfdata:"U/P Authentications"`
WindowsIntegratedAuthentications float64 `perfdata:"Windows Integrated Authentications"`
WsFedTokenRequests float64 `perfdata:"WS-Fed Token Requests"`
WsTrustTokenRequests float64 `perfdata:"WS-Trust Token Requests"`
}

View File

@@ -1,15 +1,27 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package cache
import (
"errors"
"fmt"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
@@ -18,13 +30,15 @@ const Name = "cache"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for Perflib Cache metrics.
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
asyncCopyReadsTotal *prometheus.Desc
asyncDataMapsTotal *prometheus.Desc
@@ -86,37 +100,7 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error
c.perfDataCollector, err = perfdata.NewCollector("Cache", perfdata.InstanceAll, []string{
asyncCopyReadsTotal,
asyncDataMapsTotal,
asyncFastReadsTotal,
asyncMDLReadsTotal,
asyncPinReadsTotal,
copyReadHitsTotal,
copyReadsTotal,
dataFlushesTotal,
dataFlushPagesTotal,
dataMapHitsPercent,
dataMapPinsTotal,
dataMapsTotal,
dirtyPages,
dirtyPageThreshold,
fastReadNotPossiblesTotal,
fastReadResourceMissesTotal,
fastReadsTotal,
lazyWriteFlushesTotal,
lazyWritePagesTotal,
mdlReadHitsTotal,
mdlReadsTotal,
pinReadHitsTotal,
pinReadsTotal,
readAheadsTotal,
syncCopyReadsTotal,
syncDataMapsTotal,
syncFastReadsTotal,
syncMDLReadsTotal,
syncPinReadsTotal,
})
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues]("Cache", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Cache collector: %w", err)
}
@@ -301,189 +285,183 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
// Collect implements the Collector interface.
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollector.Collect()
err := c.perfDataCollector.Collect(&c.perfDataObject)
if err != nil {
return fmt.Errorf("failed to collect Cache metrics: %w", err)
}
cacheData, ok := data[perfdata.EmptyInstance]
if !ok {
return errors.New("perflib query for Cache returned empty result set")
}
ch <- prometheus.MustNewConstMetric(
c.asyncCopyReadsTotal,
prometheus.CounterValue,
cacheData[asyncCopyReadsTotal].FirstValue,
c.perfDataObject[0].AsyncCopyReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.asyncDataMapsTotal,
prometheus.CounterValue,
cacheData[asyncDataMapsTotal].FirstValue,
c.perfDataObject[0].AsyncDataMapsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.asyncFastReadsTotal,
prometheus.CounterValue,
cacheData[asyncFastReadsTotal].FirstValue,
c.perfDataObject[0].AsyncFastReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.asyncMDLReadsTotal,
prometheus.CounterValue,
cacheData[asyncMDLReadsTotal].FirstValue,
c.perfDataObject[0].AsyncMDLReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.asyncPinReadsTotal,
prometheus.CounterValue,
cacheData[asyncPinReadsTotal].FirstValue,
c.perfDataObject[0].AsyncPinReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.copyReadHitsTotal,
prometheus.GaugeValue,
cacheData[copyReadHitsTotal].FirstValue,
c.perfDataObject[0].CopyReadHitsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.copyReadsTotal,
prometheus.CounterValue,
cacheData[copyReadsTotal].FirstValue,
c.perfDataObject[0].CopyReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.dataFlushesTotal,
prometheus.CounterValue,
cacheData[dataFlushesTotal].FirstValue,
c.perfDataObject[0].DataFlushesTotal,
)
ch <- prometheus.MustNewConstMetric(
c.dataFlushPagesTotal,
prometheus.CounterValue,
cacheData[dataFlushPagesTotal].FirstValue,
c.perfDataObject[0].DataFlushPagesTotal,
)
ch <- prometheus.MustNewConstMetric(
c.dataMapHitsPercent,
prometheus.GaugeValue,
cacheData[dataMapHitsPercent].FirstValue,
c.perfDataObject[0].DataMapHitsPercent,
)
ch <- prometheus.MustNewConstMetric(
c.dataMapPinsTotal,
prometheus.CounterValue,
cacheData[dataMapPinsTotal].FirstValue,
c.perfDataObject[0].DataMapPinsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.dataMapsTotal,
prometheus.CounterValue,
cacheData[dataMapsTotal].FirstValue,
c.perfDataObject[0].DataMapsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.dirtyPages,
prometheus.GaugeValue,
cacheData[dirtyPages].FirstValue,
c.perfDataObject[0].DirtyPages,
)
ch <- prometheus.MustNewConstMetric(
c.dirtyPageThreshold,
prometheus.GaugeValue,
cacheData[dirtyPageThreshold].FirstValue,
c.perfDataObject[0].DirtyPageThreshold,
)
ch <- prometheus.MustNewConstMetric(
c.fastReadNotPossiblesTotal,
prometheus.CounterValue,
cacheData[fastReadNotPossiblesTotal].FirstValue,
c.perfDataObject[0].FastReadNotPossiblesTotal,
)
ch <- prometheus.MustNewConstMetric(
c.fastReadResourceMissesTotal,
prometheus.CounterValue,
cacheData[fastReadResourceMissesTotal].FirstValue,
c.perfDataObject[0].FastReadResourceMissesTotal,
)
ch <- prometheus.MustNewConstMetric(
c.fastReadsTotal,
prometheus.CounterValue,
cacheData[fastReadsTotal].FirstValue,
c.perfDataObject[0].FastReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.lazyWriteFlushesTotal,
prometheus.CounterValue,
cacheData[lazyWriteFlushesTotal].FirstValue,
c.perfDataObject[0].LazyWriteFlushesTotal,
)
ch <- prometheus.MustNewConstMetric(
c.lazyWritePagesTotal,
prometheus.CounterValue,
cacheData[lazyWritePagesTotal].FirstValue,
c.perfDataObject[0].LazyWritePagesTotal,
)
ch <- prometheus.MustNewConstMetric(
c.mdlReadHitsTotal,
prometheus.CounterValue,
cacheData[mdlReadHitsTotal].FirstValue,
c.perfDataObject[0].MdlReadHitsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.mdlReadsTotal,
prometheus.CounterValue,
cacheData[mdlReadsTotal].FirstValue,
c.perfDataObject[0].MdlReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.pinReadHitsTotal,
prometheus.CounterValue,
cacheData[pinReadHitsTotal].FirstValue,
c.perfDataObject[0].PinReadHitsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.pinReadsTotal,
prometheus.CounterValue,
cacheData[pinReadsTotal].FirstValue,
c.perfDataObject[0].PinReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.readAheadsTotal,
prometheus.CounterValue,
cacheData[readAheadsTotal].FirstValue,
c.perfDataObject[0].ReadAheadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.syncCopyReadsTotal,
prometheus.CounterValue,
cacheData[syncCopyReadsTotal].FirstValue,
c.perfDataObject[0].SyncCopyReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.syncDataMapsTotal,
prometheus.CounterValue,
cacheData[syncDataMapsTotal].FirstValue,
c.perfDataObject[0].SyncDataMapsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.syncFastReadsTotal,
prometheus.CounterValue,
cacheData[syncFastReadsTotal].FirstValue,
c.perfDataObject[0].SyncFastReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.syncMDLReadsTotal,
prometheus.CounterValue,
cacheData[syncMDLReadsTotal].FirstValue,
c.perfDataObject[0].SyncMDLReadsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.syncPinReadsTotal,
prometheus.CounterValue,
cacheData[syncPinReadsTotal].FirstValue,
c.perfDataObject[0].SyncPinReadsTotal,
)
return nil

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package cache_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, cache.Name, cache.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, cache.New, nil)
}

View File

@@ -1,37 +0,0 @@
//go:build windows
package cache
// Perflib "Cache":
// - https://docs.microsoft.com/en-us/previous-versions/aa394267(v=vs.85)
const (
asyncCopyReadsTotal = "Async Copy Reads/sec"
asyncDataMapsTotal = "Async Data Maps/sec"
asyncFastReadsTotal = "Async Fast Reads/sec"
asyncMDLReadsTotal = "Async MDL Reads/sec"
asyncPinReadsTotal = "Async Pin Reads/sec"
copyReadHitsTotal = "Copy Read Hits %"
copyReadsTotal = "Copy Reads/sec"
dataFlushesTotal = "Data Flushes/sec"
dataFlushPagesTotal = "Data Flush Pages/sec"
dataMapHitsPercent = "Data Map Hits %"
dataMapPinsTotal = "Data Map Pins/sec"
dataMapsTotal = "Data Maps/sec"
dirtyPages = "Dirty Pages"
dirtyPageThreshold = "Dirty Page Threshold"
fastReadNotPossiblesTotal = "Fast Read Not Possibles/sec"
fastReadResourceMissesTotal = "Fast Read Resource Misses/sec"
fastReadsTotal = "Fast Reads/sec"
lazyWriteFlushesTotal = "Lazy Write Flushes/sec"
lazyWritePagesTotal = "Lazy Write Pages/sec"
mdlReadHitsTotal = "MDL Read Hits %"
mdlReadsTotal = "MDL Reads/sec"
pinReadHitsTotal = "Pin Read Hits %"
pinReadsTotal = "Pin Reads/sec"
readAheadsTotal = "Read Aheads/sec"
syncCopyReadsTotal = "Sync Copy Reads/sec"
syncDataMapsTotal = "Sync Data Maps/sec"
syncFastReadsTotal = "Sync Fast Reads/sec"
syncMDLReadsTotal = "Sync MDL Reads/sec"
syncPinReadsTotal = "Sync Pin Reads/sec"
)

50
internal/collector/cache/types.go vendored Normal file
View File

@@ -0,0 +1,50 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package cache
// Perflib "Cache":
// - https://docs.microsoft.com/en-us/previous-versions/aa394267(v=vs.85)
type perfDataCounterValues struct {
AsyncCopyReadsTotal float64 `perfdata:"Async Copy Reads/sec"`
AsyncDataMapsTotal float64 `perfdata:"Async Data Maps/sec"`
AsyncFastReadsTotal float64 `perfdata:"Async Fast Reads/sec"`
AsyncMDLReadsTotal float64 `perfdata:"Async MDL Reads/sec"`
AsyncPinReadsTotal float64 `perfdata:"Async Pin Reads/sec"`
CopyReadHitsTotal float64 `perfdata:"Copy Read Hits %"`
CopyReadsTotal float64 `perfdata:"Copy Reads/sec"`
DataFlushesTotal float64 `perfdata:"Data Flushes/sec"`
DataFlushPagesTotal float64 `perfdata:"Data Flush Pages/sec"`
DataMapHitsPercent float64 `perfdata:"Data Map Hits %"`
DataMapPinsTotal float64 `perfdata:"Data Map Pins/sec"`
DataMapsTotal float64 `perfdata:"Data Maps/sec"`
DirtyPages float64 `perfdata:"Dirty Pages"`
DirtyPageThreshold float64 `perfdata:"Dirty Page Threshold"`
FastReadNotPossiblesTotal float64 `perfdata:"Fast Read Not Possibles/sec"`
FastReadResourceMissesTotal float64 `perfdata:"Fast Read Resource Misses/sec"`
FastReadsTotal float64 `perfdata:"Fast Reads/sec"`
LazyWriteFlushesTotal float64 `perfdata:"Lazy Write Flushes/sec"`
LazyWritePagesTotal float64 `perfdata:"Lazy Write Pages/sec"`
MdlReadHitsTotal float64 `perfdata:"MDL Read Hits %"`
MdlReadsTotal float64 `perfdata:"MDL Reads/sec"`
PinReadHitsTotal float64 `perfdata:"Pin Read Hits %"`
PinReadsTotal float64 `perfdata:"Pin Reads/sec"`
ReadAheadsTotal float64 `perfdata:"Read Aheads/sec"`
SyncCopyReadsTotal float64 `perfdata:"Sync Copy Reads/sec"`
SyncDataMapsTotal float64 `perfdata:"Sync Data Maps/sec"`
SyncFastReadsTotal float64 `perfdata:"Sync Fast Reads/sec"`
SyncMDLReadsTotal float64 `perfdata:"Sync MDL Reads/sec"`
SyncPinReadsTotal float64 `perfdata:"Sync Pin Reads/sec"`
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package container
@@ -11,7 +24,7 @@ import (
"github.com/Microsoft/hcsshim"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
@@ -20,6 +33,7 @@ const Name = "container"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for containers metrics.
@@ -308,19 +322,19 @@ func (c *Collector) collectContainer(ch chan<- prometheus.Metric, containerDetai
ch <- prometheus.MustNewConstMetric(
c.runtimeTotal,
prometheus.CounterValue,
float64(containerStats.Processor.TotalRuntime100ns)*perfdata.TicksToSecondScaleFactor,
float64(containerStats.Processor.TotalRuntime100ns)*pdh.TicksToSecondScaleFactor,
containerIdWithPrefix,
)
ch <- prometheus.MustNewConstMetric(
c.runtimeUser,
prometheus.CounterValue,
float64(containerStats.Processor.RuntimeUser100ns)*perfdata.TicksToSecondScaleFactor,
float64(containerStats.Processor.RuntimeUser100ns)*pdh.TicksToSecondScaleFactor,
containerIdWithPrefix,
)
ch <- prometheus.MustNewConstMetric(
c.runtimeKernel,
prometheus.CounterValue,
float64(containerStats.Processor.RuntimeKernel100ns)*perfdata.TicksToSecondScaleFactor,
float64(containerStats.Processor.RuntimeKernel100ns)*pdh.TicksToSecondScaleFactor,
containerIdWithPrefix,
)
ch <- prometheus.MustNewConstMetric(

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package container_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, container.Name, container.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, container.New, nil)
}

View File

@@ -1,30 +0,0 @@
//go:build windows
package cpu
// Processor performance counters.
const (
c1TimeSeconds = "% C1 Time"
c2TimeSeconds = "% C2 Time"
c3TimeSeconds = "% C3 Time"
c1TransitionsTotal = "C1 Transitions/sec"
c2TransitionsTotal = "C2 Transitions/sec"
c3TransitionsTotal = "C3 Transitions/sec"
clockInterruptsTotal = "Clock Interrupts/sec"
dpcQueuedPerSecond = "DPCs Queued/sec"
dpcTimeSeconds = "% DPC Time"
idleBreakEventsTotal = "Idle Break Events/sec"
idleTimeSeconds = "% Idle Time"
interruptsTotal = "Interrupts/sec"
interruptTimeSeconds = "% Interrupt Time"
parkingStatus = "Parking Status"
performanceLimitPercent = "% Performance Limit"
priorityTimeSeconds = "% Priority Time"
privilegedTimeSeconds = "% Privileged Time"
privilegedUtilitySeconds = "% Privileged Utility"
processorFrequencyMHz = "Processor Frequency"
processorPerformance = "% Processor Performance"
processorTimeSeconds = "% Processor Time"
processorUtilityRate = "% Processor Utility"
userTimeSeconds = "% User Time"
)

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package cpu
@@ -9,7 +22,7 @@ import (
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus/client_golang/prometheus"
@@ -19,12 +32,14 @@ const Name = "cpu"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
mu sync.Mutex
@@ -78,31 +93,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
c.mu = sync.Mutex{}
c.perfDataCollector, err = perfdata.NewCollector("Processor Information", perfdata.InstanceAll, []string{
c1TimeSeconds,
c2TimeSeconds,
c3TimeSeconds,
c1TransitionsTotal,
c2TransitionsTotal,
c3TransitionsTotal,
clockInterruptsTotal,
dpcQueuedPerSecond,
dpcTimeSeconds,
idleBreakEventsTotal,
idleTimeSeconds,
interruptsTotal,
interruptTimeSeconds,
parkingStatus,
performanceLimitPercent,
priorityTimeSeconds,
privilegedTimeSeconds,
privilegedUtilitySeconds,
processorFrequencyMHz,
processorPerformance,
processorTimeSeconds,
processorUtilityRate,
userTimeSeconds,
})
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues]("Processor Information", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Processor Information collector: %w", err)
}
@@ -113,31 +104,6 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
nil,
nil,
)
c.cStateSecondsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "cstate_seconds_total"),
"Time spent in low-power idle state",
[]string{"core", "state"},
nil,
)
c.timeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "time_total"),
"Time that processor spent in different modes (dpc, idle, interrupt, privileged, user)",
[]string{"core", "mode"},
nil,
)
c.interruptsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "interrupts_total"),
"Total number of received and serviced hardware interrupts",
[]string{"core"},
nil,
)
c.dpcsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dpcs_total"),
"Total number of received and serviced deferred procedure calls (DPCs)",
[]string{"core"},
nil,
)
c.cStateSecondsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "cstate_seconds_total"),
"Time spent in low-power idle state",
@@ -227,14 +193,15 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
c.mu.Lock() // Lock is needed to prevent concurrent map access to c.processorRTCValues
defer c.mu.Unlock()
data, err := c.perfDataCollector.Collect()
err := c.perfDataCollector.Collect(&c.perfDataObject)
if err != nil {
return fmt.Errorf("failed to collect Processor Information metrics: %w", err)
}
var coreCount float64
for core, coreData := range data {
for _, coreData := range c.perfDataObject {
core := coreData.Name
coreCount++
var (
@@ -244,17 +211,17 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
)
if counterProcessorRTCValues, ok = c.processorRTCValues[core]; ok {
counterProcessorRTCValues.AddValue(uint32(coreData[processorUtilityRate].SecondValue))
counterProcessorRTCValues.AddValue(uint32(coreData.ProcessorUtilityRateSecondValue))
} else {
counterProcessorRTCValues = utils.NewCounter(uint32(coreData[privilegedUtilitySeconds].SecondValue))
counterProcessorRTCValues = utils.NewCounter(uint32(coreData.ProcessorUtilityRateSecondValue))
}
c.processorRTCValues[core] = counterProcessorRTCValues
if counterProcessorMPerfValues, ok = c.processorMPerfValues[core]; ok {
counterProcessorMPerfValues.AddValue(uint32(coreData[processorPerformance].SecondValue))
counterProcessorMPerfValues.AddValue(uint32(coreData.ProcessorPerformanceSecondValue))
} else {
counterProcessorMPerfValues = utils.NewCounter(uint32(coreData[processorPerformance].SecondValue))
counterProcessorMPerfValues = utils.NewCounter(uint32(coreData.ProcessorPerformanceSecondValue))
}
c.processorMPerfValues[core] = counterProcessorMPerfValues
@@ -262,95 +229,95 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(
c.cStateSecondsTotal,
prometheus.CounterValue,
coreData[c1TimeSeconds].FirstValue,
coreData.C1TimeSeconds,
core, "c1",
)
ch <- prometheus.MustNewConstMetric(
c.cStateSecondsTotal,
prometheus.CounterValue,
coreData[c2TimeSeconds].FirstValue,
coreData.C2TimeSeconds,
core, "c2",
)
ch <- prometheus.MustNewConstMetric(
c.cStateSecondsTotal,
prometheus.CounterValue,
coreData[c3TimeSeconds].FirstValue,
coreData.C3TimeSeconds,
core, "c3",
)
ch <- prometheus.MustNewConstMetric(
c.timeTotal,
prometheus.CounterValue,
coreData[idleTimeSeconds].FirstValue,
coreData.IdleTimeSeconds,
core, "idle",
)
ch <- prometheus.MustNewConstMetric(
c.timeTotal,
prometheus.CounterValue,
coreData[interruptTimeSeconds].FirstValue,
coreData.InterruptTimeSeconds,
core, "interrupt",
)
ch <- prometheus.MustNewConstMetric(
c.timeTotal,
prometheus.CounterValue,
coreData[dpcTimeSeconds].FirstValue,
coreData.DpcTimeSeconds,
core, "dpc",
)
ch <- prometheus.MustNewConstMetric(
c.timeTotal,
prometheus.CounterValue,
coreData[privilegedTimeSeconds].FirstValue,
coreData.PrivilegedTimeSeconds,
core, "privileged",
)
ch <- prometheus.MustNewConstMetric(
c.timeTotal,
prometheus.CounterValue,
coreData[userTimeSeconds].FirstValue,
coreData.UserTimeSeconds,
core, "user",
)
ch <- prometheus.MustNewConstMetric(
c.interruptsTotal,
prometheus.CounterValue,
coreData[interruptsTotal].FirstValue,
coreData.InterruptsTotal,
core,
)
ch <- prometheus.MustNewConstMetric(
c.dpcsTotal,
prometheus.CounterValue,
coreData[dpcQueuedPerSecond].FirstValue,
coreData.DpcQueuedPerSecond,
core,
)
ch <- prometheus.MustNewConstMetric(
c.clockInterruptsTotal,
prometheus.CounterValue,
coreData[clockInterruptsTotal].FirstValue,
coreData.ClockInterruptsTotal,
core,
)
ch <- prometheus.MustNewConstMetric(
c.idleBreakEventsTotal,
prometheus.CounterValue,
coreData[idleBreakEventsTotal].FirstValue,
coreData.IdleBreakEventsTotal,
core,
)
ch <- prometheus.MustNewConstMetric(
c.parkingStatus,
prometheus.GaugeValue,
coreData[parkingStatus].FirstValue,
coreData.ParkingStatus,
core,
)
ch <- prometheus.MustNewConstMetric(
c.processorFrequencyMHz,
prometheus.GaugeValue,
coreData[processorFrequencyMHz].FirstValue,
coreData.ProcessorFrequencyMHz,
core,
)
ch <- prometheus.MustNewConstMetric(
c.processorPerformance,
prometheus.CounterValue,
coreData[processorPerformance].FirstValue,
coreData.ProcessorPerformance,
core,
)
ch <- prometheus.MustNewConstMetric(
@@ -368,13 +335,13 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(
c.processorUtility,
prometheus.CounterValue,
coreData[processorUtilityRate].FirstValue,
coreData.ProcessorUtilityRate,
core,
)
ch <- prometheus.MustNewConstMetric(
c.processorPrivilegedUtility,
prometheus.CounterValue,
coreData[privilegedUtilitySeconds].FirstValue,
coreData.PrivilegedUtilitySeconds,
core,
)
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package cpu_test

View File

@@ -0,0 +1,47 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package cpu
// Processor performance counters.
type perfDataCounterValues struct {
Name string
C1TimeSeconds float64 `perfdata:"% C1 Time"`
C2TimeSeconds float64 `perfdata:"% C2 Time"`
C3TimeSeconds float64 `perfdata:"% C3 Time"`
C1TransitionsTotal float64 `perfdata:"C1 Transitions/sec"`
C2TransitionsTotal float64 `perfdata:"C2 Transitions/sec"`
C3TransitionsTotal float64 `perfdata:"C3 Transitions/sec"`
ClockInterruptsTotal float64 `perfdata:"Clock Interrupts/sec"`
DpcQueuedPerSecond float64 `perfdata:"DPCs Queued/sec"`
DpcTimeSeconds float64 `perfdata:"% DPC Time"`
IdleBreakEventsTotal float64 `perfdata:"Idle Break Events/sec"`
IdleTimeSeconds float64 `perfdata:"% Idle Time"`
InterruptsTotal float64 `perfdata:"Interrupts/sec"`
InterruptTimeSeconds float64 `perfdata:"% Interrupt Time"`
ParkingStatus float64 `perfdata:"Parking Status"`
PerformanceLimitPercent float64 `perfdata:"% Performance Limit"`
PriorityTimeSeconds float64 `perfdata:"% Priority Time"`
PrivilegedTimeSeconds float64 `perfdata:"% Privileged Time"`
PrivilegedUtilitySeconds float64 `perfdata:"% Privileged Utility"`
ProcessorFrequencyMHz float64 `perfdata:"Processor Frequency"`
ProcessorPerformance float64 `perfdata:"% Processor Performance"`
ProcessorPerformanceSecondValue float64 `perfdata:"% Processor Performance,secondvalue"`
ProcessorTimeSeconds float64 `perfdata:"% Processor Time"`
ProcessorUtilityRate float64 `perfdata:"% Processor Utility"`
ProcessorUtilityRateSecondValue float64 `perfdata:"% Processor Utility,secondvalue"`
UserTimeSeconds float64 `perfdata:"% User Time"`
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package cpu_info
@@ -19,6 +32,7 @@ const Name = "cpu_info"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for a few WMI metrics in Win32_Processor.
@@ -134,6 +148,11 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
nil,
)
var dst []miProcessor
if err := c.miSession.Query(&dst, mi.NamespaceRootCIMv2, c.miQuery); err != nil {
return fmt.Errorf("WMI query failed: %w", err)
}
return nil
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package cpu_info_test

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package cs
@@ -16,6 +29,7 @@ const Name = "cs"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for WMI metrics.
@@ -23,10 +37,10 @@ type Collector struct {
config Config
// physicalMemoryBytes
// Deprecated: Use windows_cpu_logical_processor instead
// Deprecated: Use windows_physical_memory_total_bytes instead
physicalMemoryBytes *prometheus.Desc
// logicalProcessors
// Deprecated: Use windows_physical_memory_total_bytes instead
// Deprecated: Use windows_cpu_logical_processor instead
logicalProcessors *prometheus.Desc
// hostname
// Deprecated: Use windows_os_hostname instead

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package cs_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, cs.Name, cs.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, cs.New, nil)
}

View File

@@ -1,44 +0,0 @@
//go:build windows
package dfsr
const (
// Connection Perflib: "DFS Replication Service Connections".
bytesReceivedTotal = "Total Bytes Received"
// Folder Perflib: "DFS Replicated Folder".
bandwidthSavingsUsingDFSReplicationTotal = "Bandwidth Savings Using DFS Replication"
compressedSizeOfFilesReceivedTotal = "Compressed Size of Files Received"
conflictBytesCleanedUpTotal = "Conflict Bytes Cleaned Up"
conflictBytesGeneratedTotal = "Conflict Bytes Generated"
conflictFilesCleanedUpTotal = "Conflict Files Cleaned Up"
conflictFilesGeneratedTotal = "Conflict Files Generated"
conflictFolderCleanupsCompletedTotal = "Conflict folder Cleanups Completed"
conflictSpaceInUse = "Conflict Space In Use"
deletedSpaceInUse = "Deleted Space In Use"
deletedBytesCleanedUpTotal = "Deleted Bytes Cleaned Up"
deletedBytesGeneratedTotal = "Deleted Bytes Generated"
deletedFilesCleanedUpTotal = "Deleted Files Cleaned Up"
deletedFilesGeneratedTotal = "Deleted Files Generated"
fileInstallsRetriedTotal = "File Installs Retried"
fileInstallsSucceededTotal = "File Installs Succeeded"
filesReceivedTotal = "Total Files Received"
rdcBytesReceivedTotal = "RDC Bytes Received"
rdcCompressedSizeOfFilesReceivedTotal = "RDC Compressed Size of Files Received"
rdcNumberOfFilesReceivedTotal = "RDC Number of Files Received"
rdcSizeOfFilesReceivedTotal = "RDC Size of Files Received"
sizeOfFilesReceivedTotal = "Size of Files Received"
stagingSpaceInUse = "Staging Space In Use"
stagingBytesCleanedUpTotal = "Staging Bytes Cleaned Up"
stagingBytesGeneratedTotal = "Staging Bytes Generated"
stagingFilesCleanedUpTotal = "Staging Files Cleaned Up"
stagingFilesGeneratedTotal = "Staging Files Generated"
updatesDroppedTotal = "Updates Dropped"
// Volume Perflib: "DFS Replication Service Volumes".
databaseCommitsTotal = "Database Commits"
databaseLookupsTotal = "Database Lookups"
usnJournalRecordsReadTotal = "USN Journal Records Read"
usnJournalRecordsAcceptedTotal = "USN Journal Records Accepted"
usnJournalUnreadPercentage = "USN Journal Records Unread Percentage"
)

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package dfsr
@@ -11,7 +24,7 @@ import (
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
@@ -22,6 +35,7 @@ type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
}
//nolint:gochecknoglobals
var ConfigDefaults = Config{
CollectorsEnabled: []string{"connection", "folder", "volume"},
}
@@ -30,9 +44,12 @@ var ConfigDefaults = Config{
type Collector struct {
config Config
perfDataCollectorConnection *perfdata.Collector
perfDataCollectorFolder *perfdata.Collector
perfDataCollectorVolume *perfdata.Collector
perfDataCollectorConnection *pdh.Collector
perfDataCollectorFolder *pdh.Collector
perfDataCollectorVolume *pdh.Collector
perfDataObjectConnection []perfDataCounterValuesConnection
perfDataObjectFolder []perfDataCounterValuesFolder
perfDataObjectVolume []perfDataCounterValuesVolume
// connection source
connectionBandwidthSavingsUsingDFSReplicationTotal *prometheus.Desc
@@ -146,69 +163,26 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
var err error
if slices.Contains(c.config.CollectorsEnabled, "connection") {
c.perfDataCollectorConnection, err = perfdata.NewCollector("DFS Replication Connections", perfdata.InstanceAll, []string{
bandwidthSavingsUsingDFSReplicationTotal,
bytesReceivedTotal,
compressedSizeOfFilesReceivedTotal,
filesReceivedTotal,
rdcBytesReceivedTotal,
rdcCompressedSizeOfFilesReceivedTotal,
rdcNumberOfFilesReceivedTotal,
rdcSizeOfFilesReceivedTotal,
sizeOfFilesReceivedTotal,
})
c.perfDataCollectorConnection, err = pdh.NewCollector[perfDataCounterValuesConnection]("DFS Replication Connections", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create DFS Replication Connections collector: %w", err)
}
}
if slices.Contains(c.config.CollectorsEnabled, "folder") {
c.perfDataCollectorFolder, err = perfdata.NewCollector("DFS Replicated Folders", perfdata.InstanceAll, []string{
bandwidthSavingsUsingDFSReplicationTotal,
compressedSizeOfFilesReceivedTotal,
conflictBytesCleanedUpTotal,
conflictBytesGeneratedTotal,
conflictFilesCleanedUpTotal,
conflictFilesGeneratedTotal,
conflictFolderCleanupsCompletedTotal,
conflictSpaceInUse,
deletedSpaceInUse,
deletedBytesCleanedUpTotal,
deletedBytesGeneratedTotal,
deletedFilesCleanedUpTotal,
deletedFilesGeneratedTotal,
fileInstallsRetriedTotal,
fileInstallsSucceededTotal,
filesReceivedTotal,
rdcBytesReceivedTotal,
rdcCompressedSizeOfFilesReceivedTotal,
rdcNumberOfFilesReceivedTotal,
rdcSizeOfFilesReceivedTotal,
sizeOfFilesReceivedTotal,
stagingSpaceInUse,
stagingBytesCleanedUpTotal,
stagingBytesGeneratedTotal,
stagingFilesCleanedUpTotal,
stagingFilesGeneratedTotal,
updatesDroppedTotal,
})
c.perfDataCollectorFolder, err = pdh.NewCollector[perfDataCounterValuesFolder]("DFS Replicated Folders", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create DFS Replicated Folders collector: %w", err)
}
}
if slices.Contains(c.config.CollectorsEnabled, "volume") {
c.perfDataCollectorVolume, err = perfdata.NewCollector("DFS Replication Service Volumes", perfdata.InstanceAll, []string{
databaseCommitsTotal,
databaseLookupsTotal,
usnJournalRecordsReadTotal,
usnJournalRecordsAcceptedTotal,
usnJournalUnreadPercentage,
})
c.perfDataCollectorVolume, err = pdh.NewCollector[perfDataCounterValuesVolume]("DFS Replication Service Volumes", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create DFS Replication Service Volumes collector: %w", err)
}
}
// connection
c.connectionBandwidthSavingsUsingDFSReplicationTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "connection_bandwidth_savings_using_dfs_replication_bytes_total"),
@@ -523,76 +497,74 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
}
func (c *Collector) collectPDHConnection(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorConnection.Collect()
err := c.perfDataCollectorConnection.Collect(&c.perfDataObjectConnection)
if err != nil {
return fmt.Errorf("failed to collect DFS Replication Connections metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for DFS Replication Connections returned empty result set")
}
for _, connection := range c.perfDataObjectConnection {
name := connection.Name
for name, connection := range perfData {
ch <- prometheus.MustNewConstMetric(
c.connectionBandwidthSavingsUsingDFSReplicationTotal,
prometheus.CounterValue,
connection[bandwidthSavingsUsingDFSReplicationTotal].FirstValue,
connection.BandwidthSavingsUsingDFSReplicationTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.connectionBytesReceivedTotal,
prometheus.CounterValue,
connection[bytesReceivedTotal].FirstValue,
connection.BytesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.connectionCompressedSizeOfFilesReceivedTotal,
prometheus.CounterValue,
connection[compressedSizeOfFilesReceivedTotal].FirstValue,
connection.CompressedSizeOfFilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.connectionFilesReceivedTotal,
prometheus.CounterValue,
connection[filesReceivedTotal].FirstValue,
connection.FilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.connectionRDCBytesReceivedTotal,
prometheus.CounterValue,
connection[rdcBytesReceivedTotal].FirstValue,
connection.RdcBytesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.connectionRDCCompressedSizeOfFilesReceivedTotal,
prometheus.CounterValue,
connection[rdcCompressedSizeOfFilesReceivedTotal].FirstValue,
connection.RdcCompressedSizeOfFilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.connectionRDCSizeOfFilesReceivedTotal,
prometheus.CounterValue,
connection[rdcSizeOfFilesReceivedTotal].FirstValue,
connection.RdcSizeOfFilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.connectionRDCNumberOfFilesReceivedTotal,
prometheus.CounterValue,
connection[rdcNumberOfFilesReceivedTotal].FirstValue,
connection.RdcNumberOfFilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.connectionSizeOfFilesReceivedTotal,
prometheus.CounterValue,
connection[sizeOfFilesReceivedTotal].FirstValue,
connection.SizeOfFilesReceivedTotal,
name,
)
}
@@ -601,202 +573,200 @@ func (c *Collector) collectPDHConnection(ch chan<- prometheus.Metric) error {
}
func (c *Collector) collectPDHFolder(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorFolder.Collect()
err := c.perfDataCollectorFolder.Collect(&c.perfDataObjectFolder)
if err != nil {
return fmt.Errorf("failed to collect DFS Replicated Folders metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for DFS Replicated Folders returned empty result set")
}
for _, folder := range c.perfDataObjectFolder {
name := folder.Name
for name, folder := range perfData {
ch <- prometheus.MustNewConstMetric(
c.folderBandwidthSavingsUsingDFSReplicationTotal,
prometheus.CounterValue,
folder[bandwidthSavingsUsingDFSReplicationTotal].FirstValue,
folder.BandwidthSavingsUsingDFSReplicationTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderCompressedSizeOfFilesReceivedTotal,
prometheus.CounterValue,
folder[compressedSizeOfFilesReceivedTotal].FirstValue,
folder.CompressedSizeOfFilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderConflictBytesCleanedUpTotal,
prometheus.CounterValue,
folder[conflictBytesCleanedUpTotal].FirstValue,
folder.ConflictBytesCleanedUpTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderConflictBytesGeneratedTotal,
prometheus.CounterValue,
folder[conflictBytesGeneratedTotal].FirstValue,
folder.ConflictBytesGeneratedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderConflictFilesCleanedUpTotal,
prometheus.CounterValue,
folder[conflictFilesCleanedUpTotal].FirstValue,
folder.ConflictFilesCleanedUpTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderConflictFilesGeneratedTotal,
prometheus.CounterValue,
folder[conflictFilesGeneratedTotal].FirstValue,
folder.ConflictFilesGeneratedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderConflictFolderCleanupsCompletedTotal,
prometheus.CounterValue,
folder[conflictFolderCleanupsCompletedTotal].FirstValue,
folder.ConflictFolderCleanupsCompletedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderConflictSpaceInUse,
prometheus.GaugeValue,
folder[conflictSpaceInUse].FirstValue,
folder.ConflictSpaceInUse,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderDeletedSpaceInUse,
prometheus.GaugeValue,
folder[deletedSpaceInUse].FirstValue,
folder.DeletedSpaceInUse,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderDeletedBytesCleanedUpTotal,
prometheus.CounterValue,
folder[deletedBytesCleanedUpTotal].FirstValue,
folder.DeletedBytesCleanedUpTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderDeletedBytesGeneratedTotal,
prometheus.CounterValue,
folder[deletedBytesGeneratedTotal].FirstValue,
folder.DeletedBytesGeneratedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderDeletedFilesCleanedUpTotal,
prometheus.CounterValue,
folder[deletedFilesCleanedUpTotal].FirstValue,
folder.DeletedFilesCleanedUpTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderDeletedFilesGeneratedTotal,
prometheus.CounterValue,
folder[deletedFilesGeneratedTotal].FirstValue,
folder.DeletedFilesGeneratedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderFileInstallsRetriedTotal,
prometheus.CounterValue,
folder[fileInstallsRetriedTotal].FirstValue,
folder.FileInstallsRetriedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderFileInstallsSucceededTotal,
prometheus.CounterValue,
folder[fileInstallsSucceededTotal].FirstValue,
folder.FileInstallsSucceededTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderFilesReceivedTotal,
prometheus.CounterValue,
folder[filesReceivedTotal].FirstValue,
folder.FilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderRDCBytesReceivedTotal,
prometheus.CounterValue,
folder[rdcBytesReceivedTotal].FirstValue,
folder.RdcBytesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderRDCCompressedSizeOfFilesReceivedTotal,
prometheus.CounterValue,
folder[rdcCompressedSizeOfFilesReceivedTotal].FirstValue,
folder.RdcCompressedSizeOfFilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderRDCNumberOfFilesReceivedTotal,
prometheus.CounterValue,
folder[rdcNumberOfFilesReceivedTotal].FirstValue,
folder.RdcNumberOfFilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderRDCSizeOfFilesReceivedTotal,
prometheus.CounterValue,
folder[rdcSizeOfFilesReceivedTotal].FirstValue,
folder.RdcSizeOfFilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderSizeOfFilesReceivedTotal,
prometheus.CounterValue,
folder[sizeOfFilesReceivedTotal].FirstValue,
folder.SizeOfFilesReceivedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderStagingSpaceInUse,
prometheus.GaugeValue,
folder[stagingSpaceInUse].FirstValue,
folder.StagingSpaceInUse,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderStagingBytesCleanedUpTotal,
prometheus.CounterValue,
folder[stagingBytesCleanedUpTotal].FirstValue,
folder.StagingBytesCleanedUpTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderStagingBytesGeneratedTotal,
prometheus.CounterValue,
folder[stagingBytesGeneratedTotal].FirstValue,
folder.StagingBytesGeneratedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderStagingFilesCleanedUpTotal,
prometheus.CounterValue,
folder[stagingFilesCleanedUpTotal].FirstValue,
folder.StagingFilesCleanedUpTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderStagingFilesGeneratedTotal,
prometheus.CounterValue,
folder[stagingFilesGeneratedTotal].FirstValue,
folder.StagingFilesGeneratedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.folderUpdatesDroppedTotal,
prometheus.CounterValue,
folder[updatesDroppedTotal].FirstValue,
folder.UpdatesDroppedTotal,
name,
)
}
@@ -805,48 +775,45 @@ func (c *Collector) collectPDHFolder(ch chan<- prometheus.Metric) error {
}
func (c *Collector) collectPDHVolume(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorVolume.Collect()
err := c.perfDataCollectorVolume.Collect(&c.perfDataObjectVolume)
if err != nil {
return fmt.Errorf("failed to collect DFS Replication Volumes metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for DFS Replication Volumes returned empty result set")
}
for name, volume := range perfData {
for _, volume := range c.perfDataObjectVolume {
name := volume.Name
ch <- prometheus.MustNewConstMetric(
c.volumeDatabaseLookupsTotal,
prometheus.CounterValue,
volume[databaseLookupsTotal].FirstValue,
volume.DatabaseLookupsTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.volumeDatabaseCommitsTotal,
prometheus.CounterValue,
volume[databaseCommitsTotal].FirstValue,
volume.DatabaseCommitsTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.volumeUSNJournalRecordsAcceptedTotal,
prometheus.CounterValue,
volume[usnJournalRecordsAcceptedTotal].FirstValue,
volume.UsnJournalRecordsAcceptedTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.volumeUSNJournalRecordsReadTotal,
prometheus.CounterValue,
volume[usnJournalRecordsReadTotal].FirstValue,
volume.UsnJournalRecordsReadTotal,
name,
)
ch <- prometheus.MustNewConstMetric(
c.volumeUSNJournalUnreadPercentage,
prometheus.GaugeValue,
volume[usnJournalUnreadPercentage].FirstValue,
volume.UsnJournalUnreadPercentage,
name,
)
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package dfsr_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, dfsr.Name, dfsr.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, dfsr.New, nil)
}

View File

@@ -0,0 +1,75 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package dfsr
// Connection Perflib: "DFS Replication Service Connections".
type perfDataCounterValuesConnection struct {
Name string
BandwidthSavingsUsingDFSReplicationTotal float64 `perfdata:"Bandwidth Savings Using DFS Replication"`
BytesReceivedTotal float64 `perfdata:"Total Bytes Received"`
CompressedSizeOfFilesReceivedTotal float64 `perfdata:"Compressed Size of Files Received"`
FilesReceivedTotal float64 `perfdata:"Total Files Received"`
RdcBytesReceivedTotal float64 `perfdata:"RDC Bytes Received"`
RdcCompressedSizeOfFilesReceivedTotal float64 `perfdata:"RDC Compressed Size of Files Received"`
RdcNumberOfFilesReceivedTotal float64 `perfdata:"RDC Number of Files Received"`
RdcSizeOfFilesReceivedTotal float64 `perfdata:"RDC Size of Files Received"`
SizeOfFilesReceivedTotal float64 `perfdata:"Size of Files Received"`
}
// Folder Perflib: "DFS Replicated Folder".
type perfDataCounterValuesFolder struct {
Name string
BandwidthSavingsUsingDFSReplicationTotal float64 `perfdata:"Bandwidth Savings Using DFS Replication"`
CompressedSizeOfFilesReceivedTotal float64 `perfdata:"Compressed Size of Files Received"`
ConflictBytesCleanedUpTotal float64 `perfdata:"Conflict Bytes Cleaned Up"`
ConflictBytesGeneratedTotal float64 `perfdata:"Conflict Bytes Generated"`
ConflictFilesCleanedUpTotal float64 `perfdata:"Conflict Files Cleaned Up"`
ConflictFilesGeneratedTotal float64 `perfdata:"Conflict Files Generated"`
ConflictFolderCleanupsCompletedTotal float64 `perfdata:"Conflict folder Cleanups Completed"`
ConflictSpaceInUse float64 `perfdata:"Conflict Space In Use"`
DeletedSpaceInUse float64 `perfdata:"Deleted Space In Use"`
DeletedBytesCleanedUpTotal float64 `perfdata:"Deleted Bytes Cleaned Up"`
DeletedBytesGeneratedTotal float64 `perfdata:"Deleted Bytes Generated"`
DeletedFilesCleanedUpTotal float64 `perfdata:"Deleted Files Cleaned Up"`
DeletedFilesGeneratedTotal float64 `perfdata:"Deleted Files Generated"`
FileInstallsRetriedTotal float64 `perfdata:"File Installs Retried"`
FileInstallsSucceededTotal float64 `perfdata:"File Installs Succeeded"`
FilesReceivedTotal float64 `perfdata:"Total Files Received"`
RdcBytesReceivedTotal float64 `perfdata:"RDC Bytes Received"`
RdcCompressedSizeOfFilesReceivedTotal float64 `perfdata:"RDC Compressed Size of Files Received"`
RdcNumberOfFilesReceivedTotal float64 `perfdata:"RDC Number of Files Received"`
RdcSizeOfFilesReceivedTotal float64 `perfdata:"RDC Size of Files Received"`
SizeOfFilesReceivedTotal float64 `perfdata:"Size of Files Received"`
StagingSpaceInUse float64 `perfdata:"Staging Space In Use"`
StagingBytesCleanedUpTotal float64 `perfdata:"Staging Bytes Cleaned Up"`
StagingBytesGeneratedTotal float64 `perfdata:"Staging Bytes Generated"`
StagingFilesCleanedUpTotal float64 `perfdata:"Staging Files Cleaned Up"`
StagingFilesGeneratedTotal float64 `perfdata:"Staging Files Generated"`
UpdatesDroppedTotal float64 `perfdata:"Updates Dropped"`
}
// Volume Perflib: "DFS Replication Service Volumes".
type perfDataCounterValuesVolume struct {
Name string
DatabaseCommitsTotal float64 `perfdata:"Database Commits"`
DatabaseLookupsTotal float64 `perfdata:"Database Lookups"`
UsnJournalRecordsReadTotal float64 `perfdata:"USN Journal Records Read"`
UsnJournalRecordsAcceptedTotal float64 `perfdata:"USN Journal Records Accepted"`
UsnJournalUnreadPercentage float64 `perfdata:"USN Journal Unread Percentage"`
}

View File

@@ -1,31 +0,0 @@
//go:build windows
package dhcp
const (
acksTotal = "Acks/sec"
activeQueueLength = "Active Queue Length"
conflictCheckQueueLength = "Conflict Check Queue Length"
declinesTotal = "Declines/sec"
deniedDueToMatch = "Denied due to match."
deniedDueToNonMatch = "Denied due to match."
discoversTotal = "Discovers/sec"
duplicatesDroppedTotal = "Duplicates Dropped/sec"
failoverBndAckReceivedTotal = "Failover: BndAck received/sec."
failoverBndAckSentTotal = "Failover: BndAck sent/sec."
failoverBndUpdDropped = "Failover: BndUpd Dropped."
failoverBndUpdPendingOutboundQueue = "Failover: BndUpd pending in outbound queue."
failoverBndUpdReceivedTotal = "Failover: BndUpd received/sec."
failoverBndUpdSentTotal = "Failover: BndUpd sent/sec."
failoverTransitionsCommunicationInterruptedState = "Failover: Transitions to COMMUNICATION-INTERRUPTED state."
failoverTransitionsPartnerDownState = "Failover: Transitions to PARTNER-DOWN state."
failoverTransitionsRecoverState = "Failover: Transitions to RECOVER state."
informsTotal = "Informs/sec"
nacksTotal = "Nacks/sec"
offerQueueLength = "Offer Queue Length"
offersTotal = "Offers/sec"
packetsExpiredTotal = "Packets Expired/sec"
packetsReceivedTotal = "Packets Received/sec"
releasesTotal = "Releases/sec"
requestsTotal = "Requests/sec"
)

View File

@@ -1,15 +1,27 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package dhcp
import (
"errors"
"fmt"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
@@ -18,13 +30,15 @@ const Name = "dhcp"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector perflib DHCP metrics.
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
acksTotal *prometheus.Desc
activeQueueLength *prometheus.Desc
@@ -82,33 +96,7 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error
c.perfDataCollector, err = perfdata.NewCollector("DHCP Server", perfdata.InstanceAll, []string{
acksTotal,
activeQueueLength,
conflictCheckQueueLength,
declinesTotal,
deniedDueToMatch,
deniedDueToNonMatch,
discoversTotal,
duplicatesDroppedTotal,
failoverBndAckReceivedTotal,
failoverBndAckSentTotal,
failoverBndUpdDropped,
failoverBndUpdPendingOutboundQueue,
failoverBndUpdReceivedTotal,
failoverBndUpdSentTotal,
failoverTransitionsCommunicationInterruptedState,
failoverTransitionsPartnerDownState,
failoverTransitionsRecoverState,
informsTotal,
nacksTotal,
offerQueueLength,
offersTotal,
packetsExpiredTotal,
packetsReceivedTotal,
releasesTotal,
requestsTotal,
})
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues]("DHCP Server", nil)
if err != nil {
return fmt.Errorf("failed to create DHCP Server collector: %w", err)
}
@@ -268,164 +256,159 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
}
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollector.Collect()
err := c.perfDataCollector.Collect(&c.perfDataObject)
if err != nil {
return fmt.Errorf("failed to collect DHCP Server metrics: %w", err)
}
data, ok := perfData[perfdata.EmptyInstance]
if !ok {
return errors.New("perflib query for DHCP Server returned empty result set")
}
ch <- prometheus.MustNewConstMetric(
c.packetsReceivedTotal,
prometheus.CounterValue,
data[packetsReceivedTotal].FirstValue,
c.perfDataObject[0].PacketsReceivedTotal,
)
ch <- prometheus.MustNewConstMetric(
c.duplicatesDroppedTotal,
prometheus.CounterValue,
data[duplicatesDroppedTotal].FirstValue,
c.perfDataObject[0].DuplicatesDroppedTotal,
)
ch <- prometheus.MustNewConstMetric(
c.packetsExpiredTotal,
prometheus.CounterValue,
data[packetsExpiredTotal].FirstValue,
c.perfDataObject[0].PacketsExpiredTotal,
)
ch <- prometheus.MustNewConstMetric(
c.activeQueueLength,
prometheus.GaugeValue,
data[activeQueueLength].FirstValue,
c.perfDataObject[0].ActiveQueueLength,
)
ch <- prometheus.MustNewConstMetric(
c.conflictCheckQueueLength,
prometheus.GaugeValue,
data[conflictCheckQueueLength].FirstValue,
c.perfDataObject[0].ConflictCheckQueueLength,
)
ch <- prometheus.MustNewConstMetric(
c.discoversTotal,
prometheus.CounterValue,
data[discoversTotal].FirstValue,
c.perfDataObject[0].DiscoversTotal,
)
ch <- prometheus.MustNewConstMetric(
c.offersTotal,
prometheus.CounterValue,
data[offersTotal].FirstValue,
c.perfDataObject[0].OffersTotal,
)
ch <- prometheus.MustNewConstMetric(
c.requestsTotal,
prometheus.CounterValue,
data[requestsTotal].FirstValue,
c.perfDataObject[0].RequestsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.informsTotal,
prometheus.CounterValue,
data[informsTotal].FirstValue,
c.perfDataObject[0].InformsTotal,
)
ch <- prometheus.MustNewConstMetric(
c.acksTotal,
prometheus.CounterValue,
data[acksTotal].FirstValue,
c.perfDataObject[0].AcksTotal,
)
ch <- prometheus.MustNewConstMetric(
c.nACKsTotal,
prometheus.CounterValue,
data[nacksTotal].FirstValue,
c.perfDataObject[0].NacksTotal,
)
ch <- prometheus.MustNewConstMetric(
c.declinesTotal,
prometheus.CounterValue,
data[declinesTotal].FirstValue,
c.perfDataObject[0].DeclinesTotal,
)
ch <- prometheus.MustNewConstMetric(
c.releasesTotal,
prometheus.CounterValue,
data[releasesTotal].FirstValue,
c.perfDataObject[0].ReleasesTotal,
)
ch <- prometheus.MustNewConstMetric(
c.offerQueueLength,
prometheus.GaugeValue,
data[offerQueueLength].FirstValue,
c.perfDataObject[0].OfferQueueLength,
)
ch <- prometheus.MustNewConstMetric(
c.deniedDueToMatch,
prometheus.CounterValue,
data[deniedDueToMatch].FirstValue,
c.perfDataObject[0].DeniedDueToMatch,
)
ch <- prometheus.MustNewConstMetric(
c.deniedDueToNonMatch,
prometheus.CounterValue,
data[deniedDueToNonMatch].FirstValue,
c.perfDataObject[0].DeniedDueToNonMatch,
)
ch <- prometheus.MustNewConstMetric(
c.failoverBndUpdSentTotal,
prometheus.CounterValue,
data[failoverBndUpdSentTotal].FirstValue,
c.perfDataObject[0].FailoverBndUpdSentTotal,
)
ch <- prometheus.MustNewConstMetric(
c.failoverBndUpdReceivedTotal,
prometheus.CounterValue,
data[failoverBndUpdReceivedTotal].FirstValue,
c.perfDataObject[0].FailoverBndUpdReceivedTotal,
)
ch <- prometheus.MustNewConstMetric(
c.failoverBndAckSentTotal,
prometheus.CounterValue,
data[failoverBndAckSentTotal].FirstValue,
c.perfDataObject[0].FailoverBndAckSentTotal,
)
ch <- prometheus.MustNewConstMetric(
c.failoverBndAckReceivedTotal,
prometheus.CounterValue,
data[failoverBndAckReceivedTotal].FirstValue,
c.perfDataObject[0].FailoverBndAckReceivedTotal,
)
ch <- prometheus.MustNewConstMetric(
c.failoverBndUpdPendingOutboundQueue,
prometheus.GaugeValue,
data[failoverBndUpdPendingOutboundQueue].FirstValue,
c.perfDataObject[0].FailoverBndUpdPendingOutboundQueue,
)
ch <- prometheus.MustNewConstMetric(
c.failoverTransitionsCommunicationInterruptedState,
prometheus.CounterValue,
data[failoverTransitionsCommunicationInterruptedState].FirstValue,
c.perfDataObject[0].FailoverTransitionsCommunicationInterruptedState,
)
ch <- prometheus.MustNewConstMetric(
c.failoverTransitionsPartnerDownState,
prometheus.CounterValue,
data[failoverTransitionsPartnerDownState].FirstValue,
c.perfDataObject[0].FailoverTransitionsPartnerDownState,
)
ch <- prometheus.MustNewConstMetric(
c.failoverTransitionsRecoverState,
prometheus.CounterValue,
data[failoverTransitionsRecoverState].FirstValue,
c.perfDataObject[0].FailoverTransitionsRecoverState,
)
ch <- prometheus.MustNewConstMetric(
c.failoverBndUpdDropped,
prometheus.CounterValue,
data[failoverBndUpdDropped].FirstValue,
c.perfDataObject[0].FailoverBndUpdDropped,
)
return nil

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package dhcp_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, dhcp.Name, dhcp.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, dhcp.New, nil)
}

View File

@@ -0,0 +1,44 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package dhcp
type perfDataCounterValues struct {
AcksTotal float64 `perfdata:"Acks/sec"`
ActiveQueueLength float64 `perfdata:"Active Queue Length"`
ConflictCheckQueueLength float64 `perfdata:"Conflict Check Queue Length"`
DeclinesTotal float64 `perfdata:"Declines/sec"`
DeniedDueToMatch float64 `perfdata:"Denied due to match."`
DeniedDueToNonMatch float64 `perfdata:"Denied due to match."`
DiscoversTotal float64 `perfdata:"Discovers/sec"`
DuplicatesDroppedTotal float64 `perfdata:"Duplicates Dropped/sec"`
FailoverBndAckReceivedTotal float64 `perfdata:"Failover: BndAck received/sec."`
FailoverBndAckSentTotal float64 `perfdata:"Failover: BndAck sent/sec."`
FailoverBndUpdDropped float64 `perfdata:"Failover: BndUpd Dropped."`
FailoverBndUpdPendingOutboundQueue float64 `perfdata:"Failover: BndUpd pending in outbound queue."`
FailoverBndUpdReceivedTotal float64 `perfdata:"Failover: BndUpd received/sec."`
FailoverBndUpdSentTotal float64 `perfdata:"Failover: BndUpd sent/sec."`
FailoverTransitionsCommunicationInterruptedState float64 `perfdata:"Failover: Transitions to COMMUNICATION-INTERRUPTED state."`
FailoverTransitionsPartnerDownState float64 `perfdata:"Failover: Transitions to PARTNER-DOWN state."`
FailoverTransitionsRecoverState float64 `perfdata:"Failover: Transitions to RECOVER state."`
InformsTotal float64 `perfdata:"Informs/sec"`
NacksTotal float64 `perfdata:"Nacks/sec"`
OfferQueueLength float64 `perfdata:"Offer Queue Length"`
OffersTotal float64 `perfdata:"Offers/sec"`
PacketsExpiredTotal float64 `perfdata:"Packets Expired/sec"`
PacketsReceivedTotal float64 `perfdata:"Packets Received/sec"`
ReleasesTotal float64 `perfdata:"Releases/sec"`
RequestsTotal float64 `perfdata:"Requests/sec"`
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package diskdrive
@@ -18,6 +31,7 @@ const Name = "diskdrive"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for a few WMI metrics in Win32_DiskDrive.
@@ -106,6 +120,11 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
nil,
)
var dst []diskDrive
if err := c.miSession.Query(&dst, mi.NamespaceRootCIMv2, c.miQuery); err != nil {
return fmt.Errorf("WMI query failed: %w", err)
}
return nil
}
@@ -120,6 +139,7 @@ type diskDrive struct {
Availability uint16 `mi:"Availability"`
}
//nolint:gochecknoglobals
var (
allDiskStatus = []string{
"OK",

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package diskdrive_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, diskdrive.Name, diskdrive.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, diskdrive.New, nil)
}

View File

@@ -1,94 +0,0 @@
//go:build windows
package dns
const (
_ = "% User Time"
_ = "176"
_ = "Async Fast Reads/sec"
axfrRequestReceived = "AXFR Request Received"
axfrRequestSent = "AXFR Request Sent"
axfrResponseReceived = "AXFR Response Received"
axfrSuccessReceived = "AXFR Success Received"
axfrSuccessSent = "AXFR Success Sent"
cachingMemory = "Caching Memory"
_ = "Data Flush Pages/sec"
_ = "Data Flushes/sec"
databaseNodeMemory = "Database Node Memory"
dynamicUpdateNoOperation = "Dynamic Update NoOperation"
_ = "Dynamic Update NoOperation/sec"
dynamicUpdateQueued = "Dynamic Update Queued"
_ = "Dynamic Update Received"
_ = "Dynamic Update Received/sec"
dynamicUpdateRejected = "Dynamic Update Rejected"
dynamicUpdateTimeOuts = "Dynamic Update TimeOuts"
dynamicUpdateWrittenToDatabase = "Dynamic Update Written to Database"
_ = "Dynamic Update Written to Database/sec"
_ = "Enumerations Server/sec"
_ = "Fast Read Not Possibles/sec"
_ = "Fast Read Resource Misses/sec"
ixfrRequestReceived = "IXFR Request Received"
ixfrRequestSent = "IXFR Request Sent"
ixfrResponseReceived = "IXFR Response Received"
_ = "IXFR Success Received"
ixfrSuccessSent = "IXFR Success Sent"
ixfrTCPSuccessReceived = "IXFR TCP Success Received"
ixfrUDPSuccessReceived = "IXFR UDP Success Received"
_ = "Lazy Write Flushes/sec"
_ = "Lazy Write Pages/sec"
_ = "Level 2 TLB Fills/sec"
nbStatMemory = "Nbstat Memory"
notifyReceived = "Notify Received"
notifySent = "Notify Sent"
_ = "Query Dropped Bad Socket"
_ = "Query Dropped Bad Socket/sec"
_ = "Query Dropped By Policy"
_ = "Query Dropped By Policy/sec"
_ = "Query Dropped By Response Rate Limiting"
_ = "Query Dropped By Response Rate Limiting/sec"
_ = "Query Dropped Send"
_ = "Query Dropped Send/sec"
_ = "Query Dropped Total"
_ = "Query Dropped Total/sec"
recordFlowMemory = "Record Flow Memory"
recursiveQueries = "Recursive Queries"
_ = "Recursive Queries/sec"
recursiveQueryFailure = "Recursive Query Failure"
_ = "Recursive Query Failure/sec"
_ = "Recursive Send TimeOuts"
recursiveSendTimeOuts = "Recursive TimeOut/sec"
_ = "Responses Suppressed"
_ = "Responses Suppressed/sec"
secureUpdateFailure = "Secure Update Failure"
secureUpdateReceived = "Secure Update Received"
_ = "Secure Update Received/sec"
tcpMessageMemory = "TCP Message Memory"
tcpQueryReceived = "TCP Query Received"
_ = "TCP Query Received/sec"
tcpResponseSent = "TCP Response Sent"
_ = "TCP Response Sent/sec"
_ = "Total Query Received"
_ = "Total Query Received/sec"
_ = "Total Remote Inflight Queries"
_ = "Total Response Sent"
_ = "Total Response Sent/sec"
udpMessageMemory = "UDP Message Memory"
udpQueryReceived = "UDP Query Received"
_ = "UDP Query Received/sec"
udpResponseSent = "UDP Response Sent"
_ = "UDP Response Sent/sec"
unmatchedResponsesReceived = "Unmatched Responses Received"
_ = "Virtual Bytes"
winsLookupReceived = "WINS Lookup Received"
_ = "WINS Lookup Received/sec"
winsResponseSent = "WINS Response Sent"
_ = "WINS Response Sent/sec"
winsReverseLookupReceived = "WINS Reverse Lookup Received"
_ = "WINS Reverse Lookup Received/sec"
winsReverseResponseSent = "WINS Reverse Response Sent"
_ = "WINS Reverse Response Sent/sec"
zoneTransferFailure = "Zone Transfer Failure"
zoneTransferSOARequestSent = "Zone Transfer Request Received"
_ = "Zone Transfer SOA Request Sent"
_ = "Zone Transfer Success"
)

View File

@@ -1,15 +1,27 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package dns
import (
"errors"
"fmt"
"log/slog"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
@@ -18,13 +30,15 @@ const Name = "dns"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_DNS_DNS metrics.
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
dynamicUpdatesFailures *prometheus.Desc
dynamicUpdatesQueued *prometheus.Desc
@@ -79,48 +93,7 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error
c.perfDataCollector, err = perfdata.NewCollector("DNS", perfdata.InstanceAll, []string{
axfrRequestReceived,
axfrRequestSent,
axfrResponseReceived,
axfrSuccessReceived,
axfrSuccessSent,
cachingMemory,
databaseNodeMemory,
dynamicUpdateNoOperation,
dynamicUpdateQueued,
dynamicUpdateRejected,
dynamicUpdateTimeOuts,
dynamicUpdateWrittenToDatabase,
ixfrRequestReceived,
ixfrRequestSent,
ixfrResponseReceived,
ixfrSuccessSent,
ixfrTCPSuccessReceived,
ixfrUDPSuccessReceived,
nbStatMemory,
notifyReceived,
notifySent,
recordFlowMemory,
recursiveQueries,
recursiveQueryFailure,
recursiveSendTimeOuts,
secureUpdateFailure,
secureUpdateReceived,
tcpMessageMemory,
tcpQueryReceived,
tcpResponseSent,
udpMessageMemory,
udpQueryReceived,
udpResponseSent,
unmatchedResponsesReceived,
winsLookupReceived,
winsResponseSent,
winsReverseLookupReceived,
winsReverseResponseSent,
zoneTransferFailure,
zoneTransferSOARequestSent,
})
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues]("DNS", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create DNS collector: %w", err)
}
@@ -264,79 +237,74 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollector.Collect()
err := c.perfDataCollector.Collect(&c.perfDataObject)
if err != nil {
return fmt.Errorf("failed to collect DNS metrics: %w", err)
}
data, ok := perfData[perfdata.EmptyInstance]
if !ok {
return errors.New("perflib query for DNS returned empty result set")
}
ch <- prometheus.MustNewConstMetric(
c.zoneTransferRequestsReceived,
prometheus.CounterValue,
data[axfrRequestReceived].FirstValue,
c.perfDataObject[0].AxfrRequestReceived,
"full",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferRequestsReceived,
prometheus.CounterValue,
data[ixfrRequestReceived].FirstValue,
c.perfDataObject[0].IxfrRequestReceived,
"incremental",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferRequestsSent,
prometheus.CounterValue,
data[axfrRequestSent].FirstValue,
c.perfDataObject[0].AxfrRequestSent,
"full",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferRequestsSent,
prometheus.CounterValue,
data[ixfrRequestSent].FirstValue,
c.perfDataObject[0].IxfrRequestSent,
"incremental",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferRequestsSent,
prometheus.CounterValue,
data[zoneTransferSOARequestSent].FirstValue,
c.perfDataObject[0].ZoneTransferSOARequestSent,
"soa",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferResponsesReceived,
prometheus.CounterValue,
data[axfrResponseReceived].FirstValue,
c.perfDataObject[0].AxfrResponseReceived,
"full",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferResponsesReceived,
prometheus.CounterValue,
data[ixfrResponseReceived].FirstValue,
c.perfDataObject[0].IxfrResponseReceived,
"incremental",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferSuccessReceived,
prometheus.CounterValue,
data[axfrSuccessReceived].FirstValue,
c.perfDataObject[0].AxfrSuccessReceived,
"full",
"tcp",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferSuccessReceived,
prometheus.CounterValue,
data[ixfrTCPSuccessReceived].FirstValue,
c.perfDataObject[0].IxfrTCPSuccessReceived,
"incremental",
"tcp",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferSuccessReceived,
prometheus.CounterValue,
data[ixfrTCPSuccessReceived].FirstValue,
c.perfDataObject[0].IxfrTCPSuccessReceived,
"incremental",
"udp",
)
@@ -344,183 +312,183 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(
c.zoneTransferSuccessSent,
prometheus.CounterValue,
data[axfrSuccessSent].FirstValue,
c.perfDataObject[0].AxfrSuccessSent,
"full",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferSuccessSent,
prometheus.CounterValue,
data[ixfrSuccessSent].FirstValue,
c.perfDataObject[0].IxfrSuccessSent,
"incremental",
)
ch <- prometheus.MustNewConstMetric(
c.zoneTransferFailures,
prometheus.CounterValue,
data[zoneTransferFailure].FirstValue,
c.perfDataObject[0].ZoneTransferFailure,
)
ch <- prometheus.MustNewConstMetric(
c.memoryUsedBytes,
prometheus.GaugeValue,
data[cachingMemory].FirstValue,
c.perfDataObject[0].CachingMemory,
"caching",
)
ch <- prometheus.MustNewConstMetric(
c.memoryUsedBytes,
prometheus.GaugeValue,
data[databaseNodeMemory].FirstValue,
c.perfDataObject[0].DatabaseNodeMemory,
"database_node",
)
ch <- prometheus.MustNewConstMetric(
c.memoryUsedBytes,
prometheus.GaugeValue,
data[nbStatMemory].FirstValue,
c.perfDataObject[0].NbStatMemory,
"nbstat",
)
ch <- prometheus.MustNewConstMetric(
c.memoryUsedBytes,
prometheus.GaugeValue,
data[recordFlowMemory].FirstValue,
c.perfDataObject[0].RecordFlowMemory,
"record_flow",
)
ch <- prometheus.MustNewConstMetric(
c.memoryUsedBytes,
prometheus.GaugeValue,
data[tcpMessageMemory].FirstValue,
c.perfDataObject[0].TcpMessageMemory,
"tcp_message",
)
ch <- prometheus.MustNewConstMetric(
c.memoryUsedBytes,
prometheus.GaugeValue,
data[udpMessageMemory].FirstValue,
c.perfDataObject[0].UdpMessageMemory,
"udp_message",
)
ch <- prometheus.MustNewConstMetric(
c.dynamicUpdatesReceived,
prometheus.CounterValue,
data[dynamicUpdateNoOperation].FirstValue,
c.perfDataObject[0].DynamicUpdateNoOperation,
"noop",
)
ch <- prometheus.MustNewConstMetric(
c.dynamicUpdatesReceived,
prometheus.CounterValue,
data[dynamicUpdateWrittenToDatabase].FirstValue,
c.perfDataObject[0].DynamicUpdateWrittenToDatabase,
"written",
)
ch <- prometheus.MustNewConstMetric(
c.dynamicUpdatesQueued,
prometheus.GaugeValue,
data[dynamicUpdateQueued].FirstValue,
c.perfDataObject[0].DynamicUpdateQueued,
)
ch <- prometheus.MustNewConstMetric(
c.dynamicUpdatesFailures,
prometheus.CounterValue,
data[dynamicUpdateRejected].FirstValue,
c.perfDataObject[0].DynamicUpdateRejected,
"rejected",
)
ch <- prometheus.MustNewConstMetric(
c.dynamicUpdatesFailures,
prometheus.CounterValue,
data[dynamicUpdateTimeOuts].FirstValue,
c.perfDataObject[0].DynamicUpdateTimeOuts,
"timeout",
)
ch <- prometheus.MustNewConstMetric(
c.notifyReceived,
prometheus.CounterValue,
data[notifyReceived].FirstValue,
c.perfDataObject[0].NotifyReceived,
)
ch <- prometheus.MustNewConstMetric(
c.notifySent,
prometheus.CounterValue,
data[notifySent].FirstValue,
c.perfDataObject[0].NotifySent,
)
ch <- prometheus.MustNewConstMetric(
c.recursiveQueries,
prometheus.CounterValue,
data[recursiveQueries].FirstValue,
c.perfDataObject[0].RecursiveQueries,
)
ch <- prometheus.MustNewConstMetric(
c.recursiveQueryFailures,
prometheus.CounterValue,
data[recursiveQueryFailure].FirstValue,
c.perfDataObject[0].RecursiveQueryFailure,
)
ch <- prometheus.MustNewConstMetric(
c.recursiveQuerySendTimeouts,
prometheus.CounterValue,
data[recursiveSendTimeOuts].FirstValue,
c.perfDataObject[0].RecursiveSendTimeOuts,
)
ch <- prometheus.MustNewConstMetric(
c.queries,
prometheus.CounterValue,
data[tcpQueryReceived].FirstValue,
c.perfDataObject[0].TcpQueryReceived,
"tcp",
)
ch <- prometheus.MustNewConstMetric(
c.queries,
prometheus.CounterValue,
data[udpQueryReceived].FirstValue,
c.perfDataObject[0].UdpQueryReceived,
"udp",
)
ch <- prometheus.MustNewConstMetric(
c.responses,
prometheus.CounterValue,
data[tcpResponseSent].FirstValue,
c.perfDataObject[0].TcpResponseSent,
"tcp",
)
ch <- prometheus.MustNewConstMetric(
c.responses,
prometheus.CounterValue,
data[udpResponseSent].FirstValue,
c.perfDataObject[0].UdpResponseSent,
"udp",
)
ch <- prometheus.MustNewConstMetric(
c.unmatchedResponsesReceived,
prometheus.CounterValue,
data[unmatchedResponsesReceived].FirstValue,
c.perfDataObject[0].UnmatchedResponsesReceived,
)
ch <- prometheus.MustNewConstMetric(
c.winsQueries,
prometheus.CounterValue,
data[winsLookupReceived].FirstValue,
c.perfDataObject[0].WinsLookupReceived,
"forward",
)
ch <- prometheus.MustNewConstMetric(
c.winsQueries,
prometheus.CounterValue,
data[winsReverseLookupReceived].FirstValue,
c.perfDataObject[0].WinsReverseLookupReceived,
"reverse",
)
ch <- prometheus.MustNewConstMetric(
c.winsResponses,
prometheus.CounterValue,
data[winsResponseSent].FirstValue,
c.perfDataObject[0].WinsResponseSent,
"forward",
)
ch <- prometheus.MustNewConstMetric(
c.winsResponses,
prometheus.CounterValue,
data[winsReverseResponseSent].FirstValue,
c.perfDataObject[0].WinsReverseResponseSent,
"reverse",
)
ch <- prometheus.MustNewConstMetric(
c.secureUpdateFailures,
prometheus.CounterValue,
data[secureUpdateFailure].FirstValue,
c.perfDataObject[0].SecureUpdateFailure,
)
ch <- prometheus.MustNewConstMetric(
c.secureUpdateReceived,
prometheus.CounterValue,
data[secureUpdateReceived].FirstValue,
c.perfDataObject[0].SecureUpdateReceived,
)
return nil

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package dns_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, dns.Name, dns.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, dns.New, nil)
}

View File

@@ -0,0 +1,107 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package dns
type perfDataCounterValues struct {
_ float64 `perfdata:"% User Time"`
_ float64 `perfdata:"176"`
_ float64 `perfdata:"Async Fast Reads/sec"`
AxfrRequestReceived float64 `perfdata:"AXFR Request Received"`
AxfrRequestSent float64 `perfdata:"AXFR Request Sent"`
AxfrResponseReceived float64 `perfdata:"AXFR Response Received"`
AxfrSuccessReceived float64 `perfdata:"AXFR Success Received"`
AxfrSuccessSent float64 `perfdata:"AXFR Success Sent"`
CachingMemory float64 `perfdata:"Caching Memory"`
_ float64 `perfdata:"Data Flush Pages/sec"`
_ float64 `perfdata:"Data Flushes/sec"`
DatabaseNodeMemory float64 `perfdata:"Database Node Memory"`
DynamicUpdateNoOperation float64 `perfdata:"Dynamic Update NoOperation"`
_ float64 `perfdata:"Dynamic Update NoOperation/sec"`
DynamicUpdateQueued float64 `perfdata:"Dynamic Update Queued"`
_ float64 `perfdata:"Dynamic Update Received"`
_ float64 `perfdata:"Dynamic Update Received/sec"`
DynamicUpdateRejected float64 `perfdata:"Dynamic Update Rejected"`
DynamicUpdateTimeOuts float64 `perfdata:"Dynamic Update TimeOuts"`
DynamicUpdateWrittenToDatabase float64 `perfdata:"Dynamic Update Written to Database"`
_ float64 `perfdata:"Dynamic Update Written to Database/sec"`
_ float64 `perfdata:"Enumerations Server/sec"`
_ float64 `perfdata:"Fast Read Not Possibles/sec"`
_ float64 `perfdata:"Fast Read Resource Misses/sec"`
IxfrRequestReceived float64 `perfdata:"IXFR Request Received"`
IxfrRequestSent float64 `perfdata:"IXFR Request Sent"`
IxfrResponseReceived float64 `perfdata:"IXFR Response Received"`
_ float64 `perfdata:"IXFR Success Received"`
IxfrSuccessSent float64 `perfdata:"IXFR Success Sent"`
IxfrTCPSuccessReceived float64 `perfdata:"IXFR TCP Success Received"`
IxfrUDPSuccessReceived float64 `perfdata:"IXFR UDP Success Received"`
_ float64 `perfdata:"Lazy Write Flushes/sec"`
_ float64 `perfdata:"Lazy Write Pages/sec"`
_ float64 `perfdata:"Level 2 TLB Fills/sec"`
NbStatMemory float64 `perfdata:"Nbstat Memory"`
NotifyReceived float64 `perfdata:"Notify Received"`
NotifySent float64 `perfdata:"Notify Sent"`
_ float64 `perfdata:"Query Dropped Bad Socket"`
_ float64 `perfdata:"Query Dropped Bad Socket/sec"`
_ float64 `perfdata:"Query Dropped By Policy"`
_ float64 `perfdata:"Query Dropped By Policy/sec"`
_ float64 `perfdata:"Query Dropped By Response Rate Limiting"`
_ float64 `perfdata:"Query Dropped By Response Rate Limiting/sec"`
_ float64 `perfdata:"Query Dropped Send"`
_ float64 `perfdata:"Query Dropped Send/sec"`
_ float64 `perfdata:"Query Dropped Total"`
_ float64 `perfdata:"Query Dropped Total/sec"`
RecordFlowMemory float64 `perfdata:"Record Flow Memory"`
RecursiveQueries float64 `perfdata:"Recursive Queries"`
_ float64 `perfdata:"Recursive Queries/sec"`
RecursiveQueryFailure float64 `perfdata:"Recursive Query Failure"`
_ float64 `perfdata:"Recursive Query Failure/sec"`
_ float64 `perfdata:"Recursive Send TimeOuts"`
RecursiveSendTimeOuts float64 `perfdata:"Recursive TimeOut/sec"`
_ float64 `perfdata:"Responses Suppressed"`
_ float64 `perfdata:"Responses Suppressed/sec"`
SecureUpdateFailure float64 `perfdata:"Secure Update Failure"`
SecureUpdateReceived float64 `perfdata:"Secure Update Received"`
_ float64 `perfdata:"Secure Update Received/sec"`
TcpMessageMemory float64 `perfdata:"TCP Message Memory"`
TcpQueryReceived float64 `perfdata:"TCP Query Received"`
_ float64 `perfdata:"TCP Query Received/sec"`
TcpResponseSent float64 `perfdata:"TCP Response Sent"`
_ float64 `perfdata:"TCP Response Sent/sec"`
_ float64 `perfdata:"Total Query Received"`
_ float64 `perfdata:"Total Query Received/sec"`
_ float64 `perfdata:"Total Remote Inflight Queries"`
_ float64 `perfdata:"Total Response Sent"`
_ float64 `perfdata:"Total Response Sent/sec"`
UdpMessageMemory float64 `perfdata:"UDP Message Memory"`
UdpQueryReceived float64 `perfdata:"UDP Query Received"`
_ float64 `perfdata:"UDP Query Received/sec"`
UdpResponseSent float64 `perfdata:"UDP Response Sent"`
_ float64 `perfdata:"UDP Response Sent/sec"`
UnmatchedResponsesReceived float64 `perfdata:"Unmatched Responses Received"`
_ float64 `perfdata:"Virtual Bytes"`
WinsLookupReceived float64 `perfdata:"WINS Lookup Received"`
_ float64 `perfdata:"WINS Lookup Received/sec"`
WinsResponseSent float64 `perfdata:"WINS Response Sent"`
_ float64 `perfdata:"WINS Response Sent/sec"`
WinsReverseLookupReceived float64 `perfdata:"WINS Reverse Lookup Received"`
_ float64 `perfdata:"WINS Reverse Lookup Received/sec"`
WinsReverseResponseSent float64 `perfdata:"WINS Reverse Response Sent"`
_ float64 `perfdata:"WINS Reverse Response Sent/sec"`
ZoneTransferFailure float64 `perfdata:"Zone Transfer Failure"`
ZoneTransferSOARequestSent float64 `perfdata:"Zone Transfer Request Received"`
_ float64 `perfdata:"Zone Transfer SOA Request Sent"`
_ float64 `perfdata:"Zone Transfer Success"`
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
@@ -8,100 +21,64 @@ import (
"log/slog"
"os"
"strings"
"sync"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
const Name = "exchange"
const (
adAccessProcesses = "ADAccessProcesses"
transportQueues = "TransportQueues"
httpProxy = "HttpProxy"
activeSync = "ActiveSync"
availabilityService = "AvailabilityService"
outlookWebAccess = "OutlookWebAccess"
autoDiscover = "Autodiscover"
workloadManagement = "WorkloadManagement"
rpcClientAccess = "RpcClientAccess"
mapiHttpEmsmdb = "MapiHttpEmsmdb"
subCollectorADAccessProcesses = "ADAccessProcesses"
subCollectorTransportQueues = "TransportQueues"
subCollectorHttpProxy = "HttpProxy"
subCollectorActiveSync = "ActiveSync"
subCollectorAvailabilityService = "AvailabilityService"
subCollectorOutlookWebAccess = "OutlookWebAccess"
subCollectorAutoDiscover = "Autodiscover"
subCollectorWorkloadManagement = "WorkloadManagement"
subCollectorRpcClientAccess = "RpcClientAccess"
subCollectorMapiHttpEmsmdb = "MapiHttpEmsmdb"
)
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
}
//nolint:gochecknoglobals
var ConfigDefaults = Config{
CollectorsEnabled: []string{
adAccessProcesses,
transportQueues,
httpProxy,
activeSync,
availabilityService,
outlookWebAccess,
autoDiscover,
workloadManagement,
rpcClientAccess,
mapiHttpEmsmdb,
subCollectorADAccessProcesses,
subCollectorTransportQueues,
subCollectorHttpProxy,
subCollectorActiveSync,
subCollectorAvailabilityService,
subCollectorOutlookWebAccess,
subCollectorAutoDiscover,
subCollectorWorkloadManagement,
subCollectorRpcClientAccess,
subCollectorMapiHttpEmsmdb,
},
}
type Collector struct {
config Config
perfDataCollectorADAccessProcesses *perfdata.Collector
perfDataCollectorTransportQueues *perfdata.Collector
perfDataCollectorHttpProxy *perfdata.Collector
perfDataCollectorActiveSync *perfdata.Collector
perfDataCollectorAvailabilityService *perfdata.Collector
perfDataCollectorOWA *perfdata.Collector
perfDataCollectorAutoDiscover *perfdata.Collector
perfDataCollectorWorkloadManagementWorkloads *perfdata.Collector
perfDataCollectorRpcClientAccess *perfdata.Collector
perfDataCollectorMapiHttpEmsmdb *perfdata.Collector
collectorFns []func(ch chan<- prometheus.Metric) error
closeFns []func()
activeMailboxDeliveryQueueLength *prometheus.Desc
activeSyncRequestsPerSec *prometheus.Desc
activeTasks *prometheus.Desc
activeUserCount *prometheus.Desc
activeUserCountMapiHttpEmsMDB *prometheus.Desc
autoDiscoverRequestsPerSec *prometheus.Desc
availabilityRequestsSec *prometheus.Desc
averageAuthenticationLatency *prometheus.Desc
averageCASProcessingLatency *prometheus.Desc
completedTasks *prometheus.Desc
connectionCount *prometheus.Desc
currentUniqueUsers *prometheus.Desc
externalActiveRemoteDeliveryQueueLength *prometheus.Desc
externalLargestDeliveryQueueLength *prometheus.Desc
internalActiveRemoteDeliveryQueueLength *prometheus.Desc
internalLargestDeliveryQueueLength *prometheus.Desc
isActive *prometheus.Desc
ldapReadTime *prometheus.Desc
ldapSearchTime *prometheus.Desc
ldapTimeoutErrorsPerSec *prometheus.Desc
ldapWriteTime *prometheus.Desc
longRunningLDAPOperationsPerMin *prometheus.Desc
mailboxServerLocatorAverageLatency *prometheus.Desc
mailboxServerProxyFailureRate *prometheus.Desc
outstandingProxyRequests *prometheus.Desc
owaRequestsPerSec *prometheus.Desc
pingCommandsPending *prometheus.Desc
poisonQueueLength *prometheus.Desc
proxyRequestsPerSec *prometheus.Desc
queuedTasks *prometheus.Desc
retryMailboxDeliveryQueueLength *prometheus.Desc
rpcAveragedLatency *prometheus.Desc
rpcOperationsPerSec *prometheus.Desc
rpcRequests *prometheus.Desc
syncCommandsPerSec *prometheus.Desc
unreachableQueueLength *prometheus.Desc
userCount *prometheus.Desc
yieldedTasks *prometheus.Desc
collectorADAccessProcesses
collectorActiveSync
collectorAutoDiscover
collectorAvailabilityService
collectorHTTPProxy
collectorMapiHttpEmsmdb
collectorOWA
collectorRpcClientAccess
collectorTransportQueues
collectorWorkloadManagementWorkloads
}
func New(config *Config) *Collector {
@@ -143,16 +120,16 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.PreAction(func(*kingpin.ParseContext) error {
if listAllCollectors {
collectorDesc := map[string]string{
adAccessProcesses: "[19108] MSExchange ADAccess Processes",
transportQueues: "[20524] MSExchangeTransport Queues",
httpProxy: "[36934] MSExchange HttpProxy",
activeSync: "[25138] MSExchange ActiveSync",
availabilityService: "[24914] MSExchange Availability Service",
outlookWebAccess: "[24618] MSExchange OWA",
autoDiscover: "[29240] MSExchange Autodiscover",
workloadManagement: "[19430] MSExchange WorkloadManagement Workloads",
rpcClientAccess: "[29336] MSExchange RpcClientAccess",
mapiHttpEmsmdb: "[26463] MSExchange MapiHttp Emsmdb",
subCollectorADAccessProcesses: "[19108] MSExchange ADAccess Processes",
subCollectorTransportQueues: "[20524] MSExchangeTransport Queues",
subCollectorHttpProxy: "[36934] MSExchange HttpProxy",
subCollectorActiveSync: "[25138] MSExchange ActiveSync",
subCollectorAvailabilityService: "[24914] MSExchange Availability Service",
subCollectorOutlookWebAccess: "[24618] MSExchange OWA",
subCollectorAutoDiscover: "[29240] MSExchange Autodiscover",
subCollectorWorkloadManagement: "[19430] MSExchange WorkloadManagement Workloads",
subCollectorRpcClientAccess: "[29336] MSExchange RpcClientAccess",
subCollectorMapiHttpEmsmdb: "[26463] MSExchange MapiHttp Emsmdb",
}
sb := strings.Builder{}
@@ -184,100 +161,116 @@ func (c *Collector) GetName() string {
}
func (c *Collector) Close() error {
for _, fn := range c.closeFns {
fn()
}
return nil
}
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
collectorFuncs := map[string]func() error{
adAccessProcesses: c.buildADAccessProcesses,
transportQueues: c.buildTransportQueues,
httpProxy: c.buildHTTPProxy,
activeSync: c.buildActiveSync,
availabilityService: c.buildAvailabilityService,
outlookWebAccess: c.buildOWA,
autoDiscover: c.buildAutoDiscover,
workloadManagement: c.buildWorkloadManagementWorkloads,
rpcClientAccess: c.buildRPC,
mapiHttpEmsmdb: c.buildMapiHttpEmsmdb,
subCollectors := map[string]struct {
build func() error
collect func(ch chan<- prometheus.Metric) error
close func()
}{
subCollectorADAccessProcesses: {
build: c.buildADAccessProcesses,
collect: c.collectADAccessProcesses,
close: c.perfDataCollectorADAccessProcesses.Close,
},
subCollectorTransportQueues: {
build: c.buildTransportQueues,
collect: c.collectTransportQueues,
close: c.perfDataCollectorTransportQueues.Close,
},
subCollectorHttpProxy: {
build: c.buildHTTPProxy,
collect: c.collectHTTPProxy,
close: c.perfDataCollectorHTTPProxy.Close,
},
subCollectorActiveSync: {
build: c.buildActiveSync,
collect: c.collectActiveSync,
close: c.perfDataCollectorActiveSync.Close,
},
subCollectorAvailabilityService: {
build: c.buildAvailabilityService,
collect: c.collectAvailabilityService,
close: c.perfDataCollectorAvailabilityService.Close,
},
subCollectorOutlookWebAccess: {
build: c.buildOWA,
collect: c.collectOWA,
close: c.perfDataCollectorOWA.Close,
},
subCollectorAutoDiscover: {
build: c.buildAutoDiscover,
collect: c.collectAutoDiscover,
close: c.perfDataCollectorAutoDiscover.Close,
},
subCollectorWorkloadManagement: {
build: c.buildWorkloadManagementWorkloads,
collect: c.collectWorkloadManagementWorkloads,
close: c.perfDataCollectorWorkloadManagementWorkloads.Close,
},
subCollectorRpcClientAccess: {
build: c.buildRpcClientAccess,
collect: c.collectRpcClientAccess,
close: c.perfDataCollectorRpcClientAccess.Close,
},
subCollectorMapiHttpEmsmdb: {
build: c.buildMapiHttpEmsmdb,
collect: c.collectMapiHttpEmsmdb,
close: c.perfDataCollectorMapiHttpEmsmdb.Close,
},
}
for _, collectorName := range c.config.CollectorsEnabled {
if err := collectorFuncs[collectorName](); err != nil {
return err
errs := make([]error, 0, len(c.config.CollectorsEnabled))
for _, name := range c.config.CollectorsEnabled {
if _, ok := subCollectors[name]; !ok {
return fmt.Errorf("unknown collector: %s", name)
}
if err := subCollectors[name].build(); err != nil {
errs = append(errs, fmt.Errorf("failed to build %s collector: %w", name, err))
continue
}
c.collectorFns = append(c.collectorFns, subCollectors[name].collect)
c.closeFns = append(c.closeFns, subCollectors[name].close)
}
// desc creates a new prometheus description
desc := func(metricName string, description string, labels ...string) *prometheus.Desc {
return prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, metricName),
description,
labels,
nil,
)
}
c.rpcAveragedLatency = desc("rpc_avg_latency_sec", "The latency (sec) averaged for the past 1024 packets")
c.rpcRequests = desc("rpc_requests", "Number of client requests currently being processed by the RPC Client Access service")
c.activeUserCount = desc("rpc_active_user_count", "Number of unique users that have shown some kind of activity in the last 2 minutes")
c.connectionCount = desc("rpc_connection_count", "Total number of client connections maintained")
c.rpcOperationsPerSec = desc("rpc_operations_total", "The rate at which RPC operations occur")
c.userCount = desc("rpc_user_count", "Number of users")
c.ldapReadTime = desc("ldap_read_time_sec", "Time (sec) to send an LDAP read request and receive a response", "name")
c.ldapSearchTime = desc("ldap_search_time_sec", "Time (sec) to send an LDAP search request and receive a response", "name")
c.ldapWriteTime = desc("ldap_write_time_sec", "Time (sec) to send an LDAP Add/Modify/Delete request and receive a response", "name")
c.ldapTimeoutErrorsPerSec = desc("ldap_timeout_errors_total", "Total number of LDAP timeout errors", "name")
c.longRunningLDAPOperationsPerMin = desc("ldap_long_running_ops_per_sec", "Long Running LDAP operations per second", "name")
c.externalActiveRemoteDeliveryQueueLength = desc("transport_queues_external_active_remote_delivery", "External Active Remote Delivery Queue length", "name")
c.internalActiveRemoteDeliveryQueueLength = desc("transport_queues_internal_active_remote_delivery", "Internal Active Remote Delivery Queue length", "name")
c.activeMailboxDeliveryQueueLength = desc("transport_queues_active_mailbox_delivery", "Active Mailbox Delivery Queue length", "name")
c.retryMailboxDeliveryQueueLength = desc("transport_queues_retry_mailbox_delivery", "Retry Mailbox Delivery Queue length", "name")
c.unreachableQueueLength = desc("transport_queues_unreachable", "Unreachable Queue length", "name")
c.externalLargestDeliveryQueueLength = desc("transport_queues_external_largest_delivery", "External Largest Delivery Queue length", "name")
c.internalLargestDeliveryQueueLength = desc("transport_queues_internal_largest_delivery", "Internal Largest Delivery Queue length", "name")
c.poisonQueueLength = desc("transport_queues_poison", "Poison Queue length", "name")
c.mailboxServerLocatorAverageLatency = desc("http_proxy_mailbox_server_locator_avg_latency_sec", "Average latency (sec) of MailboxServerLocator web service calls", "name")
c.averageAuthenticationLatency = desc("http_proxy_avg_auth_latency", "Average time spent authenticating CAS requests over the last 200 samples", "name")
c.outstandingProxyRequests = desc("http_proxy_outstanding_proxy_requests", "Number of concurrent outstanding proxy requests", "name")
c.proxyRequestsPerSec = desc("http_proxy_requests_total", "Number of proxy requests processed each second", "name")
c.availabilityRequestsSec = desc("avail_service_requests_per_sec", "Number of requests serviced per second")
c.currentUniqueUsers = desc("owa_current_unique_users", "Number of unique users currently logged on to Outlook Web App")
c.owaRequestsPerSec = desc("owa_requests_total", "Number of requests handled by Outlook Web App per second")
c.autoDiscoverRequestsPerSec = desc("autodiscover_requests_total", "Number of autodiscover service requests processed each second")
c.activeTasks = desc("workload_active_tasks", "Number of active tasks currently running in the background for workload management", "name")
c.completedTasks = desc("workload_completed_tasks", "Number of workload management tasks that have been completed", "name")
c.queuedTasks = desc("workload_queued_tasks", "Number of workload management tasks that are currently queued up waiting to be processed", "name")
c.yieldedTasks = desc("workload_yielded_tasks", "The total number of tasks that have been yielded by a workload", "name")
c.isActive = desc("workload_is_active", "Active indicates whether the workload is in an active (1) or paused (0) state", "name")
c.activeSyncRequestsPerSec = desc("activesync_requests_total", "Num HTTP requests received from the client via ASP.NET per sec. Shows Current user load")
c.averageCASProcessingLatency = desc("http_proxy_avg_cas_processing_latency_sec", "Average latency (sec) of CAS processing time over the last 200 reqs", "name")
c.mailboxServerProxyFailureRate = desc("http_proxy_mailbox_proxy_failure_rate", "% of failures between this CAS and MBX servers over the last 200 samples", "name")
c.pingCommandsPending = desc("activesync_ping_cmds_pending", "Number of ping commands currently pending in the queue")
c.syncCommandsPerSec = desc("activesync_sync_cmds_total", "Number of sync commands processed per second. Clients use this command to synchronize items within a folder")
c.activeUserCountMapiHttpEmsMDB = desc("mapihttp_emsmdb_active_user_count", "Number of unique outlook users that have shown some kind of activity in the last 2 minutes")
return nil
return errors.Join(errs...)
}
// Collect collects exchange metrics and sends them to prometheus.
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
collectorFuncs := map[string]func(ch chan<- prometheus.Metric) error{
adAccessProcesses: c.collectADAccessProcesses,
transportQueues: c.collectTransportQueues,
httpProxy: c.collectHTTPProxy,
activeSync: c.collectActiveSync,
availabilityService: c.collectAvailabilityService,
outlookWebAccess: c.collectOWA,
autoDiscover: c.collectAutoDiscover,
workloadManagement: c.collectWorkloadManagementWorkloads,
rpcClientAccess: c.collectRPC,
mapiHttpEmsmdb: c.collectMapiHttpEmsmdb,
errCh := make(chan error, len(c.collectorFns))
errs := make([]error, 0, len(c.collectorFns))
wg := sync.WaitGroup{}
for _, fn := range c.collectorFns {
wg.Add(1)
go func(fn func(ch chan<- prometheus.Metric) error) {
defer wg.Done()
if err := fn(ch); err != nil {
errCh <- err
}
}(fn)
}
errs := make([]error, len(c.config.CollectorsEnabled))
wg.Wait()
for i, collectorName := range c.config.CollectorsEnabled {
errs[i] = collectorFuncs[collectorName](ch)
close(errCh)
for err := range errCh {
errs = append(errs, err)
}
return errors.Join(errs...)
@@ -290,8 +283,3 @@ func (c *Collector) toLabelName(name string) string {
return s
}
// msToSec converts from ms to seconds.
func (c *Collector) msToSec(t float64) float64 {
return t / 1000
}

View File

@@ -1,63 +1,94 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
import (
"errors"
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
const (
requestsPerSec = "Requests/sec"
pingCommandsPending = "Ping Commands Pending"
syncCommandsPerSec = "Sync Commands/sec"
)
type collectorActiveSync struct {
perfDataCollectorActiveSync *pdh.Collector
perfDataObjectActiveSync []perfDataCounterValuesActiveSync
activeSyncRequestsPerSec *prometheus.Desc
pingCommandsPending *prometheus.Desc
syncCommandsPerSec *prometheus.Desc
}
type perfDataCounterValuesActiveSync struct {
RequestsPerSec float64 `perfdata:"Requests/sec"`
PingCommandsPending float64 `perfdata:"Ping Commands Pending"`
SyncCommandsPerSec float64 `perfdata:"Sync Commands/sec"`
}
func (c *Collector) buildActiveSync() error {
counters := []string{
requestsPerSec,
pingCommandsPending,
syncCommandsPerSec,
}
var err error
c.perfDataCollectorActiveSync, err = perfdata.NewCollector("MSExchange ActiveSync", perfdata.InstanceAll, counters)
c.perfDataCollectorActiveSync, err = pdh.NewCollector[perfDataCounterValuesActiveSync]("MSExchange ActiveSync", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange ActiveSync collector: %w", err)
}
c.pingCommandsPending = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "activesync_ping_cmds_pending"),
"Number of ping commands currently pending in the queue",
nil,
nil,
)
c.syncCommandsPerSec = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "activesync_sync_cmds_total"),
"Number of sync commands processed per second. Clients use this command to synchronize items within a folder",
nil,
nil,
)
c.activeSyncRequestsPerSec = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "activesync_requests_total"),
"Num HTTP requests received from the client via ASP.NET per sec. Shows Current user load",
nil,
nil,
)
return nil
}
func (c *Collector) collectActiveSync(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorActiveSync.Collect()
err := c.perfDataCollectorActiveSync.Collect(&c.perfDataObjectActiveSync)
if err != nil {
return fmt.Errorf("failed to collect MSExchange ActiveSync metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for MSExchange ActiveSync returned empty result set")
}
for _, data := range perfData {
for _, data := range c.perfDataObjectActiveSync {
ch <- prometheus.MustNewConstMetric(
c.activeSyncRequestsPerSec,
prometheus.CounterValue,
data[requestsPerSec].FirstValue,
data.RequestsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.pingCommandsPending,
prometheus.GaugeValue,
data[pingCommandsPending].FirstValue,
data.PingCommandsPending,
)
ch <- prometheus.MustNewConstMetric(
c.syncCommandsPerSec,
prometheus.CounterValue,
data[syncCommandsPerSec].FirstValue,
data.SyncCommandsPerSec,
)
}

View File

@@ -1,56 +1,102 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
import (
"errors"
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus/client_golang/prometheus"
)
const (
ldapReadTime = "LDAP Read Time"
ldapSearchTime = "LDAP Search Time"
ldapWriteTime = "LDAP Write Time"
ldapTimeoutErrorsPerSec = "LDAP Timeout Errors/sec"
longRunningLDAPOperationsPerMin = "Long Running LDAP Operations/min"
)
type collectorADAccessProcesses struct {
perfDataCollectorADAccessProcesses *pdh.Collector
perfDataObjectADAccessProcesses []perfDataCounterValuesADAccessProcesses
ldapReadTime *prometheus.Desc
ldapSearchTime *prometheus.Desc
ldapTimeoutErrorsPerSec *prometheus.Desc
ldapWriteTime *prometheus.Desc
longRunningLDAPOperationsPerMin *prometheus.Desc
}
type perfDataCounterValuesADAccessProcesses struct {
Name string
LdapReadTime float64 `perfdata:"LDAP Read Time"`
LdapSearchTime float64 `perfdata:"LDAP Search Time"`
LdapWriteTime float64 `perfdata:"LDAP Write Time"`
LdapTimeoutErrorsPerSec float64 `perfdata:"LDAP Timeout Errors/sec"`
LongRunningLDAPOperationsPerMin float64 `perfdata:"Long Running LDAP Operations/min"`
}
func (c *Collector) buildADAccessProcesses() error {
counters := []string{
ldapReadTime,
ldapSearchTime,
ldapWriteTime,
ldapTimeoutErrorsPerSec,
longRunningLDAPOperationsPerMin,
}
var err error
c.perfDataCollectorADAccessProcesses, err = perfdata.NewCollector("MSExchange ADAccess Processes", perfdata.InstanceAll, counters)
c.perfDataCollectorADAccessProcesses, err = pdh.NewCollector[perfDataCounterValuesADAccessProcesses]("MSExchange ADAccess Processes", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange ADAccess Processes collector: %w", err)
}
c.ldapReadTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "ldap_read_time_sec"),
"Time (sec) to send an LDAP read request and receive a response",
[]string{"name"},
nil,
)
c.ldapSearchTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "ldap_search_time_sec"),
"Time (sec) to send an LDAP search request and receive a response",
[]string{"name"},
nil,
)
c.ldapWriteTime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "ldap_write_time_sec"),
"Time (sec) to send an LDAP Add/Modify/Delete request and receive a response",
[]string{"name"},
nil,
)
c.ldapTimeoutErrorsPerSec = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "ldap_timeout_errors_total"),
"Total number of LDAP timeout errors",
[]string{"name"},
nil,
)
c.longRunningLDAPOperationsPerMin = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "ldap_long_running_ops_per_sec"),
"Long Running LDAP operations per second",
[]string{"name"},
nil,
)
return nil
}
func (c *Collector) collectADAccessProcesses(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorADAccessProcesses.Collect()
err := c.perfDataCollectorADAccessProcesses.Collect(&c.perfDataObjectADAccessProcesses)
if err != nil {
return fmt.Errorf("failed to collect MSExchange ADAccess Processes metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for MSExchange ADAccess Processes returned empty result set")
}
labelUseCount := make(map[string]int)
for name, data := range perfData {
labelName := c.toLabelName(name)
for _, data := range c.perfDataObjectADAccessProcesses {
labelName := c.toLabelName(data.Name)
// Since we're not including the PID suffix from the instance names in the label names, we get an occasional duplicate.
// This seems to affect about 4 instances only of this object.
@@ -62,31 +108,31 @@ func (c *Collector) collectADAccessProcesses(ch chan<- prometheus.Metric) error
ch <- prometheus.MustNewConstMetric(
c.ldapReadTime,
prometheus.CounterValue,
c.msToSec(data[ldapReadTime].FirstValue),
utils.MilliSecToSec(data.LdapReadTime),
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.ldapSearchTime,
prometheus.CounterValue,
c.msToSec(data[ldapSearchTime].FirstValue),
utils.MilliSecToSec(data.LdapSearchTime),
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.ldapWriteTime,
prometheus.CounterValue,
c.msToSec(data[ldapWriteTime].FirstValue),
utils.MilliSecToSec(data.LdapWriteTime),
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.ldapTimeoutErrorsPerSec,
prometheus.CounterValue,
data[ldapTimeoutErrorsPerSec].FirstValue,
data.LdapTimeoutErrorsPerSec,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.longRunningLDAPOperationsPerMin,
prometheus.CounterValue,
data[longRunningLDAPOperationsPerMin].FirstValue*60,
data.LongRunningLDAPOperationsPerMin*60,
labelName,
)
}

View File

@@ -1,45 +1,68 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
import (
"errors"
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
func (c *Collector) buildAutoDiscover() error {
counters := []string{
requestsPerSec,
}
type collectorAutoDiscover struct {
perfDataCollectorAutoDiscover *pdh.Collector
perfDataObjectAutoDiscover []perfDataCounterValuesAutoDiscover
autoDiscoverRequestsPerSec *prometheus.Desc
}
type perfDataCounterValuesAutoDiscover struct {
RequestsPerSec float64 `perfdata:"Requests/sec"`
}
func (c *Collector) buildAutoDiscover() error {
var err error
c.perfDataCollectorAutoDiscover, err = perfdata.NewCollector("MSExchange Autodiscover", perfdata.InstanceAll, counters)
c.perfDataCollectorAutoDiscover, err = pdh.NewCollector[perfDataCounterValuesAutoDiscover]("MSExchange Autodiscover", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange Autodiscover collector: %w", err)
}
c.autoDiscoverRequestsPerSec = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "autodiscover_requests_total"),
"Number of autodiscover service requests processed each second",
nil,
nil,
)
return nil
}
func (c *Collector) collectAutoDiscover(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorAutoDiscover.Collect()
err := c.perfDataCollectorAutoDiscover.Collect(&c.perfDataObjectAutoDiscover)
if err != nil {
return fmt.Errorf("failed to collect MSExchange Autodiscover metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for MSExchange Autodiscover returned empty result set")
}
for _, data := range perfData {
for _, data := range c.perfDataObjectAutoDiscover {
ch <- prometheus.MustNewConstMetric(
c.autoDiscoverRequestsPerSec,
prometheus.CounterValue,
data[requestsPerSec].FirstValue,
data.RequestsPerSec,
)
}

View File

@@ -1,43 +1,68 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
import (
"errors"
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
func (c *Collector) buildAvailabilityService() error {
counters := []string{}
type collectorAvailabilityService struct {
perfDataCollectorAvailabilityService *pdh.Collector
perfDataObjectAvailabilityService []perfDataCounterValuesAvailabilityService
availabilityRequestsSec *prometheus.Desc
}
type perfDataCounterValuesAvailabilityService struct {
RequestsPerSec float64 `perfdata:"Requests/sec"`
}
func (c *Collector) buildAvailabilityService() error {
var err error
c.perfDataCollectorAvailabilityService, err = perfdata.NewCollector("MSExchange Availability Service", perfdata.InstanceAll, counters)
c.perfDataCollectorAvailabilityService, err = pdh.NewCollector[perfDataCounterValuesAvailabilityService]("MSExchange Availability Service", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange Availability Service collector: %w", err)
}
c.availabilityRequestsSec = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "avail_service_requests_per_sec"),
"Number of requests serviced per second",
nil,
nil,
)
return nil
}
func (c *Collector) collectAvailabilityService(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorAvailabilityService.Collect()
err := c.perfDataCollectorAvailabilityService.Collect(&c.perfDataObjectAvailabilityService)
if err != nil {
return fmt.Errorf("failed to collect MSExchange Availability Service metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for MSExchange Availability Service returned empty result set")
}
for _, data := range perfData {
for _, data := range c.perfDataObjectAvailabilityService {
ch <- prometheus.MustNewConstMetric(
c.availabilityRequestsSec,
prometheus.CounterValue,
data[requestsPerSec].FirstValue,
data.RequestsPerSec,
)
}

View File

@@ -1,90 +1,142 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
import (
"errors"
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus/client_golang/prometheus"
)
const (
mailboxServerLocatorAverageLatency = "MailboxServerLocator Average Latency (Moving Average)"
averageAuthenticationLatency = "Average Authentication Latency"
averageCASProcessingLatency = "Average ClientAccess Server Processing Latency"
mailboxServerProxyFailureRate = "Mailbox Server Proxy Failure Rate"
outstandingProxyRequests = "Outstanding Proxy Requests"
proxyRequestsPerSec = "Proxy Requests/Sec"
)
type collectorHTTPProxy struct {
perfDataCollectorHTTPProxy *pdh.Collector
perfDataObjectHTTPProxy []perfDataCounterValuesHTTPProxy
mailboxServerLocatorAverageLatency *prometheus.Desc
averageAuthenticationLatency *prometheus.Desc
outstandingProxyRequests *prometheus.Desc
proxyRequestsPerSec *prometheus.Desc
averageCASProcessingLatency *prometheus.Desc
mailboxServerProxyFailureRate *prometheus.Desc
}
type perfDataCounterValuesHTTPProxy struct {
Name string
MailboxServerLocatorAverageLatency float64 `perfdata:"MailboxServerLocator Average Latency (Moving Average)"`
AverageAuthenticationLatency float64 `perfdata:"Average Authentication Latency"`
AverageCASProcessingLatency float64 `perfdata:"Average ClientAccess Server Processing Latency"`
MailboxServerProxyFailureRate float64 `perfdata:"Mailbox Server Proxy Failure Rate"`
OutstandingProxyRequests float64 `perfdata:"Outstanding Proxy Requests"`
ProxyRequestsPerSec float64 `perfdata:"Proxy Requests/Sec"`
}
func (c *Collector) buildHTTPProxy() error {
counters := []string{
mailboxServerLocatorAverageLatency,
averageAuthenticationLatency,
averageCASProcessingLatency,
mailboxServerProxyFailureRate,
outstandingProxyRequests,
proxyRequestsPerSec,
}
var err error
c.perfDataCollectorHttpProxy, err = perfdata.NewCollector("MSExchange HttpProxy", perfdata.InstanceAll, counters)
c.perfDataCollectorHTTPProxy, err = pdh.NewCollector[perfDataCounterValuesHTTPProxy]("MSExchange HttpProxy", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange HttpProxy collector: %w", err)
}
c.mailboxServerLocatorAverageLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "http_proxy_mailbox_server_locator_avg_latency_sec"),
"Average latency (sec) of MailboxServerLocator web service calls",
[]string{"name"},
nil,
)
c.averageAuthenticationLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "http_proxy_avg_auth_latency"),
"Average time spent authenticating CAS requests over the last 200 samples",
[]string{"name"},
nil,
)
c.outstandingProxyRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "http_proxy_outstanding_proxy_requests"),
"Number of concurrent outstanding proxy requests",
[]string{"name"},
nil,
)
c.proxyRequestsPerSec = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "http_proxy_requests_total"),
"Number of proxy requests processed each second",
[]string{"name"},
nil,
)
c.averageCASProcessingLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "http_proxy_avg_cas_processing_latency_sec"),
"Average latency (sec) of CAS processing time over the last 200 reqs",
[]string{"name"},
nil,
)
c.mailboxServerProxyFailureRate = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "http_proxy_mailbox_proxy_failure_rate"),
"% of failures between this CAS and MBX servers over the last 200 samples",
[]string{"name"},
nil,
)
return nil
}
func (c *Collector) collectHTTPProxy(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorHttpProxy.Collect()
err := c.perfDataCollectorHTTPProxy.Collect(&c.perfDataObjectHTTPProxy)
if err != nil {
return fmt.Errorf("failed to collect MSExchange HttpProxy Service metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for MSExchange HttpProxy Service returned empty result set")
}
for name, data := range perfData {
labelName := c.toLabelName(name)
for _, data := range c.perfDataObjectHTTPProxy {
labelName := c.toLabelName(data.Name)
ch <- prometheus.MustNewConstMetric(
c.mailboxServerLocatorAverageLatency,
prometheus.GaugeValue,
c.msToSec(data[mailboxServerLocatorAverageLatency].FirstValue),
utils.MilliSecToSec(data.MailboxServerLocatorAverageLatency),
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.averageAuthenticationLatency,
prometheus.GaugeValue,
data[averageAuthenticationLatency].FirstValue,
data.AverageAuthenticationLatency,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.averageCASProcessingLatency,
prometheus.GaugeValue,
c.msToSec(data[averageCASProcessingLatency].FirstValue),
utils.MilliSecToSec(data.AverageCASProcessingLatency),
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.mailboxServerProxyFailureRate,
prometheus.GaugeValue,
data[mailboxServerProxyFailureRate].FirstValue,
data.MailboxServerProxyFailureRate,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.outstandingProxyRequests,
prometheus.GaugeValue,
data[outstandingProxyRequests].FirstValue,
data.OutstandingProxyRequests,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.proxyRequestsPerSec,
prometheus.CounterValue,
data[proxyRequestsPerSec].FirstValue,
data.ProxyRequestsPerSec,
labelName,
)
}

View File

@@ -1,49 +1,68 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
import (
"errors"
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
const (
activeUserCount = "Active User Count"
)
type collectorMapiHttpEmsmdb struct {
perfDataCollectorMapiHttpEmsmdb *pdh.Collector
perfDataObjectMapiHttpEmsmdb []perfDataCounterValuesMapiHttpEmsmdb
activeUserCountMapiHttpEmsMDB *prometheus.Desc
}
type perfDataCounterValuesMapiHttpEmsmdb struct {
ActiveUserCount float64 `perfdata:"Active User Count"`
}
func (c *Collector) buildMapiHttpEmsmdb() error {
counters := []string{
activeUserCount,
}
var err error
c.perfDataCollectorMapiHttpEmsmdb, err = perfdata.NewCollector("MSExchange MapiHttp Emsmdb", perfdata.InstanceAll, counters)
c.perfDataCollectorMapiHttpEmsmdb, err = pdh.NewCollector[perfDataCounterValuesMapiHttpEmsmdb]("MSExchange MapiHttp Emsmdb", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange MapiHttp Emsmdb: %w", err)
}
c.activeUserCountMapiHttpEmsMDB = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "mapihttp_emsmdb_active_user_count"),
"Number of unique outlook users that have shown some kind of activity in the last 2 minutes",
nil,
nil,
)
return nil
}
func (c *Collector) collectMapiHttpEmsmdb(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorMapiHttpEmsmdb.Collect()
err := c.perfDataCollectorMapiHttpEmsmdb.Collect(&c.perfDataObjectMapiHttpEmsmdb)
if err != nil {
return fmt.Errorf("failed to collect MSExchange MapiHttp Emsmdb metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for MSExchange MapiHttp Emsmdb returned empty result set")
}
for _, data := range perfData {
for _, data := range c.perfDataObjectMapiHttpEmsmdb {
ch <- prometheus.MustNewConstMetric(
c.activeUserCountMapiHttpEmsMDB,
prometheus.GaugeValue,
data[activeUserCount].FirstValue,
data.ActiveUserCount,
)
}

View File

@@ -1,56 +1,81 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
import (
"errors"
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
const (
currentUniqueUsers = "Current Unique Users"
// requestsPerSec = "Requests/sec"
)
type collectorOWA struct {
perfDataCollectorOWA *pdh.Collector
perfDataObjectOWA []perfDataCounterValuesOWA
currentUniqueUsers *prometheus.Desc
owaRequestsPerSec *prometheus.Desc
}
type perfDataCounterValuesOWA struct {
CurrentUniqueUsers float64 `perfdata:"Current Unique Users"`
RequestsPerSec float64 `perfdata:"Requests/sec"`
}
func (c *Collector) buildOWA() error {
counters := []string{
currentUniqueUsers,
requestsPerSec,
}
var err error
c.perfDataCollectorOWA, err = perfdata.NewCollector("MSExchange OWA", perfdata.InstanceAll, counters)
c.perfDataCollectorOWA, err = pdh.NewCollector[perfDataCounterValuesOWA]("MSExchange OWA", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange OWA collector: %w", err)
}
c.currentUniqueUsers = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "owa_current_unique_users"),
"Number of unique users currently logged on to Outlook Web App",
nil,
nil,
)
c.owaRequestsPerSec = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "owa_requests_total"),
"Number of requests handled by Outlook Web App per second",
nil,
nil,
)
return nil
}
func (c *Collector) collectOWA(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorOWA.Collect()
err := c.perfDataCollectorOWA.Collect(&c.perfDataObjectOWA)
if err != nil {
return fmt.Errorf("failed to collect MSExchange OWA metrics: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for MSExchange OWA returned empty result set")
}
for _, data := range perfData {
for _, data := range c.perfDataObjectOWA {
ch <- prometheus.MustNewConstMetric(
c.currentUniqueUsers,
prometheus.GaugeValue,
data[currentUniqueUsers].FirstValue,
data.CurrentUniqueUsers,
)
ch <- prometheus.MustNewConstMetric(
c.owaRequestsPerSec,
prometheus.CounterValue,
data[requestsPerSec].FirstValue,
data.RequestsPerSec,
)
}

View File

@@ -1,84 +1,134 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
import (
"errors"
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus/client_golang/prometheus"
)
const (
rpcAveragedLatency = "RPC Averaged Latency"
rpcRequests = "RPC Requests"
// activeUserCount = "Active User Count"
connectionCount = "Connection Count"
rpcOperationsPerSec = "RPC Operations/sec"
userCount = "User Count"
)
type collectorRpcClientAccess struct {
perfDataCollectorRpcClientAccess *pdh.Collector
perfDataObjectRpcClientAccess []perfDataCounterValuesRpcClientAccess
func (c *Collector) buildRPC() error {
counters := []string{
rpcAveragedLatency,
rpcRequests,
activeUserCount,
connectionCount,
rpcOperationsPerSec,
userCount,
}
activeUserCount *prometheus.Desc
connectionCount *prometheus.Desc
rpcAveragedLatency *prometheus.Desc
rpcOperationsPerSec *prometheus.Desc
rpcRequests *prometheus.Desc
userCount *prometheus.Desc
}
type perfDataCounterValuesRpcClientAccess struct {
RpcAveragedLatency float64 `perfdata:"RPC Averaged Latency"`
RpcRequests float64 `perfdata:"RPC Requests"`
ActiveUserCount float64 `perfdata:"Active User Count"`
ConnectionCount float64 `perfdata:"Connection Count"`
RpcOperationsPerSec float64 `perfdata:"RPC Operations/sec"`
UserCount float64 `perfdata:"User Count"`
}
func (c *Collector) buildRpcClientAccess() error {
var err error
c.perfDataCollectorRpcClientAccess, err = perfdata.NewCollector("MSExchange RpcClientAccess", perfdata.InstanceAll, counters)
c.perfDataCollectorRpcClientAccess, err = pdh.NewCollector[perfDataCounterValuesRpcClientAccess]("MSExchange RpcClientAccess", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange RpcClientAccess collector: %w", err)
}
c.rpcAveragedLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "rpc_avg_latency_sec"),
"The latency (sec) averaged for the past 1024 packets",
nil,
nil,
)
c.rpcRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "rpc_requests"),
"Number of client requests currently being processed by the RPC Client Access service",
nil,
nil,
)
c.activeUserCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "rpc_active_user_count"),
"Number of unique users that have shown some kind of activity in the last 2 minutes",
nil,
nil,
)
c.connectionCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "rpc_connection_count"),
"Total number of client connections maintained",
nil,
nil,
)
c.rpcOperationsPerSec = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "rpc_operations_total"),
"The rate at which RPC operations occur",
nil,
nil,
)
c.userCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "rpc_user_count"),
"Number of users",
nil,
nil,
)
return nil
}
func (c *Collector) collectRPC(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorRpcClientAccess.Collect()
func (c *Collector) collectRpcClientAccess(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorRpcClientAccess.Collect(&c.perfDataObjectRpcClientAccess)
if err != nil {
return fmt.Errorf("failed to collect MSExchange RpcClientAccess: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for MSExchange RpcClientAccess returned empty result set")
}
for _, data := range perfData {
for _, data := range c.perfDataObjectRpcClientAccess {
ch <- prometheus.MustNewConstMetric(
c.rpcAveragedLatency,
prometheus.GaugeValue,
c.msToSec(data[rpcAveragedLatency].FirstValue),
utils.MilliSecToSec(data.RpcAveragedLatency),
)
ch <- prometheus.MustNewConstMetric(
c.rpcRequests,
prometheus.GaugeValue,
data[rpcRequests].FirstValue,
data.RpcRequests,
)
ch <- prometheus.MustNewConstMetric(
c.activeUserCount,
prometheus.GaugeValue,
data[activeUserCount].FirstValue,
data.ActiveUserCount,
)
ch <- prometheus.MustNewConstMetric(
c.connectionCount,
prometheus.GaugeValue,
data[connectionCount].FirstValue,
data.ConnectionCount,
)
ch <- prometheus.MustNewConstMetric(
c.rpcOperationsPerSec,
prometheus.CounterValue,
data[rpcOperationsPerSec].FirstValue,
data.RpcOperationsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.userCount,
prometheus.GaugeValue,
data[userCount].FirstValue,
data.UserCount,
)
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, exchange.Name, exchange.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, exchange.New, nil)
}

View File

@@ -1,107 +1,324 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
import (
"errors"
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
const (
externalActiveRemoteDeliveryQueueLength = "External Active Remote Delivery Queue Length"
internalActiveRemoteDeliveryQueueLength = "Internal Active Remote Delivery Queue Length"
activeMailboxDeliveryQueueLength = "Active Mailbox Delivery Queue Length"
retryMailboxDeliveryQueueLength = "Retry Mailbox Delivery Queue Length"
unreachableQueueLength = "Unreachable Queue Length"
externalLargestDeliveryQueueLength = "External Largest Delivery Queue Length"
internalLargestDeliveryQueueLength = "Internal Largest Delivery Queue Length"
poisonQueueLength = "Poison Queue Length"
)
type collectorTransportQueues struct {
perfDataCollectorTransportQueues *pdh.Collector
perfDataObjectTransportQueues []perfDataCounterValuesTransportQueues
activeMailboxDeliveryQueueLength *prometheus.Desc
externalActiveRemoteDeliveryQueueLength *prometheus.Desc
externalLargestDeliveryQueueLength *prometheus.Desc
internalActiveRemoteDeliveryQueueLength *prometheus.Desc
internalLargestDeliveryQueueLength *prometheus.Desc
poisonQueueLength *prometheus.Desc
retryMailboxDeliveryQueueLength *prometheus.Desc
unreachableQueueLength *prometheus.Desc
messagesQueuedForDeliveryTotal *prometheus.Desc
messagesSubmittedTotal *prometheus.Desc
messagesDelayedTotal *prometheus.Desc
messagesCompletedDeliveryTotal *prometheus.Desc
shadowQueueLength *prometheus.Desc
submissionQueueLength *prometheus.Desc
delayQueueLength *prometheus.Desc
itemsCompletedDeliveryTotal *prometheus.Desc
itemsQueuedForDeliveryExpiredTotal *prometheus.Desc
itemsQueuedForDeliveryTotal *prometheus.Desc
itemsResubmittedTotal *prometheus.Desc
}
type perfDataCounterValuesTransportQueues struct {
Name string
ExternalActiveRemoteDeliveryQueueLength float64 `perfdata:"External Active Remote Delivery Queue Length"`
InternalActiveRemoteDeliveryQueueLength float64 `perfdata:"Internal Active Remote Delivery Queue Length"`
ActiveMailboxDeliveryQueueLength float64 `perfdata:"Active Mailbox Delivery Queue Length"`
RetryMailboxDeliveryQueueLength float64 `perfdata:"Retry Mailbox Delivery Queue Length"`
UnreachableQueueLength float64 `perfdata:"Unreachable Queue Length"`
ExternalLargestDeliveryQueueLength float64 `perfdata:"External Largest Delivery Queue Length"`
InternalLargestDeliveryQueueLength float64 `perfdata:"Internal Largest Delivery Queue Length"`
PoisonQueueLength float64 `perfdata:"Poison Queue Length"`
MessagesQueuedForDeliveryTotal float64 `perfdata:"Messages Queued For Delivery Total"`
MessagesSubmittedTotal float64 `perfdata:"Messages Submitted Total"`
MessagesDelayedTotal float64 `perfdata:"Messages Delayed Total"`
MessagesCompletedDeliveryTotal float64 `perfdata:"Messages Completed Delivery Total"`
ShadowQueueLength float64 `perfdata:"Shadow Queue Length"`
SubmissionQueueLength float64 `perfdata:"Submission Queue Length"`
DelayQueueLength float64 `perfdata:"Delay Queue Length"`
ItemsCompletedDeliveryTotal float64 `perfdata:"Items Completed Delivery Total"`
ItemsQueuedForDeliveryExpiredTotal float64 `perfdata:"Items Queued For Delivery Expired Total"`
ItemsQueuedForDeliveryTotal float64 `perfdata:"Items Queued For Delivery Total"`
ItemsResubmittedTotal float64 `perfdata:"Items Resubmitted Total"`
}
func (c *Collector) buildTransportQueues() error {
counters := []string{
externalActiveRemoteDeliveryQueueLength,
internalActiveRemoteDeliveryQueueLength,
activeMailboxDeliveryQueueLength,
retryMailboxDeliveryQueueLength,
unreachableQueueLength,
externalLargestDeliveryQueueLength,
internalLargestDeliveryQueueLength,
poisonQueueLength,
}
var err error
c.perfDataCollectorTransportQueues, err = perfdata.NewCollector("MSExchangeTransport Queues", perfdata.InstanceAll, counters)
c.perfDataCollectorTransportQueues, err = pdh.NewCollector[perfDataCounterValuesTransportQueues]("MSExchangeTransport Queues", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchangeTransport Queues collector: %w", err)
}
c.externalActiveRemoteDeliveryQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_external_active_remote_delivery"),
"External Active Remote Delivery Queue length",
[]string{"name"},
nil,
)
c.internalActiveRemoteDeliveryQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_internal_active_remote_delivery"),
"Internal Active Remote Delivery Queue length",
[]string{"name"},
nil,
)
c.activeMailboxDeliveryQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_active_mailbox_delivery"),
"Active Mailbox Delivery Queue length",
[]string{"name"},
nil,
)
c.retryMailboxDeliveryQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_retry_mailbox_delivery"),
"Retry Mailbox Delivery Queue length",
[]string{"name"},
nil,
)
c.unreachableQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_unreachable"),
"Unreachable Queue length",
[]string{"name"},
nil,
)
c.externalLargestDeliveryQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_external_largest_delivery"),
"External Largest Delivery Queue length",
[]string{"name"},
nil,
)
c.internalLargestDeliveryQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_internal_largest_delivery"),
"Internal Largest Delivery Queue length",
[]string{"name"},
nil,
)
c.poisonQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_poison"),
"Poison Queue length",
[]string{"name"},
nil,
)
c.messagesQueuedForDeliveryTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_messages_queued_for_delivery_total"),
"Messages Queued For Delivery Total",
[]string{"name"},
nil,
)
c.messagesSubmittedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_messages_submitted_total"),
"Messages Submitted Total",
[]string{"name"},
nil,
)
c.messagesDelayedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_messages_delayed_total"),
"Messages Delayed Total",
[]string{"name"},
nil,
)
c.messagesCompletedDeliveryTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_messages_completed_delivery_total"),
"Messages Completed Delivery Total",
[]string{"name"},
nil,
)
c.shadowQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_shadow_queue_length"),
"Shadow Queue Length",
[]string{"name"},
nil,
)
c.submissionQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_submission_queue_length"),
"Submission Queue Length",
[]string{"name"},
nil,
)
c.delayQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_delay_queue_length"),
"Delay Queue Length",
[]string{"name"},
nil,
)
c.itemsCompletedDeliveryTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_items_completed_delivery_total"),
"Items Completed Delivery Total",
[]string{"name"},
nil,
)
c.itemsQueuedForDeliveryExpiredTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_items_queued_for_delivery_expired_total"),
"Items Queued For Delivery Expired Total",
[]string{"name"},
nil,
)
c.itemsQueuedForDeliveryTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_items_queued_for_delivery_total"),
"Items Queued For Delivery Total",
[]string{"name"},
nil,
)
c.itemsResubmittedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_items_resubmitted_total"),
"Items Resubmitted Total",
[]string{"name"},
nil,
)
return nil
}
func (c *Collector) collectTransportQueues(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorTransportQueues.Collect()
err := c.perfDataCollectorTransportQueues.Collect(&c.perfDataObjectTransportQueues)
if err != nil {
return fmt.Errorf("failed to collect MSExchangeTransport Queues: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for MSExchangeTransport Queues returned empty result set")
}
for name, data := range perfData {
labelName := c.toLabelName(name)
for _, data := range c.perfDataObjectTransportQueues {
labelName := c.toLabelName(data.Name)
ch <- prometheus.MustNewConstMetric(
c.externalActiveRemoteDeliveryQueueLength,
prometheus.GaugeValue,
data[externalActiveRemoteDeliveryQueueLength].FirstValue,
data.ExternalActiveRemoteDeliveryQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.internalActiveRemoteDeliveryQueueLength,
prometheus.GaugeValue,
data[internalActiveRemoteDeliveryQueueLength].FirstValue,
data.InternalActiveRemoteDeliveryQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.activeMailboxDeliveryQueueLength,
prometheus.GaugeValue,
data[activeMailboxDeliveryQueueLength].FirstValue,
data.ActiveMailboxDeliveryQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.retryMailboxDeliveryQueueLength,
prometheus.GaugeValue,
data[retryMailboxDeliveryQueueLength].FirstValue,
data.RetryMailboxDeliveryQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.unreachableQueueLength,
prometheus.GaugeValue,
data[unreachableQueueLength].FirstValue,
data.UnreachableQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.externalLargestDeliveryQueueLength,
prometheus.GaugeValue,
data[externalLargestDeliveryQueueLength].FirstValue,
data.ExternalLargestDeliveryQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.internalLargestDeliveryQueueLength,
prometheus.GaugeValue,
data[internalLargestDeliveryQueueLength].FirstValue,
data.InternalLargestDeliveryQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.poisonQueueLength,
prometheus.GaugeValue,
data[poisonQueueLength].FirstValue,
data.PoisonQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.messagesQueuedForDeliveryTotal,
prometheus.CounterValue,
data.MessagesQueuedForDeliveryTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.messagesSubmittedTotal,
prometheus.CounterValue,
data.MessagesSubmittedTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.messagesDelayedTotal,
prometheus.CounterValue,
data.MessagesDelayedTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.messagesCompletedDeliveryTotal,
prometheus.CounterValue,
data.MessagesCompletedDeliveryTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.shadowQueueLength,
prometheus.GaugeValue,
data.ShadowQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.submissionQueueLength,
prometheus.GaugeValue,
data.SubmissionQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.delayQueueLength,
prometheus.GaugeValue,
data.DelayQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.itemsCompletedDeliveryTotal,
prometheus.CounterValue,
data.ItemsCompletedDeliveryTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.itemsQueuedForDeliveryExpiredTotal,
prometheus.CounterValue,
data.ItemsQueuedForDeliveryExpiredTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.itemsQueuedForDeliveryTotal,
prometheus.CounterValue,
data.ItemsQueuedForDeliveryTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.itemsResubmittedTotal,
prometheus.CounterValue,
data.ItemsResubmittedTotal,
labelName,
)
}

View File

@@ -1,83 +1,128 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package exchange
import (
"errors"
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
const (
activeTasks = "ActiveTasks"
completedTasks = "CompletedTasks"
queuedTasks = "QueuedTasks"
yieldedTasks = "YieldedTasks"
isActive = "Active"
)
type collectorWorkloadManagementWorkloads struct {
perfDataCollectorWorkloadManagementWorkloads *pdh.Collector
perfDataObjectWorkloadManagementWorkloads []perfDataCounterValuesWorkloadManagementWorkloads
activeTasks *prometheus.Desc
isActive *prometheus.Desc
completedTasks *prometheus.Desc
queuedTasks *prometheus.Desc
yieldedTasks *prometheus.Desc
}
type perfDataCounterValuesWorkloadManagementWorkloads struct {
Name string
ActiveTasks float64 `perfdata:"ActiveTasks"`
CompletedTasks float64 `perfdata:"CompletedTasks"`
QueuedTasks float64 `perfdata:"QueuedTasks"`
YieldedTasks float64 `perfdata:"YieldedTasks"`
IsActive float64 `perfdata:"Active"`
}
func (c *Collector) buildWorkloadManagementWorkloads() error {
counters := []string{
activeTasks,
completedTasks,
queuedTasks,
yieldedTasks,
isActive,
}
var err error
c.perfDataCollectorWorkloadManagementWorkloads, err = perfdata.NewCollector("MSExchange WorkloadManagement Workloads", perfdata.InstanceAll, counters)
c.perfDataCollectorWorkloadManagementWorkloads, err = pdh.NewCollector[perfDataCounterValuesWorkloadManagementWorkloads]("MSExchange WorkloadManagement Workloads", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange WorkloadManagement Workloads collector: %w", err)
}
c.activeTasks = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "workload_active_tasks"),
"Number of active tasks currently running in the background for workload management",
[]string{"name"},
nil,
)
c.completedTasks = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "workload_completed_tasks"),
"Number of workload management tasks that have been completed",
[]string{"name"},
nil,
)
c.queuedTasks = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "workload_queued_tasks"),
"Number of workload management tasks that are currently queued up waiting to be processed",
[]string{"name"},
nil,
)
c.yieldedTasks = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "workload_yielded_tasks"),
"The total number of tasks that have been yielded by a workload",
[]string{"name"},
nil,
)
c.isActive = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "workload_is_active"),
"Active indicates whether the workload is in an active (1) or paused (0) state",
[]string{"name"},
nil,
)
return nil
}
func (c *Collector) collectWorkloadManagementWorkloads(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorWorkloadManagementWorkloads.Collect()
err := c.perfDataCollectorWorkloadManagementWorkloads.Collect(&c.perfDataObjectWorkloadManagementWorkloads)
if err != nil {
return fmt.Errorf("failed to collect MSExchange WorkloadManagement Workloads: %w", err)
}
if len(perfData) == 0 {
return errors.New("perflib query for MSExchange WorkloadManagement Workloads returned empty result set")
}
for name, data := range perfData {
labelName := c.toLabelName(name)
for _, data := range c.perfDataObjectWorkloadManagementWorkloads {
labelName := c.toLabelName(data.Name)
ch <- prometheus.MustNewConstMetric(
c.activeTasks,
prometheus.GaugeValue,
data[activeTasks].FirstValue,
data.ActiveTasks,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.completedTasks,
prometheus.CounterValue,
data[completedTasks].FirstValue,
data.CompletedTasks,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.queuedTasks,
prometheus.CounterValue,
data[queuedTasks].FirstValue,
data.QueuedTasks,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.yieldedTasks,
prometheus.CounterValue,
data[yieldedTasks].FirstValue,
data.YieldedTasks,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.isActive,
prometheus.GaugeValue,
data[isActive].FirstValue,
data.IsActive,
labelName,
)
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package filetime
@@ -23,6 +36,7 @@ type Config struct {
FilePatterns []string
}
//nolint:gochecknoglobals
var ConfigDefaults = Config{
FilePatterns: []string{},
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package filetime_test

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package fsrmquota
@@ -18,6 +31,7 @@ const Name = "fsrmquota"
type Config struct{}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
type Collector struct {
@@ -129,30 +143,32 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
nil,
)
var dst []msftFSRMQuota
if err := c.miSession.Query(&dst, mi.NamespaceRootWindowsFSRM, c.miQuery); err != nil {
return fmt.Errorf("WMI query failed: %w", err)
}
return nil
}
// MSFT_FSRMQuota docs:
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/fsrm/msft-fsrmquota
type MSFT_FSRMQuota struct {
Name string `mi:"Name"`
Path string `mi:"Path"`
PeakUsage uint64 `mi:"PeakUsage"`
Size uint64 `mi:"Size"`
Usage uint64 `mi:"Usage"`
Description string `mi:"Description"`
Template string `mi:"Template"`
// Threshold string `mi:"Threshold"`
Disabled bool `mi:"Disabled"`
MatchesTemplate bool `mi:"MatchesTemplate"`
SoftLimit bool `mi:"SoftLimit"`
type msftFSRMQuota struct {
Path string `mi:"Path"`
PeakUsage uint64 `mi:"PeakUsage"`
Size uint64 `mi:"Size"`
Usage uint64 `mi:"Usage"`
Description string `mi:"Description"`
Template string `mi:"Template"`
Disabled bool `mi:"Disabled"`
MatchesTemplate bool `mi:"MatchesTemplate"`
SoftLimit bool `mi:"SoftLimit"`
}
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
var dst []MSFT_FSRMQuota
var dst []msftFSRMQuota
if err := c.miSession.Query(&dst, mi.NamespaceRootWindowsFSRM, c.miQuery); err != nil {
return fmt.Errorf("WMI query failed: %w", err)
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package fsrmquota_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, fsrmquota.Name, fsrmquota.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, fsrmquota.New, nil)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,749 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorDataStore Hyper-V DataStore metrics
type collectorDataStore struct {
perfDataCollectorDataStore *pdh.Collector
perfDataObjectDataStore []perfDataCounterValuesDataStore
dataStoreFragmentationRatio *prometheus.Desc // \Hyper-V DataStore(*)\Fragmentation ratio
dataStoreSectorSize *prometheus.Desc // \Hyper-V DataStore(*)\Sector size
dataStoreDataAlignment *prometheus.Desc // \Hyper-V DataStore(*)\Data alignment
dataStoreCurrentReplayLogSize *prometheus.Desc // \Hyper-V DataStore(*)\Current replay logSize
dataStoreAvailableEntries *prometheus.Desc // \Hyper-V DataStore(*)\Number of available entries inside object tables
dataStoreEmptyEntries *prometheus.Desc // \Hyper-V DataStore(*)\Number of empty entries inside object tables
dataStoreFreeBytes *prometheus.Desc // \Hyper-V DataStore(*)\Number of free bytes inside key tables
dataStoreDataEnd *prometheus.Desc // \Hyper-V DataStore(*)\Data end
dataStoreFileObjects *prometheus.Desc // \Hyper-V DataStore(*)\Number of file objects
dataStoreObjectTables *prometheus.Desc // \Hyper-V DataStore(*)\Number of object tables
dataStoreKeyTables *prometheus.Desc // \Hyper-V DataStore(*)\Number of key tables
dataStoreFileDataSize *prometheus.Desc // \Hyper-V DataStore(*)\File data size in bytes
dataStoreTableDataSize *prometheus.Desc // \Hyper-V DataStore(*)\Table data size in bytes
dataStoreNamesSize *prometheus.Desc // \Hyper-V DataStore(*)\Names size in bytes
dataStoreNumberOfKeys *prometheus.Desc // \Hyper-V DataStore(*)\Number of keys
dataStoreReconnectLatencyMicro *prometheus.Desc // \Hyper-V DataStore(*)\Reconnect latency microseconds
dataStoreDisconnectCount *prometheus.Desc // \Hyper-V DataStore(*)\Disconnect count
dataStoreWriteToFileByteLatency *prometheus.Desc // \Hyper-V DataStore(*)\Write to file byte latency microseconds
dataStoreWriteToFileByteCount *prometheus.Desc // \Hyper-V DataStore(*)\Write to file byte count
dataStoreWriteToFileCount *prometheus.Desc // \Hyper-V DataStore(*)\Write to file count
dataStoreReadFromFileByteLatency *prometheus.Desc // \Hyper-V DataStore(*)\Read from file byte latency microseconds
dataStoreReadFromFileByteCount *prometheus.Desc // \Hyper-V DataStore(*)\Read from file byte count
dataStoreReadFromFileCount *prometheus.Desc // \Hyper-V DataStore(*)\Read from file count
dataStoreWriteToStorageByteLatency *prometheus.Desc // \Hyper-V DataStore(*)\Write to storage byte latency microseconds
dataStoreWriteToStorageByteCount *prometheus.Desc // \Hyper-V DataStore(*)\Write to storage byte count
dataStoreWriteToStorageCount *prometheus.Desc // \Hyper-V DataStore(*)\Write to storage count
dataStoreReadFromStorageByteLatency *prometheus.Desc // \Hyper-V DataStore(*)\Read from storage byte latency microseconds
dataStoreReadFromStorageByteCount *prometheus.Desc // \Hyper-V DataStore(*)\Read from storage byte count
dataStoreReadFromStorageCount *prometheus.Desc // \Hyper-V DataStore(*)\Read from storage count
dataStoreCommitByteLatency *prometheus.Desc // \Hyper-V DataStore(*)\Commit byte latency microseconds
dataStoreCommitByteCount *prometheus.Desc // \Hyper-V DataStore(*)\Commit byte count
dataStoreCommitCount *prometheus.Desc // \Hyper-V DataStore(*)\Commit count
dataStoreCacheUpdateOperationLatency *prometheus.Desc // \Hyper-V DataStore(*)\Cache update operation latency microseconds
dataStoreCacheUpdateOperationCount *prometheus.Desc // \Hyper-V DataStore(*)\Cache update operation count
dataStoreCommitOperationLatency *prometheus.Desc // \Hyper-V DataStore(*)\Commit operation latency microseconds
dataStoreCommitOperationCount *prometheus.Desc // \Hyper-V DataStore(*)\Commit operation count
dataStoreCompactOperationLatency *prometheus.Desc // \Hyper-V DataStore(*)\Compact operation latency microseconds
dataStoreCompactOperationCount *prometheus.Desc // \Hyper-V DataStore(*)\Compact operation count
dataStoreLoadFileOperationLatency *prometheus.Desc // \Hyper-V DataStore(*)\Load file operation latency microseconds
dataStoreLoadFileOperationCount *prometheus.Desc // \Hyper-V DataStore(*)\Load file operation count
dataStoreRemoveOperationLatency *prometheus.Desc // \Hyper-V DataStore(*)\Remove operation latency microseconds
dataStoreRemoveOperationCount *prometheus.Desc // \Hyper-V DataStore(*)\Remove operation count
dataStoreQuerySizeOperationLatency *prometheus.Desc // \Hyper-V DataStore(*)\Query size operation latency microseconds
dataStoreQuerySizeOperationCount *prometheus.Desc // \Hyper-V DataStore(*)\Query size operation count
dataStoreSetOperationLatencyMicro *prometheus.Desc // \Hyper-V DataStore(*)\Set operation latency microseconds
dataStoreSetOperationCount *prometheus.Desc // \Hyper-V DataStore(*)\Set operation count
}
type perfDataCounterValuesDataStore struct {
Name string
// Hyper-V DataStore metrics
DataStoreFragmentationRatio float64 `perfdata:"Fragmentation ratio"`
DataStoreSectorSize float64 `perfdata:"Sector size"`
DataStoreDataAlignment float64 `perfdata:"Data alignment"`
DataStoreCurrentReplayLogSize float64 `perfdata:"Current replay logSize"`
DataStoreAvailableEntries float64 `perfdata:"Number of available entries inside object tables"`
DataStoreEmptyEntries float64 `perfdata:"Number of empty entries inside object tables"`
DataStoreFreeBytes float64 `perfdata:"Number of free bytes inside key tables"`
DataStoreDataEnd float64 `perfdata:"Data end"`
DataStoreFileObjects float64 `perfdata:"Number of file objects"`
DataStoreObjectTables float64 `perfdata:"Number of object tables"`
DataStoreKeyTables float64 `perfdata:"Number of key tables"`
DataStoreFileDataSize float64 `perfdata:"File data size in bytes"`
DataStoreTableDataSize float64 `perfdata:"Table data size in bytes"`
DataStoreNamesSize float64 `perfdata:"Names size in bytes"`
DataStoreNumberOfKeys float64 `perfdata:"Number of keys"`
DataStoreReconnectLatencyMicro float64 `perfdata:"Reconnect latency microseconds"`
DataStoreDisconnectCount float64 `perfdata:"Disconnect count"`
DataStoreWriteToFileByteLatency float64 `perfdata:"Write to file byte latency microseconds"`
DataStoreWriteToFileByteCount float64 `perfdata:"Write to file byte count"`
DataStoreWriteToFileCount float64 `perfdata:"Write to file count"`
DataStoreReadFromFileByteLatency float64 `perfdata:"Read from file byte latency microseconds"`
DataStoreReadFromFileByteCount float64 `perfdata:"Read from file byte count"`
DataStoreReadFromFileCount float64 `perfdata:"Read from file count"`
DataStoreWriteToStorageByteLatency float64 `perfdata:"Write to storage byte latency microseconds"`
DataStoreWriteToStorageByteCount float64 `perfdata:"Write to storage byte count"`
DataStoreWriteToStorageCount float64 `perfdata:"Write to storage count"`
DataStoreReadFromStorageByteLatency float64 `perfdata:"Read from storage byte latency microseconds"`
DataStoreReadFromStorageByteCount float64 `perfdata:"Read from storage byte count"`
DataStoreReadFromStorageCount float64 `perfdata:"Read from storage count"`
DataStoreCommitByteLatency float64 `perfdata:"Commit byte latency microseconds"`
DataStoreCommitByteCount float64 `perfdata:"Commit byte count"`
DataStoreCommitCount float64 `perfdata:"Commit count"`
DataStoreCacheUpdateOperationLatency float64 `perfdata:"Cache update operation latency microseconds"`
DataStoreCacheUpdateOperationCount float64 `perfdata:"Cache update operation count"`
DataStoreCommitOperationLatency float64 `perfdata:"Commit operation latency microseconds"`
DataStoreCommitOperationCount float64 `perfdata:"Commit operation count"`
DataStoreCompactOperationLatency float64 `perfdata:"Compact operation latency microseconds"`
DataStoreCompactOperationCount float64 `perfdata:"Compact operation count"`
DataStoreLoadFileOperationLatency float64 `perfdata:"Load file operation latency microseconds"`
DataStoreLoadFileOperationCount float64 `perfdata:"Load file operation count"`
DataStoreRemoveOperationLatency float64 `perfdata:"Remove operation latency microseconds"`
DataStoreRemoveOperationCount float64 `perfdata:"Remove operation count"`
DataStoreQuerySizeOperationLatency float64 `perfdata:"Query size operation latency microseconds"`
DataStoreQuerySizeOperationCount float64 `perfdata:"Query size operation count"`
DataStoreSetOperationLatencyMicro float64 `perfdata:"Set operation latency microseconds"`
DataStoreSetOperationCount float64 `perfdata:"Set operation count"`
}
func (c *Collector) buildDataStore() error {
var err error
c.perfDataCollectorDataStore, err = pdh.NewCollector[perfDataCounterValuesDataStore]("Hyper-V DataStore", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V DataStore collector: %w", err)
}
c.dataStoreFragmentationRatio = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_fragmentation_ratio"),
"Represents the fragmentation ratio of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreSectorSize = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_sector_size_bytes"),
"Represents the sector size of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreDataAlignment = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_data_alignment_bytes"),
"Represents the data alignment of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCurrentReplayLogSize = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_current_replay_log_size_bytes"),
"Represents the current replay log size of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreAvailableEntries = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_available_entries"),
"Represents the number of available entries inside object tables.",
[]string{"datastore"},
nil,
)
c.dataStoreEmptyEntries = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_empty_entries"),
"Represents the number of empty entries inside object tables.",
[]string{"datastore"},
nil,
)
c.dataStoreFreeBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_free_bytes"),
"Represents the number of free bytes inside key tables.",
[]string{"datastore"},
nil,
)
c.dataStoreDataEnd = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_data_end_bytes"),
"Represents the data end of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreFileObjects = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_file_objects"),
"Represents the number of file objects in the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreObjectTables = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_object_tables"),
"Represents the number of object tables in the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreKeyTables = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_key_tables"),
"Represents the number of key tables in the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreFileDataSize = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_file_data_size_bytes"),
"Represents the file data size in bytes of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreTableDataSize = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_table_data_size_bytes"),
"Represents the table data size in bytes of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreNamesSize = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_names_size_bytes"),
"Represents the names size in bytes of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreNumberOfKeys = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_number_of_keys"),
"Represents the number of keys in the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreReconnectLatencyMicro = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_reconnect_latency_microseconds"),
"Represents the reconnect latency in microseconds of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreDisconnectCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_disconnect_count"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreWriteToFileByteCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_file_byte_count"),
"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"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreReadFromFileByteCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_file_byte_count"),
"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"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreWriteToStorageByteCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_write_to_storage_byte_count"),
"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"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreReadFromStorageByteCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_read_from_storage_byte_count"),
"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"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreCommitByteCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_byte_count"),
"Represents the commit byte count of the DataStore.",
[]string{"datastore"},
nil,
)
c.dataStoreCommitCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_count"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreCacheUpdateOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_cache_update_operation_count"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreCommitOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_commit_operation_count"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreCompactOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_compact_operation_count"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreLoadFileOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_load_file_operation_count"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreRemoveOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_remove_operation_count"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreQuerySizeOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_query_size_operation_count"),
"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.",
[]string{"datastore"},
nil,
)
c.dataStoreSetOperationCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "datastore_set_operation_count"),
"Represents the set operation count of the DataStore.",
[]string{"datastore"},
nil,
)
return nil
}
func (c *Collector) collectDataStore(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorDataStore.Collect(&c.perfDataObjectDataStore)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V DataStore metrics: %w", err)
}
for _, data := range c.perfDataObjectDataStore {
ch <- prometheus.MustNewConstMetric(
c.dataStoreFragmentationRatio,
prometheus.GaugeValue,
data.DataStoreFragmentationRatio,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreSectorSize,
prometheus.GaugeValue,
data.DataStoreSectorSize,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreDataAlignment,
prometheus.GaugeValue,
data.DataStoreDataAlignment,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCurrentReplayLogSize,
prometheus.GaugeValue,
data.DataStoreCurrentReplayLogSize,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreAvailableEntries,
prometheus.GaugeValue,
data.DataStoreAvailableEntries,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreEmptyEntries,
prometheus.GaugeValue,
data.DataStoreEmptyEntries,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreFreeBytes,
prometheus.GaugeValue,
data.DataStoreFreeBytes,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreDataEnd,
prometheus.GaugeValue,
data.DataStoreDataEnd,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreFileObjects,
prometheus.GaugeValue,
data.DataStoreFileObjects,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreObjectTables,
prometheus.GaugeValue,
data.DataStoreObjectTables,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreKeyTables,
prometheus.GaugeValue,
data.DataStoreKeyTables,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreFileDataSize,
prometheus.GaugeValue,
data.DataStoreFileDataSize,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreTableDataSize,
prometheus.GaugeValue,
data.DataStoreTableDataSize,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreNamesSize,
prometheus.GaugeValue,
data.DataStoreNamesSize,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreNumberOfKeys,
prometheus.GaugeValue,
data.DataStoreNumberOfKeys,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReconnectLatencyMicro,
prometheus.GaugeValue,
data.DataStoreReconnectLatencyMicro,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreDisconnectCount,
prometheus.CounterValue,
data.DataStoreDisconnectCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToFileByteLatency,
prometheus.GaugeValue,
data.DataStoreWriteToFileByteLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToFileByteCount,
prometheus.CounterValue,
data.DataStoreWriteToFileByteCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToFileCount,
prometheus.CounterValue,
data.DataStoreWriteToFileCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromFileByteLatency,
prometheus.GaugeValue,
data.DataStoreReadFromFileByteLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromFileByteCount,
prometheus.CounterValue,
data.DataStoreReadFromFileByteCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromFileCount,
prometheus.CounterValue,
data.DataStoreReadFromFileCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToStorageByteLatency,
prometheus.GaugeValue,
data.DataStoreWriteToStorageByteLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToStorageByteCount,
prometheus.CounterValue,
data.DataStoreWriteToStorageByteCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToStorageCount,
prometheus.CounterValue,
data.DataStoreWriteToStorageCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromStorageByteLatency,
prometheus.GaugeValue,
data.DataStoreReadFromStorageByteLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromStorageByteCount,
prometheus.CounterValue,
data.DataStoreReadFromStorageByteCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromStorageCount,
prometheus.CounterValue,
data.DataStoreReadFromStorageCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCommitByteLatency,
prometheus.GaugeValue,
data.DataStoreCommitByteLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCommitByteCount,
prometheus.CounterValue,
data.DataStoreCommitByteCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCommitCount,
prometheus.CounterValue,
data.DataStoreCommitCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCacheUpdateOperationLatency,
prometheus.GaugeValue,
data.DataStoreCacheUpdateOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCacheUpdateOperationCount,
prometheus.CounterValue,
data.DataStoreCacheUpdateOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCommitOperationLatency,
prometheus.GaugeValue,
data.DataStoreCommitOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCommitOperationCount,
prometheus.CounterValue,
data.DataStoreCommitOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCompactOperationLatency,
prometheus.GaugeValue,
data.DataStoreCompactOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCompactOperationCount,
prometheus.CounterValue,
data.DataStoreCompactOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreLoadFileOperationLatency,
prometheus.GaugeValue,
data.DataStoreLoadFileOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreLoadFileOperationCount,
prometheus.CounterValue,
data.DataStoreLoadFileOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreRemoveOperationLatency,
prometheus.GaugeValue,
data.DataStoreRemoveOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreRemoveOperationCount,
prometheus.CounterValue,
data.DataStoreRemoveOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreQuerySizeOperationLatency,
prometheus.GaugeValue,
data.DataStoreQuerySizeOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreQuerySizeOperationCount,
prometheus.CounterValue,
data.DataStoreQuerySizeOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreSetOperationLatencyMicro,
prometheus.GaugeValue,
data.DataStoreSetOperationLatencyMicro,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreSetOperationCount,
prometheus.CounterValue,
data.DataStoreSetOperationCount,
data.Name,
)
}
return nil
}

View File

@@ -0,0 +1,122 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus/client_golang/prometheus"
)
// collectorDynamicMemoryBalancer Hyper-V Dynamic Memory Balancer metrics
type collectorDynamicMemoryBalancer struct {
perfDataCollectorDynamicMemoryBalancer *pdh.Collector
perfDataObjectDynamicMemoryBalancer []perfDataCounterValuesDynamicMemoryBalancer
vmDynamicMemoryBalancerAvailableMemoryForBalancing *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\Available Memory For Balancing
vmDynamicMemoryBalancerSystemCurrentPressure *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\System Current Pressure
vmDynamicMemoryBalancerAvailableMemory *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\Available Memory
vmDynamicMemoryBalancerAveragePressure *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\Average Pressure
}
type perfDataCounterValuesDynamicMemoryBalancer struct {
Name string
// Hyper-V Dynamic Memory Balancer metrics
VmDynamicMemoryBalancerAvailableMemory float64 `perfdata:"Available Memory"`
VmDynamicMemoryBalancerAvailableMemoryForBalancing float64 `perfdata:"Available Memory For Balancing"`
VmDynamicMemoryBalancerAveragePressure float64 `perfdata:"Average Pressure"`
VmDynamicMemoryBalancerSystemCurrentPressure float64 `perfdata:"System Current Pressure"`
}
func (c *Collector) buildDynamicMemoryBalancer() error {
var err error
// https://learn.microsoft.com/en-us/archive/blogs/chrisavis/monitoring-dynamic-memory-in-windows-server-hyper-v-2012
c.perfDataCollectorDynamicMemoryBalancer, err = pdh.NewCollector[perfDataCounterValuesDynamicMemoryBalancer]("Hyper-V Dynamic Memory Balancer", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Virtual Machine Health Summary collector: %w", err)
}
c.vmDynamicMemoryBalancerAvailableMemory = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_balancer_available_memory_bytes"),
"Represents the amount of memory left on the node.",
[]string{"balancer"},
nil,
)
c.vmDynamicMemoryBalancerAvailableMemoryForBalancing = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_balancer_available_memory_for_balancing_bytes"),
"Represents the available memory for balancing purposes.",
[]string{"balancer"},
nil,
)
c.vmDynamicMemoryBalancerAveragePressure = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_balancer_average_pressure_ratio"),
"Represents the average system pressure on the balancer node among all balanced objects.",
[]string{"balancer"},
nil,
)
c.vmDynamicMemoryBalancerSystemCurrentPressure = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_balancer_system_current_pressure_ratio"),
"Represents the current pressure in the system.",
[]string{"balancer"},
nil,
)
return nil
}
func (c *Collector) collectDynamicMemoryBalancer(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorDynamicMemoryBalancer.Collect(&c.perfDataObjectDynamicMemoryBalancer)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Dynamic Memory Balancer metrics: %w", err)
}
for _, data := range c.perfDataObjectDynamicMemoryBalancer {
ch <- prometheus.MustNewConstMetric(
c.vmDynamicMemoryBalancerAvailableMemory,
prometheus.GaugeValue,
utils.MBToBytes(data.VmDynamicMemoryBalancerAvailableMemory),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmDynamicMemoryBalancerAvailableMemoryForBalancing,
prometheus.GaugeValue,
utils.MBToBytes(data.VmDynamicMemoryBalancerAvailableMemoryForBalancing),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmDynamicMemoryBalancerAveragePressure,
prometheus.GaugeValue,
utils.PercentageToRatio(data.VmDynamicMemoryBalancerAveragePressure),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmDynamicMemoryBalancerSystemCurrentPressure,
prometheus.GaugeValue,
utils.PercentageToRatio(data.VmDynamicMemoryBalancerSystemCurrentPressure),
data.Name,
)
}
return nil
}

View File

@@ -0,0 +1,211 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus/client_golang/prometheus"
)
// collectorDynamicMemoryVM Hyper-V Dynamic Memory VM metrics
type collectorDynamicMemoryVM struct {
perfDataCollectorDynamicMemoryVM *pdh.Collector
perfDataObjectDynamicMemoryVM []perfDataCounterValuesDynamicMemoryVM
vmMemoryAddedMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Added Memory
vmMemoryCurrentPressure *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Current Pressure
vmMemoryGuestVisiblePhysicalMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Guest Visible Physical Memory
vmMemoryMaximumPressure *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Maximum Pressure
vmMemoryMemoryAddOperations *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Memory Add Operations
vmMemoryMemoryRemoveOperations *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Memory Remove Operations
vmMemoryMinimumPressure *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Minimum Pressure
vmMemoryPhysicalMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Physical Memory
vmMemoryRemovedMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Removed Memory
vmMemoryGuestAvailableMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Guest Available Memory
}
type perfDataCounterValuesDynamicMemoryVM struct {
Name string
// Hyper-V Dynamic Memory VM metrics
VmMemoryAddedMemory float64 `perfdata:"Added Memory"`
VmMemoryCurrentPressure float64 `perfdata:"Current Pressure"`
VmMemoryGuestAvailableMemory float64 `perfdata:"Guest Available Memory"`
VmMemoryGuestVisiblePhysicalMemory float64 `perfdata:"Guest Visible Physical Memory"`
VmMemoryMaximumPressure float64 `perfdata:"Maximum Pressure"`
VmMemoryMemoryAddOperations float64 `perfdata:"Memory Add Operations"`
VmMemoryMemoryRemoveOperations float64 `perfdata:"Memory Remove Operations"`
VmMemoryMinimumPressure float64 `perfdata:"Minimum Pressure"`
VmMemoryPhysicalMemory float64 `perfdata:"Physical Memory"`
VmMemoryRemovedMemory float64 `perfdata:"Removed Memory"`
}
func (c *Collector) buildDynamicMemoryVM() error {
var err error
c.perfDataCollectorDynamicMemoryVM, err = pdh.NewCollector[perfDataCounterValuesDynamicMemoryVM]("Hyper-V Dynamic Memory VM", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Dynamic Memory VM collector: %w", err)
}
c.vmMemoryAddedMemory = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_vm_added_total"),
"Represents the cumulative amount of memory added to the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryCurrentPressure = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_vm_pressure_current_ratio"),
"Represents the current pressure in the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryGuestAvailableMemory = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_vm_guest_available_bytes"),
"Represents the current amount of available memory in the VM (reported by the VM).",
[]string{"vm"},
nil,
)
c.vmMemoryGuestVisiblePhysicalMemory = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_vm_guest_visible_physical_memory_bytes"),
"Represents the amount of memory visible in the VM.'",
[]string{"vm"},
nil,
)
c.vmMemoryMaximumPressure = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_vm_pressure_maximum_ratio"),
"Represents the maximum pressure band in the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryMemoryAddOperations = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_vm_add_operations_total"),
"Represents the total number of add operations for the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryMemoryRemoveOperations = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_vm_remove_operations_total"),
"Represents the total number of remove operations for the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryMinimumPressure = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_vm_pressure_minimum_ratio"),
"Represents the minimum pressure band in the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryPhysicalMemory = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_vm_physical_bytes"),
"Represents the current amount of memory in the VM.",
[]string{"vm"},
nil,
)
c.vmMemoryRemovedMemory = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "dynamic_memory_vm_removed_bytes_total"),
"Represents the cumulative amount of memory removed from the VM.",
[]string{"vm"},
nil,
)
return nil
}
func (c *Collector) collectDynamicMemoryVM(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorDynamicMemoryVM.Collect(&c.perfDataObjectDynamicMemoryVM)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Dynamic Memory VM metrics: %w", err)
}
for _, data := range c.perfDataObjectDynamicMemoryVM {
ch <- prometheus.MustNewConstMetric(
c.vmMemoryAddedMemory,
prometheus.CounterValue,
utils.MBToBytes(data.VmMemoryAddedMemory),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryCurrentPressure,
prometheus.GaugeValue,
utils.PercentageToRatio(data.VmMemoryCurrentPressure),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryGuestAvailableMemory,
prometheus.GaugeValue,
utils.MBToBytes(data.VmMemoryGuestAvailableMemory),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryGuestVisiblePhysicalMemory,
prometheus.GaugeValue,
utils.MBToBytes(data.VmMemoryGuestVisiblePhysicalMemory),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryMaximumPressure,
prometheus.GaugeValue,
utils.PercentageToRatio(data.VmMemoryMaximumPressure),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryMemoryAddOperations,
prometheus.CounterValue,
data.VmMemoryMemoryAddOperations,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryMemoryRemoveOperations,
prometheus.CounterValue,
data.VmMemoryMemoryRemoveOperations,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryMinimumPressure,
prometheus.GaugeValue,
utils.PercentageToRatio(data.VmMemoryMinimumPressure),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryPhysicalMemory,
prometheus.GaugeValue,
utils.MBToBytes(data.VmMemoryPhysicalMemory),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryRemovedMemory,
prometheus.CounterValue,
utils.MBToBytes(data.VmMemoryRemovedMemory),
data.Name,
)
}
return nil
}

View File

@@ -0,0 +1,133 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"strings"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorHypervisorLogicalProcessor Hyper-V Hypervisor Logical Processor metrics
type collectorHypervisorLogicalProcessor struct {
perfDataCollectorHypervisorLogicalProcessor *pdh.Collector
perfDataObjectHypervisorLogicalProcessor []perfDataCounterValuesHypervisorLogicalProcessor
// \Hyper-V Hypervisor Logical Processor(*)\% Guest Run Time
// \Hyper-V Hypervisor Logical Processor(*)\% Hypervisor Run Time
// \Hyper-V Hypervisor Logical Processor(*)\% Idle Time
hypervisorLogicalProcessorTimeTotal *prometheus.Desc
hypervisorLogicalProcessorTotalRunTimeTotal *prometheus.Desc // \Hyper-V Hypervisor Logical Processor(*)\% Total Run Time
hypervisorLogicalProcessorContextSwitches *prometheus.Desc // \Hyper-V Hypervisor Logical Processor(*)\Context Switches/sec
}
type perfDataCounterValuesHypervisorLogicalProcessor struct {
Name string
HypervisorLogicalProcessorGuestRunTimePercent float64 `perfdata:"% Guest Run Time"`
HypervisorLogicalProcessorHypervisorRunTimePercent float64 `perfdata:"% Hypervisor Run Time"`
HypervisorLogicalProcessorTotalRunTimePercent float64 `perfdata:"% Total Run Time"`
HypervisorLogicalProcessorIdleRunTimePercent float64 `perfdata:"% Idle Time"`
HypervisorLogicalProcessorContextSwitches float64 `perfdata:"Context Switches/sec"`
}
func (c *Collector) buildHypervisorLogicalProcessor() error {
var err error
c.perfDataCollectorHypervisorLogicalProcessor, err = pdh.NewCollector[perfDataCounterValuesHypervisorLogicalProcessor]("Hyper-V Hypervisor Logical Processor", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Hypervisor Logical Processor collector: %w", err)
}
c.hypervisorLogicalProcessorTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_logical_processor_time_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"),
"Time that processor spent",
[]string{"core"},
nil,
)
c.hypervisorLogicalProcessorContextSwitches = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_logical_processor_context_switches_total"),
"The rate of virtual processor context switches on the processor.",
[]string{"core"},
nil,
)
return nil
}
func (c *Collector) collectHypervisorLogicalProcessor(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorHypervisorLogicalProcessor.Collect(&c.perfDataObjectHypervisorLogicalProcessor)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Hypervisor Logical Processor metrics: %w", err)
}
for _, data := range c.perfDataObjectHypervisorLogicalProcessor {
// The name format is Hv LP <core id>
parts := strings.Split(data.Name, " ")
if len(parts) != 3 {
return fmt.Errorf("unexpected Hyper-V Hypervisor Logical Processor name format: %s", data.Name)
}
coreID := parts[2]
ch <- prometheus.MustNewConstMetric(
c.hypervisorLogicalProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorLogicalProcessorGuestRunTimePercent,
coreID, "guest",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorLogicalProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorLogicalProcessorHypervisorRunTimePercent,
coreID, "hypervisor",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorLogicalProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorLogicalProcessorIdleRunTimePercent,
coreID, "idle",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorLogicalProcessorTotalRunTimeTotal,
prometheus.CounterValue,
data.HypervisorLogicalProcessorTotalRunTimePercent,
coreID,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorLogicalProcessorContextSwitches,
prometheus.CounterValue,
data.HypervisorLogicalProcessorContextSwitches,
coreID,
)
}
return nil
}

View File

@@ -0,0 +1,338 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorHypervisorRootPartition Hyper-V Hypervisor Root Partition metrics
type collectorHypervisorRootPartition struct {
perfDataCollectorHypervisorRootPartition *pdh.Collector
perfDataObjectHypervisorRootPartition []perfDataCounterValuesHypervisorRootPartition
hypervisorRootPartitionAddressSpaces *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Address Spaces
hypervisorRootPartitionAttachedDevices *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Attached Devices
hypervisorRootPartitionDepositedPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Deposited Pages
hypervisorRootPartitionDeviceDMAErrors *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Device DMA Errors
hypervisorRootPartitionDeviceInterruptErrors *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Device Interrupt Errors
hypervisorRootPartitionDeviceInterruptMappings *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Device Interrupt Mappings
hypervisorRootPartitionDeviceInterruptThrottleEvents *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Device Interrupt Throttle Events
hypervisorRootPartitionGPAPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\GPA Pages
hypervisorRootPartitionGPASpaceModifications *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\GPA Space Modifications/sec
hypervisorRootPartitionIOTLBFlushCost *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\I/O TLB Flush Cost
hypervisorRootPartitionIOTLBFlushes *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\I/O TLB Flushes/sec
hypervisorRootPartitionRecommendedVirtualTLBSize *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Recommended Virtual TLB Size
hypervisorRootPartitionSkippedTimerTicks *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Skipped Timer Ticks
hypervisorRootPartition1GDevicePages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\1G device pages
hypervisorRootPartition1GGPAPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\1G GPA pages
hypervisorRootPartition2MDevicePages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\2M device pages
hypervisorRootPartition2MGPAPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\2M GPA pages
hypervisorRootPartition4KDevicePages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\4K device pages
hypervisorRootPartition4KGPAPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\4K GPA pages
hypervisorRootPartitionVirtualTLBFlushEntries *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Virtual TLB Flush Entries/sec
hypervisorRootPartitionVirtualTLBPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Virtual TLB Pages
}
type perfDataCounterValuesHypervisorRootPartition struct {
HypervisorRootPartitionAddressSpaces float64 `perfdata:"Address Spaces"`
HypervisorRootPartitionAttachedDevices float64 `perfdata:"Attached Devices"`
HypervisorRootPartitionDepositedPages float64 `perfdata:"Deposited Pages"`
HypervisorRootPartitionDeviceDMAErrors float64 `perfdata:"Device DMA Errors"`
HypervisorRootPartitionDeviceInterruptErrors float64 `perfdata:"Device Interrupt Errors"`
HypervisorRootPartitionDeviceInterruptMappings float64 `perfdata:"Device Interrupt Mappings"`
HypervisorRootPartitionDeviceInterruptThrottleEvents float64 `perfdata:"Device Interrupt Throttle Events"`
HypervisorRootPartitionGPAPages float64 `perfdata:"GPA Pages"`
HypervisorRootPartitionGPASpaceModifications float64 `perfdata:"GPA Space Modifications/sec"`
HypervisorRootPartitionIOTLBFlushCost float64 `perfdata:"I/O TLB Flush Cost"`
HypervisorRootPartitionIOTLBFlushes float64 `perfdata:"I/O TLB Flushes/sec"`
HypervisorRootPartitionRecommendedVirtualTLBSize float64 `perfdata:"Recommended Virtual TLB Size"`
HypervisorRootPartitionSkippedTimerTicks float64 `perfdata:"Skipped Timer Ticks"`
HypervisorRootPartition1GDevicePages float64 `perfdata:"1G device pages"`
HypervisorRootPartition1GGPAPages float64 `perfdata:"1G GPA pages"`
HypervisorRootPartition2MDevicePages float64 `perfdata:"2M device pages"`
HypervisorRootPartition2MGPAPages float64 `perfdata:"2M GPA pages"`
HypervisorRootPartition4KDevicePages float64 `perfdata:"4K device pages"`
HypervisorRootPartition4KGPAPages float64 `perfdata:"4K GPA pages"`
HypervisorRootPartitionVirtualTLBFlushEntries float64 `perfdata:"Virtual TLB Flush Entires/sec"`
HypervisorRootPartitionVirtualTLBPages float64 `perfdata:"Virtual TLB Pages"`
}
func (c *Collector) buildHypervisorRootPartition() error {
var err error
c.perfDataCollectorHypervisorRootPartition, err = pdh.NewCollector[perfDataCounterValuesHypervisorRootPartition]("Hyper-V Hypervisor Root Partition", []string{"Root"})
if err != nil {
return fmt.Errorf("failed to create Hyper-V Hypervisor Root Partition collector: %w", err)
}
c.hypervisorRootPartitionAddressSpaces = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_address_spaces"),
"The number of address spaces in the virtual TLB of the partition",
nil,
nil,
)
c.hypervisorRootPartitionAttachedDevices = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_attached_devices"),
"The number of devices attached to the partition",
nil,
nil,
)
c.hypervisorRootPartitionDepositedPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_deposited_pages"),
"The number of pages deposited into the partition",
nil,
nil,
)
c.hypervisorRootPartitionDeviceDMAErrors = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_device_dma_errors"),
"An indicator of illegal DMA requests generated by all devices assigned to the partition",
nil,
nil,
)
c.hypervisorRootPartitionDeviceInterruptErrors = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_device_interrupt_errors"),
"An indicator of illegal interrupt requests generated by all devices assigned to the partition",
nil,
nil,
)
c.hypervisorRootPartitionDeviceInterruptMappings = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_device_interrupt_mappings"),
"The number of device interrupt mappings used by the partition",
nil,
nil,
)
c.hypervisorRootPartitionDeviceInterruptThrottleEvents = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "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.hypervisorRootPartitionGPAPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "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.hypervisorRootPartitionGPASpaceModifications = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_gpa_space_modifications"),
"The rate of modifications to the GPA space of the partition",
nil,
nil,
)
c.hypervisorRootPartitionIOTLBFlushCost = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_io_tlb_flush_cost"),
"The average time (in nanoseconds) spent processing an I/O TLB flush",
nil,
nil,
)
c.hypervisorRootPartitionIOTLBFlushes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_io_tlb_flush"),
"The rate of flushes of I/O TLBs of the partition",
nil,
nil,
)
c.hypervisorRootPartitionRecommendedVirtualTLBSize = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_recommended_virtual_tlb_size"),
"The recommended number of pages to be deposited for the virtual TLB",
nil,
nil,
)
c.hypervisorRootPartitionSkippedTimerTicks = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_physical_pages_allocated"),
"The number of timer interrupts skipped for the partition",
nil,
nil,
)
c.hypervisorRootPartition1GDevicePages = prometheus.NewDesc(
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"),
"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"),
"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"),
"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"),
"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"),
"The number of 4K pages present in the GPA space of the partition",
nil,
nil,
)
c.hypervisorRootPartitionVirtualTLBFlushEntries = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_virtual_tlb_flush_entries"),
"The rate of flushes of the entire virtual TLB",
nil,
nil,
)
c.hypervisorRootPartitionVirtualTLBPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "root_partition_virtual_tlb_pages"),
"The number of pages used by the virtual TLB of the partition",
nil,
nil,
)
return nil
}
func (c *Collector) collectHypervisorRootPartition(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorHypervisorRootPartition.Collect(&c.perfDataObjectHypervisorRootPartition)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Hypervisor Root Partition metrics: %w", err)
}
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionAddressSpaces,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionAddressSpaces,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionAttachedDevices,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionAttachedDevices,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionDepositedPages,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDepositedPages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionDeviceDMAErrors,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDeviceDMAErrors,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionDeviceInterruptErrors,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDeviceInterruptErrors,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionDeviceInterruptThrottleEvents,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDeviceInterruptThrottleEvents,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionGPAPages,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionGPAPages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionGPASpaceModifications,
prometheus.CounterValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionGPASpaceModifications,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionIOTLBFlushCost,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionIOTLBFlushCost,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionIOTLBFlushes,
prometheus.CounterValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionIOTLBFlushes,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionRecommendedVirtualTLBSize,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionRecommendedVirtualTLBSize,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionSkippedTimerTicks,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionSkippedTimerTicks,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition1GDevicePages,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition1GDevicePages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition1GGPAPages,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition1GGPAPages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition2MDevicePages,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MDevicePages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition2MGPAPages,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MGPAPages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition4KDevicePages,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KDevicePages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition4KGPAPages,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KGPAPages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionVirtualTLBFlushEntries,
prometheus.CounterValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionVirtualTLBFlushEntries,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionVirtualTLBPages,
prometheus.GaugeValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionVirtualTLBPages,
)
return nil
}

View File

@@ -0,0 +1,135 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"strings"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorHypervisorRootVirtualProcessor Hyper-V Hypervisor Root Virtual Processor metrics
type collectorHypervisorRootVirtualProcessor struct {
perfDataCollectorHypervisorRootVirtualProcessor *pdh.Collector
perfDataObjectHypervisorRootVirtualProcessor []perfDataCounterValuesHypervisorRootVirtualProcessor
// \Hyper-V Hypervisor Root Virtual Processor(*)\% Guest Run Time
// \Hyper-V Hypervisor Root Virtual Processor(*)\% Hypervisor Run Time
// \Hyper-V Hypervisor Root Virtual Processor(*)\% Remote Run Time
// \Hyper-V Hypervisor Root Virtual Processor(*)\% Total Run Time
hypervisorRootVirtualProcessorTimeTotal *prometheus.Desc
hypervisorRootVirtualProcessorTotalRunTimeTotal *prometheus.Desc
hypervisorRootVirtualProcessorCPUWaitTimePerDispatch *prometheus.Desc // \Hyper-V Hypervisor Root Virtual Processor(*)\CPU Wait Time Per Dispatch
}
type perfDataCounterValuesHypervisorRootVirtualProcessor struct {
Name string
HypervisorRootVirtualProcessorGuestRunTimePercent float64 `perfdata:"% Guest Run Time"`
HypervisorRootVirtualProcessorHypervisorRunTimePercent float64 `perfdata:"% Hypervisor Run Time"`
HypervisorRootVirtualProcessorTotalRunTimePercent float64 `perfdata:"% Total Run Time"`
HypervisorRootVirtualProcessorRemoteRunTimePercent float64 `perfdata:"% Remote Run Time"`
HypervisorRootVirtualProcessorCPUWaitTimePerDispatch float64 `perfdata:"CPU Wait Time Per Dispatch"`
}
func (c *Collector) buildHypervisorRootVirtualProcessor() error {
var err error
c.perfDataCollectorHypervisorRootVirtualProcessor, err = pdh.NewCollector[perfDataCounterValuesHypervisorRootVirtualProcessor]("Hyper-V Hypervisor Root Virtual Processor", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Hypervisor Root Virtual Processor collector: %w", err)
}
c.hypervisorRootVirtualProcessorTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_root_virtual_processor_time_total"),
"Time that processor spent in different modes (hypervisor, guest_run, guest_idle, remote)",
[]string{"core", "state"},
nil,
)
c.hypervisorRootVirtualProcessorTotalRunTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_root_virtual_processor_total_run_time_total"),
"Time that processor spent",
[]string{"core"},
nil,
)
c.hypervisorRootVirtualProcessorCPUWaitTimePerDispatch = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_root_virtual_cpu_wait_time_per_dispatch_total"),
"The average time (in nanoseconds) spent waiting for a virtual processor to be dispatched onto a logical processor.",
[]string{"core"},
nil,
)
return nil
}
func (c *Collector) collectHypervisorRootVirtualProcessor(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorHypervisorRootVirtualProcessor.Collect(&c.perfDataObjectHypervisorRootVirtualProcessor)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Hypervisor Root Virtual Processor metrics: %w", err)
}
for _, data := range c.perfDataObjectHypervisorRootVirtualProcessor {
// The name format is Hv LP <core id>
parts := strings.Split(data.Name, " ")
if len(parts) != 3 {
return fmt.Errorf("unexpected Hyper-V Hypervisor Root Virtual Processor name format: %s", data.Name)
}
coreID := parts[2]
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorRootVirtualProcessorGuestRunTimePercent,
coreID, "guest_run",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorRootVirtualProcessorHypervisorRunTimePercent,
coreID, "hypervisor",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorRootVirtualProcessorRemoteRunTimePercent,
coreID, "remote",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorTotalRunTimeTotal,
prometheus.CounterValue,
data.HypervisorRootVirtualProcessorTotalRunTimePercent,
coreID,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorCPUWaitTimePerDispatch,
prometheus.CounterValue,
data.HypervisorRootVirtualProcessorCPUWaitTimePerDispatch,
coreID,
)
}
return nil
}

View File

@@ -0,0 +1,138 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"strings"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorHypervisorVirtualProcessor Hyper-V Hypervisor Virtual Processor metrics
type collectorHypervisorVirtualProcessor struct {
perfDataCollectorHypervisorVirtualProcessor *pdh.Collector
perfDataObjectHypervisorVirtualProcessor []perfDataCounterValuesHypervisorVirtualProcessor
// \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
hypervisorVirtualProcessorTotalRunTimeTotal *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\% Total Run Time
hypervisorVirtualProcessorContextSwitches *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\CPU Wait Time Per Dispatch
}
type perfDataCounterValuesHypervisorVirtualProcessor struct {
Name string
HypervisorVirtualProcessorGuestIdleTimePercent float64 `perfdata:"% Guest Idle Time"`
HypervisorVirtualProcessorHypervisorRunTimePercent float64 `perfdata:"% Hypervisor Run Time"`
HypervisorVirtualProcessorTotalRunTimePercent float64 `perfdata:"% Total Run Time"`
HypervisorVirtualProcessorRemoteRunTimePercent float64 `perfdata:"% Remote Run Time"`
HypervisorVirtualProcessorCPUWaitTimePerDispatch float64 `perfdata:"CPU Wait Time Per Dispatch"`
}
func (c *Collector) buildHypervisorVirtualProcessor() error {
var err error
c.perfDataCollectorHypervisorVirtualProcessor, err = pdh.NewCollector[perfDataCounterValuesHypervisorVirtualProcessor]("Hyper-V Hypervisor Virtual Processor", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Hypervisor Virtual Processor collector: %w", err)
}
c.hypervisorVirtualProcessorTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_time_total"),
"Time that processor spent in different modes (hypervisor, guest_run, guest_idle, remote)",
[]string{"vm", "core", "state"},
nil,
)
c.hypervisorVirtualProcessorTotalRunTimeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "hypervisor_virtual_processor_total_run_time_total"),
"Time that processor spent",
[]string{"vm", "core"},
nil,
)
c.hypervisorVirtualProcessorContextSwitches = prometheus.NewDesc(
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.",
[]string{"vm", "core"},
nil,
)
return nil
}
func (c *Collector) collectHypervisorVirtualProcessor(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorHypervisorVirtualProcessor.Collect(&c.perfDataObjectHypervisorVirtualProcessor)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Hypervisor Virtual Processor metrics: %w", err)
}
for _, data := range c.perfDataObjectHypervisorVirtualProcessor {
// The name format is <VM Name>:Hv VP <vcore id>
parts := strings.Split(data.Name, ":")
if len(parts) != 2 {
return fmt.Errorf("unexpected format of Name in Hyper-V Hypervisor Virtual Processor: %q, expected %q", data.Name, "<VM Name>:Hv VP <vcore id>")
}
coreParts := strings.Split(parts[1], " ")
if len(coreParts) != 3 {
return fmt.Errorf("unexpected format of core identifier in Hyper-V Hypervisor Virtual Processor: %q, expected %q", parts[1], "Hv VP <vcore id>")
}
vmName := parts[0]
coreID := coreParts[2]
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorHypervisorRunTimePercent,
vmName, coreID, "hypervisor",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorGuestIdleTimePercent,
vmName, coreID, "guest_idle",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorGuestIdleTimePercent,
vmName, coreID, "guest_idle",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorTotalRunTimeTotal,
prometheus.CounterValue,
data.HypervisorVirtualProcessorTotalRunTimePercent,
vmName, coreID,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorContextSwitches,
prometheus.CounterValue,
data.HypervisorVirtualProcessorCPUWaitTimePerDispatch,
vmName, coreID,
)
}
return nil
}

View File

@@ -0,0 +1,149 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorLegacyNetworkAdapter Hyper-V Legacy Network Adapter metrics
type collectorLegacyNetworkAdapter struct {
perfDataCollectorLegacyNetworkAdapter *pdh.Collector
perfDataObjectLegacyNetworkAdapter []perfDataCounterValuesLegacyNetworkAdapter
legacyNetworkAdapterBytesDropped *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Bytes Dropped
legacyNetworkAdapterBytesReceived *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Bytes Received/sec
legacyNetworkAdapterBytesSent *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Bytes Sent/sec
legacyNetworkAdapterFramesDropped *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Frames Dropped
legacyNetworkAdapterFramesReceived *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Frames Received/sec
legacyNetworkAdapterFramesSent *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Frames Sent/sec
}
type perfDataCounterValuesLegacyNetworkAdapter struct {
Name string
LegacyNetworkAdapterBytesDropped float64 `perfdata:"Bytes Dropped"`
LegacyNetworkAdapterBytesReceived float64 `perfdata:"Bytes Received/sec"`
LegacyNetworkAdapterBytesSent float64 `perfdata:"Bytes Sent/sec"`
LegacyNetworkAdapterFramesDropped float64 `perfdata:"Frames Dropped"`
LegacyNetworkAdapterFramesReceived float64 `perfdata:"Frames Received/sec"`
LegacyNetworkAdapterFramesSent float64 `perfdata:"Frames Sent/sec"`
}
func (c *Collector) buildLegacyNetworkAdapter() error {
var err error
c.perfDataCollectorLegacyNetworkAdapter, err = pdh.NewCollector[perfDataCounterValuesLegacyNetworkAdapter]("Hyper-V Legacy Network Adapter", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Legacy Network Adapter collector: %w", err)
}
c.legacyNetworkAdapterBytesDropped = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "legacy_network_adapter_bytes_dropped_total"),
"Bytes Dropped is the number of bytes dropped on the network adapter",
[]string{"adapter"},
nil,
)
c.legacyNetworkAdapterBytesReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "legacy_network_adapter_bytes_received_total"),
"Bytes received is the number of bytes received on the network adapter",
[]string{"adapter"},
nil,
)
c.legacyNetworkAdapterBytesSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "legacy_network_adapter_bytes_sent_total"),
"Bytes sent is the number of bytes sent over the network adapter",
[]string{"adapter"},
nil,
)
c.legacyNetworkAdapterFramesDropped = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "legacy_network_adapter_frames_dropped_total"),
"Frames Dropped is the number of frames dropped on the network adapter",
[]string{"adapter"},
nil,
)
c.legacyNetworkAdapterFramesReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "legacy_network_adapter_frames_received_total"),
"Frames received is the number of frames received on the network adapter",
[]string{"adapter"},
nil,
)
c.legacyNetworkAdapterFramesSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "legacy_network_adapter_frames_sent_total"),
"Frames sent is the number of frames sent over the network adapter",
[]string{"adapter"},
nil,
)
return nil
}
func (c *Collector) collectLegacyNetworkAdapter(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorLegacyNetworkAdapter.Collect(&c.perfDataObjectLegacyNetworkAdapter)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Legacy Network Adapter metrics: %w", err)
}
for _, data := range c.perfDataObjectLegacyNetworkAdapter {
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterBytesDropped,
prometheus.GaugeValue,
data.LegacyNetworkAdapterBytesDropped,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterBytesReceived,
prometheus.CounterValue,
data.LegacyNetworkAdapterBytesReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterBytesSent,
prometheus.CounterValue,
data.LegacyNetworkAdapterBytesSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterFramesReceived,
prometheus.CounterValue,
data.LegacyNetworkAdapterFramesReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterFramesDropped,
prometheus.CounterValue,
data.LegacyNetworkAdapterFramesDropped,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterFramesSent,
prometheus.CounterValue,
data.LegacyNetworkAdapterFramesSent,
data.Name,
)
}
return nil
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, hyperv.Name, hyperv.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, hyperv.New, nil)
}

View File

@@ -0,0 +1,81 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorVirtualMachineHealthSummary Hyper-V Virtual Machine Health Summary metrics
type collectorVirtualMachineHealthSummary struct {
perfDataCollectorVirtualMachineHealthSummary *pdh.Collector
perfDataObjectVirtualMachineHealthSummary []perfDataCounterValuesVirtualMachineHealthSummary
// \Hyper-V Virtual Machine Health Summary\Health Critical
// \Hyper-V Virtual Machine Health Summary\Health Ok
health *prometheus.Desc
}
type perfDataCounterValuesVirtualMachineHealthSummary struct {
// Hyper-V Virtual Machine Health Summary
HealthCritical float64 `perfdata:"Health Critical"`
HealthOk float64 `perfdata:"Health Ok"`
}
func (c *Collector) buildVirtualMachineHealthSummary() error {
var err error
c.perfDataCollectorVirtualMachineHealthSummary, err = pdh.NewCollector[perfDataCounterValuesVirtualMachineHealthSummary]("Hyper-V Virtual Machine Health Summary", nil)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Virtual Machine Health Summary collector: %w", err)
}
c.health = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_machine_health_total_count"),
"Represents the number of virtual machines with critical health",
[]string{"state"},
nil,
)
return nil
}
func (c *Collector) collectVirtualMachineHealthSummary(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorVirtualMachineHealthSummary.Collect(&c.perfDataObjectVirtualMachineHealthSummary)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Virtual Machine Health Summary metrics: %w", err)
}
ch <- prometheus.MustNewConstMetric(
c.health,
prometheus.GaugeValue,
c.perfDataObjectVirtualMachineHealthSummary[0].HealthCritical,
"critical",
)
ch <- prometheus.MustNewConstMetric(
c.health,
prometheus.GaugeValue,
c.perfDataObjectVirtualMachineHealthSummary[0].HealthOk,
"ok",
)
return nil
}

View File

@@ -0,0 +1,104 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorVirtualMachineVidPartition Hyper-V VM Vid Partition metrics
type collectorVirtualMachineVidPartition struct {
perfDataCollectorVirtualMachineVidPartition *pdh.Collector
perfDataObjectVirtualMachineVidPartition []perfDataCounterValuesVirtualMachineVidPartition
physicalPagesAllocated *prometheus.Desc // \Hyper-V VM Vid Partition(*)\Physical Pages Allocated
preferredNUMANodeIndex *prometheus.Desc // \Hyper-V VM Vid Partition(*)\Preferred NUMA Node Index
remotePhysicalPages *prometheus.Desc // \Hyper-V VM Vid Partition(*)\Remote Physical Pages
}
type perfDataCounterValuesVirtualMachineVidPartition struct {
Name string
PhysicalPagesAllocated float64 `perfdata:"Physical Pages Allocated"`
PreferredNUMANodeIndex float64 `perfdata:"Preferred NUMA Node Index"`
RemotePhysicalPages float64 `perfdata:"Remote Physical Pages"`
}
func (c *Collector) buildVirtualMachineVidPartition() error {
var err error
c.perfDataCollectorVirtualMachineVidPartition, err = pdh.NewCollector[perfDataCounterValuesVirtualMachineVidPartition]("Hyper-V VM Vid Partition", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V VM Vid Partition collector: %w", err)
}
c.physicalPagesAllocated = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vid_physical_pages_allocated"),
"The number of physical pages allocated",
[]string{"vm"},
nil,
)
c.preferredNUMANodeIndex = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "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, Name, "vid_remote_physical_pages"),
"The number of physical pages not allocated from the preferred NUMA node",
[]string{"vm"},
nil,
)
return nil
}
func (c *Collector) collectVirtualMachineVidPartition(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorVirtualMachineVidPartition.Collect(&c.perfDataObjectVirtualMachineVidPartition)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V VM Vid Partition metrics: %w", err)
}
for _, data := range c.perfDataObjectVirtualMachineVidPartition {
ch <- prometheus.MustNewConstMetric(
c.physicalPagesAllocated,
prometheus.GaugeValue,
data.PhysicalPagesAllocated,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.preferredNUMANodeIndex,
prometheus.GaugeValue,
data.PreferredNUMANodeIndex,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.remotePhysicalPages,
prometheus.GaugeValue,
data.RemotePhysicalPages,
data.Name,
)
}
return nil
}

View File

@@ -0,0 +1,149 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorVirtualNetworkAdapter Hyper-V Virtual Network Adapter metrics
type collectorVirtualNetworkAdapter struct {
perfDataCollectorVirtualNetworkAdapter *pdh.Collector
perfDataObjectVirtualNetworkAdapter []perfDataCounterValuesVirtualNetworkAdapter
virtualNetworkAdapterBytesReceived *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Bytes Received/sec
virtualNetworkAdapterBytesSent *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Bytes Sent/sec
virtualNetworkAdapterDroppedPacketsIncoming *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Dropped Packets Incoming/sec
virtualNetworkAdapterDroppedPacketsOutgoing *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Dropped Packets Outgoing/sec
virtualNetworkAdapterPacketsReceived *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Packets Received/sec
virtualNetworkAdapterPacketsSent *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Packets Sent/sec
}
type perfDataCounterValuesVirtualNetworkAdapter struct {
Name string
VirtualNetworkAdapterBytesReceived float64 `perfdata:"Bytes Received/sec"`
VirtualNetworkAdapterBytesSent float64 `perfdata:"Bytes Sent/sec"`
VirtualNetworkAdapterDroppedPacketsIncoming float64 `perfdata:"Dropped Packets Incoming/sec"`
VirtualNetworkAdapterDroppedPacketsOutgoing float64 `perfdata:"Dropped Packets Outgoing/sec"`
VirtualNetworkAdapterPacketsReceived float64 `perfdata:"Packets Received/sec"`
VirtualNetworkAdapterPacketsSent float64 `perfdata:"Packets Sent/sec"`
}
func (c *Collector) buildVirtualNetworkAdapter() error {
var err error
c.perfDataCollectorVirtualNetworkAdapter, err = pdh.NewCollector[perfDataCounterValuesVirtualNetworkAdapter]("Hyper-V Virtual Network Adapter", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Virtual Network Adapter collector: %w", err)
}
c.virtualNetworkAdapterBytesReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_network_adapter_received_bytes_total"),
"Represents the total number of bytes received per second by the network adapter",
[]string{"adapter"},
nil,
)
c.virtualNetworkAdapterBytesSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_network_adapter_sent_bytes_total"),
"Represents the total number of bytes sent per second by the network adapter",
[]string{"adapter"},
nil,
)
c.virtualNetworkAdapterDroppedPacketsIncoming = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_network_adapter_incoming_dropped_packets_total"),
"Represents the total number of dropped packets per second in the incoming direction of the network adapter",
[]string{"adapter"},
nil,
)
c.virtualNetworkAdapterDroppedPacketsOutgoing = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_network_adapter_outgoing_dropped_packets_total"),
"Represents the total number of dropped packets per second in the outgoing direction of the network adapter",
[]string{"adapter"},
nil,
)
c.virtualNetworkAdapterPacketsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_network_adapter_received_packets_total"),
"Represents the total number of packets received per second by the network adapter",
[]string{"adapter"},
nil,
)
c.virtualNetworkAdapterPacketsSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_network_adapter_sent_packets_total"),
"Represents the total number of packets sent per second by the network adapter",
[]string{"adapter"},
nil,
)
return nil
}
func (c *Collector) collectVirtualNetworkAdapter(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorVirtualNetworkAdapter.Collect(&c.perfDataObjectVirtualNetworkAdapter)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Virtual Network Adapter metrics: %w", err)
}
for _, data := range c.perfDataObjectVirtualNetworkAdapter {
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterBytesReceived,
prometheus.CounterValue,
data.VirtualNetworkAdapterBytesReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterBytesSent,
prometheus.CounterValue,
data.VirtualNetworkAdapterBytesSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDroppedPacketsIncoming,
prometheus.CounterValue,
data.VirtualNetworkAdapterDroppedPacketsIncoming,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDroppedPacketsOutgoing,
prometheus.CounterValue,
data.VirtualNetworkAdapterDroppedPacketsOutgoing,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterPacketsReceived,
prometheus.CounterValue,
data.VirtualNetworkAdapterPacketsReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterPacketsSent,
prometheus.CounterValue,
data.VirtualNetworkAdapterPacketsSent,
data.Name,
)
}
return nil
}

View File

@@ -0,0 +1,493 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorVirtualNetworkAdapterDropReasons Hyper-V Virtual Network Adapter Drop Reasons metrics
type collectorVirtualNetworkAdapterDropReasons struct {
perfDataCollectorVirtualNetworkAdapterDropReasons *pdh.Collector
perfDataObjectVirtualNetworkAdapterDropReasons []perfDataCounterValuesVirtualNetworkAdapterDropReasons
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing LowPowerPacketFilter
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming LowPowerPacketFilter
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing InvalidPDQueue
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming InvalidPDQueue
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing FilteredIsolationUntagged
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming FilteredIsolationUntagged
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing SwitchDataFlowDisabled
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming SwitchDataFlowDisabled
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing FailedPacketFilter
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming FailedPacketFilter
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing NicDisabled
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming NicDisabled
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing FailedDestinationListUpdate
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming FailedDestinationListUpdate
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing InjectedIcmp
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming InjectedIcmp
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing StormLimit
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming StormLimit
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing InvalidFirstNBTooSmall
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming InvalidFirstNBTooSmall
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing InvalidSourceMac
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming InvalidSourceMac
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing InvalidDestMac
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming InvalidDestMac
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing InvalidVlanFormat
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming InvalidVlanFormat
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing NativeFwdingReq
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming NativeFwdingReq
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing MTUMismatch
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming MTUMismatch
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing InvalidConfig
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming InvalidConfig
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing RequiredExtensionMissing
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming RequiredExtensionMissing
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing VirtualSubnetId
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming VirtualSubnetId
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing BridgeReserved
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming BridgeReserved
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing RouterGuard
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming RouterGuard
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing DhcpGuard
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming DhcpGuard
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing MacSpoofing
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming MacSpoofing
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing Ipsec
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming Ipsec
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing Qos
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming Qos
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing FailedPvlanSetting
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming FailedPvlanSetting
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing FailedSecurityPolicy
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming FailedSecurityPolicy
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing UnauthorizedMAC
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming UnauthorizedMAC
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing UnauthorizedVLAN
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming UnauthorizedVLAN
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing FilteredVLAN
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming FilteredVLAN
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing Filtered
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming Filtered
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing Busy
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming Busy
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing NotAccepted
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming NotAccepted
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing Disconnected
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming Disconnected
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing NotReady
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming NotReady
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing Resources
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming Resources
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing InvalidPacket
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming InvalidPacket
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing InvalidData
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming InvalidData
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing Unknown
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming Unknown
virtualNetworkAdapterDropReasons *prometheus.Desc
}
type perfDataCounterValuesVirtualNetworkAdapterDropReasons struct {
Name string
VirtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq float64 `perfdata:"Outgoing NativeFwdingReq"`
VirtualNetworkAdapterDropReasonsIncomingNativeFwdingReq float64 `perfdata:"Incoming NativeFwdingReq"`
VirtualNetworkAdapterDropReasonsOutgoingMTUMismatch float64 `perfdata:"Outgoing MTUMismatch"`
VirtualNetworkAdapterDropReasonsIncomingMTUMismatch float64 `perfdata:"Incoming MTUMismatch"`
VirtualNetworkAdapterDropReasonsOutgoingInvalidConfig float64 `perfdata:"Outgoing InvalidConfig"`
VirtualNetworkAdapterDropReasonsIncomingInvalidConfig float64 `perfdata:"Incoming InvalidConfig"`
VirtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing float64 `perfdata:"Outgoing RequiredExtensionMissing"`
VirtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing float64 `perfdata:"Incoming RequiredExtensionMissing"`
VirtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId float64 `perfdata:"Outgoing VirtualSubnetId"`
VirtualNetworkAdapterDropReasonsIncomingVirtualSubnetId float64 `perfdata:"Incoming VirtualSubnetId"`
VirtualNetworkAdapterDropReasonsOutgoingBridgeReserved float64 `perfdata:"Outgoing BridgeReserved"`
VirtualNetworkAdapterDropReasonsIncomingBridgeReserved float64 `perfdata:"Incoming BridgeReserved"`
VirtualNetworkAdapterDropReasonsOutgoingRouterGuard float64 `perfdata:"Outgoing RouterGuard"`
VirtualNetworkAdapterDropReasonsIncomingRouterGuard float64 `perfdata:"Incoming RouterGuard"`
VirtualNetworkAdapterDropReasonsOutgoingDhcpGuard float64 `perfdata:"Outgoing DhcpGuard"`
VirtualNetworkAdapterDropReasonsIncomingDhcpGuard float64 `perfdata:"Incoming DhcpGuard"`
VirtualNetworkAdapterDropReasonsOutgoingMacSpoofing float64 `perfdata:"Outgoing MacSpoofing"`
VirtualNetworkAdapterDropReasonsIncomingMacSpoofing float64 `perfdata:"Incoming MacSpoofing"`
VirtualNetworkAdapterDropReasonsOutgoingIpsec float64 `perfdata:"Outgoing Ipsec"`
VirtualNetworkAdapterDropReasonsIncomingIpsec float64 `perfdata:"Incoming Ipsec"`
VirtualNetworkAdapterDropReasonsOutgoingQos float64 `perfdata:"Outgoing Qos"`
VirtualNetworkAdapterDropReasonsIncomingQos float64 `perfdata:"Incoming Qos"`
VirtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting float64 `perfdata:"Outgoing FailedPvlanSetting"`
VirtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting float64 `perfdata:"Incoming FailedPvlanSetting"`
VirtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy float64 `perfdata:"Outgoing FailedSecurityPolicy"`
VirtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy float64 `perfdata:"Incoming FailedSecurityPolicy"`
VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC float64 `perfdata:"Outgoing UnauthorizedMAC"`
VirtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC float64 `perfdata:"Incoming UnauthorizedMAC"`
VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN float64 `perfdata:"Outgoing UnauthorizedVLAN"`
VirtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN float64 `perfdata:"Incoming UnauthorizedVLAN"`
VirtualNetworkAdapterDropReasonsOutgoingFilteredVLAN float64 `perfdata:"Outgoing FilteredVLAN"`
VirtualNetworkAdapterDropReasonsIncomingFilteredVLAN float64 `perfdata:"Incoming FilteredVLAN"`
VirtualNetworkAdapterDropReasonsOutgoingFiltered float64 `perfdata:"Outgoing Filtered"`
VirtualNetworkAdapterDropReasonsIncomingFiltered float64 `perfdata:"Incoming Filtered"`
VirtualNetworkAdapterDropReasonsOutgoingBusy float64 `perfdata:"Outgoing Busy"`
VirtualNetworkAdapterDropReasonsIncomingBusy float64 `perfdata:"Incoming Busy"`
VirtualNetworkAdapterDropReasonsOutgoingNotAccepted float64 `perfdata:"Outgoing NotAccepted"`
VirtualNetworkAdapterDropReasonsIncomingNotAccepted float64 `perfdata:"Incoming NotAccepted"`
VirtualNetworkAdapterDropReasonsOutgoingDisconnected float64 `perfdata:"Outgoing Disconnected"`
VirtualNetworkAdapterDropReasonsIncomingDisconnected float64 `perfdata:"Incoming Disconnected"`
VirtualNetworkAdapterDropReasonsOutgoingNotReady float64 `perfdata:"Outgoing NotReady"`
VirtualNetworkAdapterDropReasonsIncomingNotReady float64 `perfdata:"Incoming NotReady"`
VirtualNetworkAdapterDropReasonsOutgoingResources float64 `perfdata:"Outgoing Resources"`
VirtualNetworkAdapterDropReasonsIncomingResources float64 `perfdata:"Incoming Resources"`
VirtualNetworkAdapterDropReasonsOutgoingInvalidPacket float64 `perfdata:"Outgoing InvalidPacket"`
VirtualNetworkAdapterDropReasonsIncomingInvalidPacket float64 `perfdata:"Incoming InvalidPacket"`
VirtualNetworkAdapterDropReasonsOutgoingInvalidData float64 `perfdata:"Outgoing InvalidData"`
VirtualNetworkAdapterDropReasonsIncomingInvalidData float64 `perfdata:"Incoming InvalidData"`
VirtualNetworkAdapterDropReasonsOutgoingUnknown float64 `perfdata:"Outgoing Unknown"`
VirtualNetworkAdapterDropReasonsIncomingUnknown float64 `perfdata:"Incoming Unknown"`
}
func (c *Collector) buildVirtualNetworkAdapterDropReasons() error {
var err error
c.perfDataCollectorVirtualNetworkAdapterDropReasons, err = pdh.NewCollector[perfDataCounterValuesVirtualNetworkAdapterDropReasons]("Hyper-V Virtual Network Adapter Drop Reasons", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Virtual Network Adapter Drop Reasons collector: %w", err)
}
c.virtualNetworkAdapterDropReasons = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_network_adapter_drop_reasons"),
"Hyper-V Virtual Network Adapter Drop Reasons",
[]string{"adapter", "reason", "direction"},
nil,
)
return nil
}
func (c *Collector) collectVirtualNetworkAdapterDropReasons(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorVirtualNetworkAdapterDropReasons.Collect(&c.perfDataObjectVirtualNetworkAdapterDropReasons)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Virtual Network Adapter Drop Reasons metrics: %w", err)
}
for _, data := range c.perfDataObjectVirtualNetworkAdapterDropReasons {
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq,
data.Name, "NativeFwdingReq", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingNativeFwdingReq,
data.Name, "NativeFwdingReq", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingMTUMismatch,
data.Name, "MTUMismatch", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingMTUMismatch,
data.Name, "MTUMismatch", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidConfig,
data.Name, "InvalidConfig", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingInvalidConfig,
data.Name, "InvalidConfig", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing,
data.Name, "RequiredExtensionMissing", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing,
data.Name, "RequiredExtensionMissing", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId,
data.Name, "VirtualSubnetId", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingVirtualSubnetId,
data.Name, "VirtualSubnetId", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingBridgeReserved,
data.Name, "BridgeReserved", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingBridgeReserved,
data.Name, "BridgeReserved", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingRouterGuard,
data.Name, "RouterGuard", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingRouterGuard,
data.Name, "RouterGuard", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingDhcpGuard,
data.Name, "DhcpGuard", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingDhcpGuard,
data.Name, "DhcpGuard", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingMacSpoofing,
data.Name, "MacSpoofing", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingMacSpoofing,
data.Name, "MacSpoofing", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingIpsec,
data.Name, "Ipsec", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingIpsec,
data.Name, "Ipsec", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingQos,
data.Name, "Qos", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingQos,
data.Name, "Qos", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting,
data.Name, "FailedPvlanSetting", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting,
data.Name, "FailedPvlanSetting", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy,
data.Name, "FailedSecurityPolicy", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy,
data.Name, "FailedSecurityPolicy", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC,
data.Name, "UnauthorizedMAC", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC,
data.Name, "UnauthorizedMAC", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN,
data.Name, "UnauthorizedVLAN", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN,
data.Name, "UnauthorizedVLAN", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingFilteredVLAN,
data.Name, "FilteredVLAN", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingFilteredVLAN,
data.Name, "FilteredVLAN", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingFiltered,
data.Name, "Filtered", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingFiltered,
data.Name, "Filtered", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingBusy,
data.Name, "Busy", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingBusy,
data.Name, "Busy", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingNotAccepted,
data.Name, "NotAccepted", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingNotAccepted,
data.Name, "NotAccepted", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingDisconnected,
data.Name, "Disconnected", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingDisconnected,
data.Name, "Disconnected", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingNotReady,
data.Name, "NotReady", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingNotReady,
data.Name, "NotReady", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingResources,
data.Name, "Resources", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingResources,
data.Name, "Resources", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidPacket,
data.Name, "InvalidPacket", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingInvalidPacket,
data.Name, "InvalidPacket", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidData,
data.Name, "InvalidData", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingInvalidData,
data.Name, "InvalidData", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsOutgoingUnknown,
data.Name, "Unknown", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
data.VirtualNetworkAdapterDropReasonsIncomingUnknown,
data.Name, "Unknown", "incoming",
)
}
return nil
}

View File

@@ -0,0 +1,314 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorVirtualSMB Hyper-V Virtual SMB metrics
type collectorVirtualSMB struct {
perfDataCollectorVirtualSMB *pdh.Collector
perfDataObjectVirtualSMB []perfDataCounterValuesVirtualSMB
virtualSMBDirectMappedSections *prometheus.Desc // \Hyper-V Virtual SMB(*)\Direct-Mapped Sections
virtualSMBDirectMappedPages *prometheus.Desc // \Hyper-V Virtual SMB(*)\Direct-Mapped Pages
virtualSMBWriteBytesRDMA *prometheus.Desc // \Hyper-V Virtual SMB(*)\Write Bytes/sec (RDMA)
virtualSMBWriteBytes *prometheus.Desc // \Hyper-V Virtual SMB(*)\Write Bytes/sec
virtualSMBReadBytesRDMA *prometheus.Desc // \Hyper-V Virtual SMB(*)\Read Bytes/sec (RDMA)
virtualSMBReadBytes *prometheus.Desc // \Hyper-V Virtual SMB(*)\Read Bytes/sec
virtualSMBFlushRequests *prometheus.Desc // \Hyper-V Virtual SMB(*)\Flush Requests/sec
virtualSMBWriteRequestsRDMA *prometheus.Desc // \Hyper-V Virtual SMB(*)\Write Requests/sec (RDMA)
virtualSMBWriteRequests *prometheus.Desc // \Hyper-V Virtual SMB(*)\Write Requests/sec
virtualSMBReadRequestsRDMA *prometheus.Desc // \Hyper-V Virtual SMB(*)\Read Requests/sec (RDMA)
virtualSMBReadRequests *prometheus.Desc // \Hyper-V Virtual SMB(*)\Read Requests/sec
virtualSMBCurrentPendingRequests *prometheus.Desc // \Hyper-V Virtual SMB(*)\Current Pending Requests
virtualSMBCurrentOpenFileCount *prometheus.Desc // \Hyper-V Virtual SMB(*)\Current Open File Count
virtualSMBTreeConnectCount *prometheus.Desc // \Hyper-V Virtual SMB(*)\Tree Connect Count
virtualSMBRequests *prometheus.Desc // \Hyper-V Virtual SMB(*)\Requests/sec
virtualSMBSentBytes *prometheus.Desc // \Hyper-V Virtual SMB(*)\Sent Bytes/sec
virtualSMBReceivedBytes *prometheus.Desc // \Hyper-V Virtual SMB(*)\Received Bytes/sec
}
type perfDataCounterValuesVirtualSMB struct {
Name string
VirtualSMBDirectMappedSections float64 `perfdata:"Direct-Mapped Sections"`
VirtualSMBDirectMappedPages float64 `perfdata:"Direct-Mapped Pages"`
VirtualSMBWriteBytesRDMA float64 `perfdata:"Write Bytes/sec (RDMA)"`
VirtualSMBWriteBytes float64 `perfdata:"Write Bytes/sec"`
VirtualSMBReadBytesRDMA float64 `perfdata:"Read Bytes/sec (RDMA)"`
VirtualSMBReadBytes float64 `perfdata:"Read Bytes/sec"`
VirtualSMBFlushRequests float64 `perfdata:"Flush Requests/sec"`
VirtualSMBWriteRequestsRDMA float64 `perfdata:"Write Requests/sec (RDMA)"`
VirtualSMBWriteRequests float64 `perfdata:"Write Requests/sec"`
VirtualSMBReadRequestsRDMA float64 `perfdata:"Read Requests/sec (RDMA)"`
VirtualSMBReadRequests float64 `perfdata:"Read Requests/sec"`
VirtualSMBCurrentPendingRequests float64 `perfdata:"Current Pending Requests"`
VirtualSMBCurrentOpenFileCount float64 `perfdata:"Current Open File Count"`
VirtualSMBTreeConnectCount float64 `perfdata:"Tree Connect Count"`
VirtualSMBRequests float64 `perfdata:"Requests/sec"`
VirtualSMBSentBytes float64 `perfdata:"Sent Bytes/sec"`
VirtualSMBReceivedBytes float64 `perfdata:"Received Bytes/sec"`
}
func (c *Collector) buildVirtualSMB() error {
var err error
c.perfDataCollectorVirtualSMB, err = pdh.NewCollector[perfDataCounterValuesVirtualSMB]("Hyper-V Virtual SMB", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Virtual SMB collector: %w", err)
}
c.virtualSMBDirectMappedSections = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_direct_mapped_sections"),
"Represents the number of direct-mapped sections in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBDirectMappedPages = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_direct_mapped_pages"),
"Represents the number of direct-mapped pages in the virtual SMB",
[]string{"instance"},
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",
[]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",
[]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",
[]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",
[]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",
[]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",
[]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",
[]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",
[]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",
[]string{"instance"},
nil,
)
c.virtualSMBCurrentPendingRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_current_pending_requests"),
"Represents the current number of pending requests in the virtual SMB",
[]string{"instance"},
nil,
)
c.virtualSMBCurrentOpenFileCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_smb_current_open_file_count"),
"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",
[]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",
[]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",
[]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",
[]string{"instance"},
nil,
)
return nil
}
func (c *Collector) collectVirtualSMB(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorVirtualSMB.Collect(&c.perfDataObjectVirtualSMB)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Virtual SMB metrics: %w", err)
}
for _, data := range c.perfDataObjectVirtualSMB {
ch <- prometheus.MustNewConstMetric(
c.virtualSMBDirectMappedSections,
prometheus.GaugeValue,
data.VirtualSMBDirectMappedSections,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBDirectMappedPages,
prometheus.GaugeValue,
data.VirtualSMBDirectMappedPages,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBWriteBytesRDMA,
prometheus.CounterValue,
data.VirtualSMBWriteBytesRDMA,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBWriteBytes,
prometheus.CounterValue,
data.VirtualSMBWriteBytes,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBReadBytesRDMA,
prometheus.CounterValue,
data.VirtualSMBReadBytesRDMA,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBReadBytes,
prometheus.CounterValue,
data.VirtualSMBReadBytes,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBFlushRequests,
prometheus.CounterValue,
data.VirtualSMBFlushRequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBWriteRequestsRDMA,
prometheus.CounterValue,
data.VirtualSMBWriteRequestsRDMA,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBWriteRequests,
prometheus.CounterValue,
data.VirtualSMBWriteRequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBReadRequestsRDMA,
prometheus.CounterValue,
data.VirtualSMBReadRequestsRDMA,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBReadRequests,
prometheus.CounterValue,
data.VirtualSMBReadRequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBCurrentPendingRequests,
prometheus.GaugeValue,
data.VirtualSMBCurrentPendingRequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBCurrentOpenFileCount,
prometheus.GaugeValue,
data.VirtualSMBCurrentOpenFileCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBTreeConnectCount,
prometheus.GaugeValue,
data.VirtualSMBTreeConnectCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBRequests,
prometheus.CounterValue,
data.VirtualSMBRequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBSentBytes,
prometheus.CounterValue,
data.VirtualSMBSentBytes,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSMBReceivedBytes,
prometheus.CounterValue,
data.VirtualSMBReceivedBytes,
data.Name,
)
}
return nil
}

View File

@@ -0,0 +1,239 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// Hyper-V Virtual Storage Device metrics
type collectorVirtualStorageDevice struct {
perfDataCollectorVirtualStorageDevice *pdh.Collector
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
}
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"`
VirtualStorageDeviceWriteOperations float64 `perfdata:"Write Count"`
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"`
}
func (c *Collector) buildVirtualStorageDevice() error {
var err error
c.perfDataCollectorVirtualStorageDevice, err = pdh.NewCollector[perfDataCounterValuesVirtualStorageDevice]("Hyper-V Virtual Storage Device", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Virtual Storage Device collector: %w", err)
}
c.virtualStorageDeviceErrorCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_error_count_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"),
"Represents the average queue length on this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceReadBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_bytes_read"),
"Represents the total number of bytes that have been read on this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceReadOperations = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_operations_read_total"),
"Represents the total number of read operations that have occurred on this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceWriteBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_bytes_written"),
"Represents the total number of bytes that have been written on this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceWriteOperations = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_operations_written_total"),
"Represents the total number of write operations that have occurred on this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_latency_seconds"),
"Represents the average IO transfer latency for this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceThroughput = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_throughput"),
"Represents the average number of 8KB IO transfers completed by this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceNormalizedThroughput = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_normalized_throughput"),
"Represents the average number of IO transfers completed by this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceLowerQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_lower_queue_length"),
"Represents the average queue length on the underlying storage subsystem for this device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceLowerLatency = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "virtual_storage_device_lower_latency_seconds"),
"Represents the average IO transfer latency on the underlying storage subsystem for this virtual device.",
[]string{"device"},
nil,
)
c.virtualStorageDeviceIOQuotaReplenishmentRate = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "io_quota_replenishment_rate"),
"Represents the IO quota replenishment rate for this virtual device.",
[]string{"device"},
nil,
)
return nil
}
func (c *Collector) collectVirtualStorageDevice(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorVirtualStorageDevice.Collect(&c.perfDataObjectVirtualStorageDevice)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Virtual Storage Device metrics: %w", err)
}
for _, data := range c.perfDataObjectVirtualStorageDevice {
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceErrorCount,
prometheus.CounterValue,
data.VirtualStorageDeviceErrorCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceQueueLength,
prometheus.GaugeValue,
data.VirtualStorageDeviceQueueLength,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceReadBytes,
prometheus.CounterValue,
data.VirtualStorageDeviceReadBytes,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceReadOperations,
prometheus.CounterValue,
data.VirtualStorageDeviceReadOperations,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceWriteBytes,
prometheus.CounterValue,
data.VirtualStorageDeviceWriteBytes,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceWriteOperations,
prometheus.CounterValue,
data.VirtualStorageDeviceWriteOperations,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceLatency,
prometheus.GaugeValue,
data.VirtualStorageDeviceLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceThroughput,
prometheus.GaugeValue,
data.VirtualStorageDeviceThroughput,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceNormalizedThroughput,
prometheus.GaugeValue,
data.VirtualStorageDeviceNormalizedThroughput,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceLowerQueueLength,
prometheus.GaugeValue,
data.VirtualStorageDeviceLowerQueueLength,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceLowerLatency,
prometheus.GaugeValue,
data.VirtualStorageDeviceLowerLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualStorageDeviceIOQuotaReplenishmentRate,
prometheus.GaugeValue,
data.VirtualStorageDeviceIOQuotaReplenishmentRate,
data.Name,
)
}
return nil
}

View File

@@ -0,0 +1,364 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
// collectorVirtualMachineHealthSummary Hyper-V Virtual Switch Summary metrics
type collectorVirtualSwitch struct {
perfDataCollectorVirtualSwitch *pdh.Collector
perfDataObjectVirtualSwitch []perfDataCounterValuesVirtualSwitch
virtualSwitchBroadcastPacketsReceived *prometheus.Desc // \Hyper-V Virtual Switch(*)\Broadcast Packets Received/sec
virtualSwitchBroadcastPacketsSent *prometheus.Desc // \Hyper-V Virtual Switch(*)\Broadcast Packets Sent/sec
virtualSwitchBytes *prometheus.Desc // \Hyper-V Virtual Switch(*)\Bytes/sec
virtualSwitchBytesReceived *prometheus.Desc // \Hyper-V Virtual Switch(*)\Bytes Received/sec
virtualSwitchBytesSent *prometheus.Desc // \Hyper-V Virtual Switch(*)\Bytes Sent/sec
virtualSwitchDirectedPacketsReceived *prometheus.Desc // \Hyper-V Virtual Switch(*)\Directed Packets Received/sec
virtualSwitchDirectedPacketsSent *prometheus.Desc // \Hyper-V Virtual Switch(*)\Directed Packets Sent/sec
virtualSwitchDroppedPacketsIncoming *prometheus.Desc // \Hyper-V Virtual Switch(*)\Dropped Packets Incoming/sec
virtualSwitchDroppedPacketsOutgoing *prometheus.Desc // \Hyper-V Virtual Switch(*)\Dropped Packets Outgoing/sec
virtualSwitchExtensionsDroppedPacketsIncoming *prometheus.Desc // \Hyper-V Virtual Switch(*)\Extensions Dropped Packets Incoming/sec
virtualSwitchExtensionsDroppedPacketsOutgoing *prometheus.Desc // \Hyper-V Virtual Switch(*)\Extensions Dropped Packets Outgoing/sec
virtualSwitchLearnedMacAddresses *prometheus.Desc // \Hyper-V Virtual Switch(*)\Learned Mac Addresses
virtualSwitchMulticastPacketsReceived *prometheus.Desc // \Hyper-V Virtual Switch(*)\Multicast Packets Received/sec
virtualSwitchMulticastPacketsSent *prometheus.Desc // \Hyper-V Virtual Switch(*)\Multicast Packets Sent/sec
virtualSwitchNumberOfSendChannelMoves *prometheus.Desc // \Hyper-V Virtual Switch(*)\Number of Send Channel Moves/sec
virtualSwitchNumberOfVMQMoves *prometheus.Desc // \Hyper-V Virtual Switch(*)\Number of VMQ Moves/sec
virtualSwitchPacketsFlooded *prometheus.Desc // \Hyper-V Virtual Switch(*)\Packets Flooded
virtualSwitchPackets *prometheus.Desc // \Hyper-V Virtual Switch(*)\Packets/sec
virtualSwitchPacketsReceived *prometheus.Desc // \Hyper-V Virtual Switch(*)\Packets Received/sec
virtualSwitchPacketsSent *prometheus.Desc // \Hyper-V Virtual Switch(*)\Packets Sent/sec
virtualSwitchPurgedMacAddresses *prometheus.Desc // \Hyper-V Virtual Switch(*)\Purged Mac Addresses
}
type perfDataCounterValuesVirtualSwitch struct {
Name string
VirtualSwitchBroadcastPacketsReceived float64 `perfdata:"Broadcast Packets Received/sec"`
VirtualSwitchBroadcastPacketsSent float64 `perfdata:"Broadcast Packets Sent/sec"`
VirtualSwitchBytes float64 `perfdata:"Bytes/sec"`
VirtualSwitchBytesReceived float64 `perfdata:"Bytes Received/sec"`
VirtualSwitchBytesSent float64 `perfdata:"Bytes Sent/sec"`
VirtualSwitchDirectedPacketsReceived float64 `perfdata:"Directed Packets Received/sec"`
VirtualSwitchDirectedPacketsSent float64 `perfdata:"Directed Packets Sent/sec"`
VirtualSwitchDroppedPacketsIncoming float64 `perfdata:"Dropped Packets Incoming/sec"`
VirtualSwitchDroppedPacketsOutgoing float64 `perfdata:"Dropped Packets Outgoing/sec"`
VirtualSwitchExtensionsDroppedPacketsIncoming float64 `perfdata:"Extensions Dropped Packets Incoming/sec"`
VirtualSwitchExtensionsDroppedPacketsOutgoing float64 `perfdata:"Extensions Dropped Packets Outgoing/sec"`
VirtualSwitchLearnedMacAddresses float64 `perfdata:"Learned Mac Addresses"`
VirtualSwitchMulticastPacketsReceived float64 `perfdata:"Multicast Packets Received/sec"`
VirtualSwitchMulticastPacketsSent float64 `perfdata:"Multicast Packets Sent/sec"`
VirtualSwitchNumberOfSendChannelMoves float64 `perfdata:"Number of Send Channel Moves/sec"`
VirtualSwitchNumberOfVMQMoves float64 `perfdata:"Number of VMQ Moves/sec"`
VirtualSwitchPacketsFlooded float64 `perfdata:"Packets Flooded"`
VirtualSwitchPackets float64 `perfdata:"Packets/sec"`
VirtualSwitchPacketsReceived float64 `perfdata:"Packets Received/sec"`
VirtualSwitchPacketsSent float64 `perfdata:"Packets Sent/sec"`
VirtualSwitchPurgedMacAddresses float64 `perfdata:"Purged Mac Addresses"`
}
func (c *Collector) buildVirtualSwitch() error {
var err error
c.perfDataCollectorVirtualSwitch, err = pdh.NewCollector[perfDataCounterValuesVirtualSwitch]("Hyper-V Virtual Switch", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Virtual Switch collector: %w", err)
}
c.virtualSwitchBroadcastPacketsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_broadcast_packets_received_total"),
"Represents the total number of broadcast packets received per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchBroadcastPacketsSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_broadcast_packets_sent_total"),
"Represents the total number of broadcast packets sent per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_bytes_total"),
"Represents the total number of bytes per second traversing the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchBytesReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_bytes_received_total"),
"Represents the total number of bytes received per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchBytesSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_bytes_sent_total"),
"Represents the total number of bytes sent per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchDirectedPacketsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_directed_packets_received_total"),
"Represents the total number of directed packets received per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchDirectedPacketsSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_directed_packets_send_total"),
"Represents the total number of directed packets sent per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchDroppedPacketsIncoming = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_dropped_packets_incoming_total"),
"Represents the total number of packet dropped per second by the virtual switch in the incoming direction",
[]string{"vswitch"},
nil,
)
c.virtualSwitchDroppedPacketsOutgoing = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_dropped_packets_outcoming_total"),
"Represents the total number of packet dropped per second by the virtual switch in the outgoing direction",
[]string{"vswitch"},
nil,
)
c.virtualSwitchExtensionsDroppedPacketsIncoming = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_extensions_dropped_packets_incoming_total"),
"Represents the total number of packet dropped per second by the virtual switch extensions in the incoming direction",
[]string{"vswitch"},
nil,
)
c.virtualSwitchExtensionsDroppedPacketsOutgoing = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_extensions_dropped_packets_outcoming_total"),
"Represents the total number of packet dropped per second by the virtual switch extensions in the outgoing direction",
[]string{"vswitch"},
nil,
)
c.virtualSwitchLearnedMacAddresses = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_learned_mac_addresses_total"),
"Represents the total number of learned MAC addresses of the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchMulticastPacketsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_multicast_packets_received_total"),
"Represents the total number of multicast packets received per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchMulticastPacketsSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_multicast_packets_sent_total"),
"Represents the total number of multicast packets sent per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchNumberOfSendChannelMoves = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_number_of_send_channel_moves_total"),
"Represents the total number of send channel moves per second on this virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchNumberOfVMQMoves = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_number_of_vmq_moves_total"),
"Represents the total number of VMQ moves per second on this virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchPacketsFlooded = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_packets_flooded_total"),
"Represents the total number of packets flooded by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchPackets = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_packets_total"),
"Represents the total number of packets per second traversing the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchPacketsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_packets_received_total"),
"Represents the total number of packets received per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchPacketsSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_packets_sent_total"),
"Represents the total number of packets send per second by the virtual switch",
[]string{"vswitch"},
nil,
)
c.virtualSwitchPurgedMacAddresses = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "vswitch_purged_mac_addresses_total"),
"Represents the total number of purged MAC addresses of the virtual switch",
[]string{"vswitch"},
nil,
)
return nil
}
func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
err := c.perfDataCollectorVirtualSwitch.Collect(&c.perfDataObjectVirtualSwitch)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Virtual Switch metrics: %w", err)
}
for _, data := range c.perfDataObjectVirtualSwitch {
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchBroadcastPacketsReceived,
prometheus.CounterValue,
data.VirtualSwitchBroadcastPacketsReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchBroadcastPacketsSent,
prometheus.CounterValue,
data.VirtualSwitchBroadcastPacketsSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchBytes,
prometheus.CounterValue,
data.VirtualSwitchBytes,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchBytesReceived,
prometheus.CounterValue,
data.VirtualSwitchBytesReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchBytesSent,
prometheus.CounterValue,
data.VirtualSwitchBytesSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchDirectedPacketsReceived,
prometheus.CounterValue,
data.VirtualSwitchDirectedPacketsReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchDirectedPacketsSent,
prometheus.CounterValue,
data.VirtualSwitchDirectedPacketsSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchDroppedPacketsIncoming,
prometheus.CounterValue,
data.VirtualSwitchDroppedPacketsIncoming,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchDroppedPacketsOutgoing,
prometheus.CounterValue,
data.VirtualSwitchDroppedPacketsOutgoing,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchExtensionsDroppedPacketsIncoming,
prometheus.CounterValue,
data.VirtualSwitchExtensionsDroppedPacketsIncoming,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchExtensionsDroppedPacketsOutgoing,
prometheus.CounterValue,
data.VirtualSwitchExtensionsDroppedPacketsOutgoing,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchLearnedMacAddresses,
prometheus.CounterValue,
data.VirtualSwitchLearnedMacAddresses,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchMulticastPacketsReceived,
prometheus.CounterValue,
data.VirtualSwitchMulticastPacketsReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchMulticastPacketsSent,
prometheus.CounterValue,
data.VirtualSwitchMulticastPacketsSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchNumberOfSendChannelMoves,
prometheus.CounterValue,
data.VirtualSwitchNumberOfSendChannelMoves,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchNumberOfVMQMoves,
prometheus.CounterValue,
data.VirtualSwitchNumberOfVMQMoves,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchPacketsFlooded,
prometheus.CounterValue,
data.VirtualSwitchPacketsFlooded,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchPackets,
prometheus.CounterValue,
data.VirtualSwitchPackets,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchPacketsReceived,
prometheus.CounterValue,
data.VirtualSwitchPacketsReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchPacketsSent,
prometheus.CounterValue,
data.VirtualSwitchPacketsSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualSwitchPurgedMacAddresses,
prometheus.CounterValue,
data.VirtualSwitchPurgedMacAddresses,
data.Name,
)
}
return nil
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package iis
@@ -6,14 +19,12 @@ import (
"errors"
"fmt"
"log/slog"
"maps"
"regexp"
"slices"
"strings"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/sys/windows/registry"
@@ -28,6 +39,7 @@ type Config struct {
AppExclude *regexp.Regexp `yaml:"app_exclude"`
}
//nolint:gochecknoglobals
var ConfigDefaults = Config{
SiteInclude: types.RegExpAny,
SiteExclude: types.RegExpEmpty,
@@ -137,8 +149,8 @@ func (c *Collector) GetName() string {
func (c *Collector) Close() error {
c.perfDataCollectorWebService.Close()
c.perfDataCollectorAppPoolWAS.Close()
c.perfDataCollectorW3SVCW3WP.Close()
c.perfDataCollectorWebServiceCache.Close()
c.w3SVCW3WPPerfDataCollector.Close()
c.serviceCachePerfDataCollector.Close()
return nil
}
@@ -155,23 +167,25 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
prometheus.Labels{"version": fmt.Sprintf("%d.%d", c.iisVersion.major, c.iisVersion.minor)},
)
errs := make([]error, 0, 4)
if err := c.buildWebService(); err != nil {
return fmt.Errorf("failed to build Web Service collector: %w", err)
errs = append(errs, fmt.Errorf("failed to build Web Service collector: %w", err))
}
if err := c.buildAppPoolWAS(); err != nil {
return fmt.Errorf("failed to build APP_POOL_WAS collector: %w", err)
errs = append(errs, fmt.Errorf("failed to build APP_POOL_WAS collector: %w", err))
}
if err := c.buildW3SVCW3WP(); err != nil {
return fmt.Errorf("failed to build W3SVC_W3WP collector: %w", err)
errs = append(errs, fmt.Errorf("failed to build W3SVC_W3WP collector: %w", err))
}
if err := c.buildWebServiceCache(); err != nil {
return fmt.Errorf("failed to build Web Service Cache collector: %w", err)
errs = append(errs, fmt.Errorf("failed to build Web Service Cache collector: %w", err))
}
return nil
return errors.Join(errs...)
}
type simpleVersion struct {
@@ -182,7 +196,7 @@ type simpleVersion struct {
func (c *Collector) getIISVersion(logger *slog.Logger) simpleVersion {
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\InetStp\`, registry.QUERY_VALUE)
if err != nil {
logger.Warn("Couldn't open registry to determine IIS version",
logger.Warn("couldn't open registry to determine IIS version",
slog.Any("err", err),
)
@@ -254,26 +268,36 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
return errors.Join(errs...)
}
type collectorName interface {
GetName() string
}
// deduplicateIISNames deduplicate IIS site names from various IIS perflib objects.
//
// E.G. Given the following list of site names, "Site_B" would be
// discarded, and "Site_B#2" would be kept and presented as "Site_B" in the
// Collector metrics.
// [ "Site_A", "Site_B", "Site_C", "Site_B#2" ].
func deduplicateIISNames(counterValues map[string]map[string]perfdata.CounterValues) {
services := slices.Collect(maps.Keys(counterValues))
func deduplicateIISNames[T collectorName](counterValues []T) {
indexes := make(map[string]int)
// Ensure IIS entry with the highest suffix occurs last
slices.Sort(services)
slices.SortFunc(counterValues, func(a, b T) int {
return strings.Compare(a.GetName(), b.GetName())
})
// Use map to deduplicate IIS entries
for _, entry := range services {
name := strings.Split(entry, "#")[0]
if name == entry {
for index, counterValue := range counterValues {
name := strings.Split(counterValue.GetName(), "#")[0]
if name == counterValue.GetName() {
continue
}
counterValues[name] = counterValues[entry]
delete(counterValues, entry)
if originalIndex, ok := indexes[name]; !ok {
counterValues[originalIndex] = counterValue
counterValues = slices.Delete(counterValues, index, 1)
} else {
indexes[name] = index
}
}
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package iis
@@ -5,13 +18,14 @@ package iis
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
type collectorAppPoolWAS struct {
perfDataCollectorAppPoolWAS *perfdata.Collector
perfDataCollectorAppPoolWAS *pdh.Collector
perfDataObjectAppPoolWAS []perfDataCounterValuesAppPoolWAS
currentApplicationPoolState *prometheus.Desc
currentApplicationPoolUptime *prometheus.Desc
@@ -27,23 +41,29 @@ type collectorAppPoolWAS struct {
totalWorkerProcessShutdownFailures *prometheus.Desc
totalWorkerProcessStartupFailures *prometheus.Desc
}
type perfDataCounterValuesAppPoolWAS struct {
Name string
const (
CurrentApplicationPoolState = "Current Application Pool State"
CurrentApplicationPoolUptime = "Current Application Pool Uptime"
CurrentWorkerProcesses = "Current Worker Processes"
MaximumWorkerProcesses = "Maximum Worker Processes"
RecentWorkerProcessFailures = "Recent Worker Process Failures"
TimeSinceLastWorkerProcessFailure = "Time Since Last Worker Process Failure"
TotalApplicationPoolRecycles = "Total Application Pool Recycles"
TotalApplicationPoolUptime = "Total Application Pool Uptime"
TotalWorkerProcessesCreated = "Total Worker Processes Created"
TotalWorkerProcessFailures = "Total Worker Process Failures"
TotalWorkerProcessPingFailures = "Total Worker Process Ping Failures"
TotalWorkerProcessShutdownFailures = "Total Worker Process Shutdown Failures"
TotalWorkerProcessStartupFailures = "Total Worker Process Startup Failures"
)
CurrentApplicationPoolState float64 `perfdata:"Current Application Pool State"`
CurrentApplicationPoolUptime float64 `perfdata:"Current Application Pool Uptime"`
CurrentWorkerProcesses float64 `perfdata:"Current Worker Processes"`
MaximumWorkerProcesses float64 `perfdata:"Maximum Worker Processes"`
RecentWorkerProcessFailures float64 `perfdata:"Recent Worker Process Failures"`
TimeSinceLastWorkerProcessFailure float64 `perfdata:"Time Since Last Worker Process Failure"`
TotalApplicationPoolRecycles float64 `perfdata:"Total Application Pool Recycles"`
TotalApplicationPoolUptime float64 `perfdata:"Total Application Pool Uptime"`
TotalWorkerProcessesCreated float64 `perfdata:"Total Worker Processes Created"`
TotalWorkerProcessFailures float64 `perfdata:"Total Worker Process Failures"`
TotalWorkerProcessPingFailures float64 `perfdata:"Total Worker Process Ping Failures"`
TotalWorkerProcessShutdownFailures float64 `perfdata:"Total Worker Process Shutdown Failures"`
TotalWorkerProcessStartupFailures float64 `perfdata:"Total Worker Process Startup Failures"`
}
func (p perfDataCounterValuesAppPoolWAS) GetName() string {
return p.Name
}
//nolint:gochecknoglobals
var applicationStates = map[uint32]string{
1: "Uninitialized",
2: "Initialized",
@@ -57,21 +77,7 @@ var applicationStates = map[uint32]string{
func (c *Collector) buildAppPoolWAS() error {
var err error
c.perfDataCollectorAppPoolWAS, err = perfdata.NewCollector("APP_POOL_WAS", perfdata.InstanceAll, []string{
CurrentApplicationPoolState,
CurrentApplicationPoolUptime,
CurrentWorkerProcesses,
MaximumWorkerProcesses,
RecentWorkerProcessFailures,
TimeSinceLastWorkerProcessFailure,
TotalApplicationPoolRecycles,
TotalApplicationPoolUptime,
TotalWorkerProcessesCreated,
TotalWorkerProcessFailures,
TotalWorkerProcessPingFailures,
TotalWorkerProcessShutdownFailures,
TotalWorkerProcessStartupFailures,
})
c.perfDataCollectorAppPoolWAS, err = pdh.NewCollector[perfDataCounterValuesAppPoolWAS]("APP_POOL_WAS", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create APP_POOL_WAS collector: %w", err)
}
@@ -160,21 +166,21 @@ func (c *Collector) buildAppPoolWAS() error {
}
func (c *Collector) collectAppPoolWAS(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorWebService.Collect()
err := c.perfDataCollectorAppPoolWAS.Collect(&c.perfDataObjectAppPoolWAS)
if err != nil {
return fmt.Errorf("failed to collect APP_POOL_WAS metrics: %w", err)
}
deduplicateIISNames(perfData)
deduplicateIISNames(c.perfDataObjectAppPoolWAS)
for name, app := range perfData {
if c.config.AppExclude.MatchString(name) || !c.config.AppInclude.MatchString(name) {
for _, data := range c.perfDataObjectAppPoolWAS {
if c.config.AppExclude.MatchString(data.Name) || !c.config.AppInclude.MatchString(data.Name) {
continue
}
for key, label := range applicationStates {
isCurrentState := 0.0
if key == uint32(app[CurrentApplicationPoolState].FirstValue) {
if key == uint32(data.CurrentApplicationPoolState) {
isCurrentState = 1.0
}
@@ -182,7 +188,7 @@ func (c *Collector) collectAppPoolWAS(ch chan<- prometheus.Metric) error {
c.currentApplicationPoolState,
prometheus.GaugeValue,
isCurrentState,
name,
data.Name,
label,
)
}
@@ -190,74 +196,74 @@ func (c *Collector) collectAppPoolWAS(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(
c.currentApplicationPoolUptime,
prometheus.GaugeValue,
app[CurrentApplicationPoolUptime].FirstValue,
name,
data.CurrentApplicationPoolUptime,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.currentWorkerProcesses,
prometheus.GaugeValue,
app[CurrentWorkerProcesses].FirstValue,
name,
data.CurrentWorkerProcesses,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.maximumWorkerProcesses,
prometheus.GaugeValue,
app[MaximumWorkerProcesses].FirstValue,
name,
data.MaximumWorkerProcesses,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.recentWorkerProcessFailures,
prometheus.GaugeValue,
app[RecentWorkerProcessFailures].FirstValue,
name,
data.RecentWorkerProcessFailures,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.timeSinceLastWorkerProcessFailure,
prometheus.GaugeValue,
app[TimeSinceLastWorkerProcessFailure].FirstValue,
name,
data.TimeSinceLastWorkerProcessFailure,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalApplicationPoolRecycles,
prometheus.CounterValue,
app[TotalApplicationPoolRecycles].FirstValue,
name,
data.TotalApplicationPoolRecycles,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalApplicationPoolUptime,
prometheus.CounterValue,
app[TotalApplicationPoolUptime].FirstValue,
name,
data.TotalApplicationPoolUptime,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalWorkerProcessesCreated,
prometheus.CounterValue,
app[TotalWorkerProcessesCreated].FirstValue,
name,
data.TotalWorkerProcessesCreated,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalWorkerProcessFailures,
prometheus.CounterValue,
app[TotalWorkerProcessFailures].FirstValue,
name,
data.TotalWorkerProcessFailures,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalWorkerProcessPingFailures,
prometheus.CounterValue,
app[TotalWorkerProcessPingFailures].FirstValue,
name,
data.TotalWorkerProcessPingFailures,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalWorkerProcessShutdownFailures,
prometheus.CounterValue,
app[TotalWorkerProcessShutdownFailures].FirstValue,
name,
data.TotalWorkerProcessShutdownFailures,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalWorkerProcessStartupFailures,
prometheus.CounterValue,
app[TotalWorkerProcessStartupFailures].FirstValue,
name,
data.TotalWorkerProcessStartupFailures,
data.Name,
)
}

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package iis_test
@@ -12,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, iis.Name, iis.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, iis.New, nil)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build windows
package iis
@@ -5,251 +18,220 @@ package iis
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
type collectorWebService struct {
perfDataCollectorWebService *perfdata.Collector
perfDataCollectorWebService *pdh.Collector
perfDataObjectWebService []perfDataCounterValuesWebService
currentAnonymousUsers *prometheus.Desc
currentBlockedAsyncIORequests *prometheus.Desc
currentCGIRequests *prometheus.Desc
currentConnections *prometheus.Desc
currentISAPIExtensionRequests *prometheus.Desc
currentNonAnonymousUsers *prometheus.Desc
serviceUptime *prometheus.Desc
totalBytesReceived *prometheus.Desc
totalBytesSent *prometheus.Desc
totalAnonymousUsers *prometheus.Desc
totalBlockedAsyncIORequests *prometheus.Desc
totalCGIRequests *prometheus.Desc
totalConnectionAttemptsAllInstances *prometheus.Desc
totalRequests *prometheus.Desc
totalFilesReceived *prometheus.Desc
totalFilesSent *prometheus.Desc
totalISAPIExtensionRequests *prometheus.Desc
totalLockedErrors *prometheus.Desc
totalLogonAttempts *prometheus.Desc
totalNonAnonymousUsers *prometheus.Desc
totalNotFoundErrors *prometheus.Desc
totalRejectedAsyncIORequests *prometheus.Desc
webServiceCurrentAnonymousUsers *prometheus.Desc
webServiceCurrentBlockedAsyncIORequests *prometheus.Desc
webServiceCurrentCGIRequests *prometheus.Desc
webServiceCurrentConnections *prometheus.Desc
webServiceCurrentISAPIExtensionRequests *prometheus.Desc
webServiceCurrentNonAnonymousUsers *prometheus.Desc
webServiceServiceUptime *prometheus.Desc
webServiceTotalBytesReceived *prometheus.Desc
webServiceTotalBytesSent *prometheus.Desc
webServiceTotalAnonymousUsers *prometheus.Desc
webServiceTotalBlockedAsyncIORequests *prometheus.Desc
webServiceTotalCGIRequests *prometheus.Desc
webServiceTotalConnectionAttemptsAllInstances *prometheus.Desc
webServiceTotalRequests *prometheus.Desc
webServiceTotalFilesReceived *prometheus.Desc
webServiceTotalFilesSent *prometheus.Desc
webServiceTotalISAPIExtensionRequests *prometheus.Desc
webServiceTotalLockedErrors *prometheus.Desc
webServiceTotalLogonAttempts *prometheus.Desc
webServiceTotalNonAnonymousUsers *prometheus.Desc
webServiceTotalNotFoundErrors *prometheus.Desc
webServiceTotalRejectedAsyncIORequests *prometheus.Desc
}
const (
CurrentAnonymousUsers = "Current Anonymous Users"
CurrentBlockedAsyncIORequests = "Current Blocked Async I/O Requests"
CurrentCGIRequests = "Current CGI Requests"
CurrentConnections = "Current Connections"
CurrentISAPIExtensionRequests = "Current ISAPI Extension Requests"
CurrentNonAnonymousUsers = "Current NonAnonymous Users"
ServiceUptime = "Service Uptime"
TotalBytesReceived = "Total Bytes Received"
TotalBytesSent = "Total Bytes Sent"
TotalAnonymousUsers = "Total Anonymous Users"
TotalBlockedAsyncIORequests = "Total Blocked Async I/O Requests"
TotalCGIRequests = "Total CGI Requests"
TotalConnectionAttemptsAllInstances = "Total Connection Attempts (all instances)"
TotalFilesReceived = "Total Files Received"
TotalFilesSent = "Total Files Sent"
TotalISAPIExtensionRequests = "Total ISAPI Extension Requests"
TotalLockedErrors = "Total Locked Errors"
TotalLogonAttempts = "Total Logon Attempts"
TotalNonAnonymousUsers = "Total NonAnonymous Users"
TotalNotFoundErrors = "Total Not Found Errors"
TotalRejectedAsyncIORequests = "Total Rejected Async I/O Requests"
TotalCopyRequests = "Total Copy Requests"
TotalDeleteRequests = "Total Delete Requests"
TotalGetRequests = "Total Get Requests"
TotalHeadRequests = "Total Head Requests"
TotalLockRequests = "Total Lock Requests"
TotalMkcolRequests = "Total Mkcol Requests"
TotalMoveRequests = "Total Move Requests"
TotalOptionsRequests = "Total Options Requests"
TotalOtherRequests = "Total Other Request Methods"
TotalPostRequests = "Total Post Requests"
TotalPropfindRequests = "Total Propfind Requests"
TotalProppatchRequests = "Total Proppatch Requests"
TotalPutRequests = "Total Put Requests"
TotalSearchRequests = "Total Search Requests"
TotalTraceRequests = "Total Trace Requests"
TotalUnlockRequests = "Total Unlock Requests"
)
type perfDataCounterValuesWebService struct {
Name string
WebServiceCurrentAnonymousUsers float64 `perfdata:"Current Anonymous Users"`
WebServiceCurrentBlockedAsyncIORequests float64 `perfdata:"Current Blocked Async I/O Requests"`
WebServiceCurrentCGIRequests float64 `perfdata:"Current CGI Requests"`
WebServiceCurrentConnections float64 `perfdata:"Current Connections"`
WebServiceCurrentISAPIExtensionRequests float64 `perfdata:"Current ISAPI Extension Requests"`
WebServiceCurrentNonAnonymousUsers float64 `perfdata:"Current NonAnonymous Users"`
WebServiceServiceUptime float64 `perfdata:"Service Uptime"`
WebServiceTotalBytesReceived float64 `perfdata:"Total Bytes Received"`
WebServiceTotalBytesSent float64 `perfdata:"Total Bytes Sent"`
WebServiceTotalAnonymousUsers float64 `perfdata:"Total Anonymous Users"`
WebServiceTotalBlockedAsyncIORequests float64 `perfdata:"Total Blocked Async I/O Requests"`
WebServiceTotalCGIRequests float64 `perfdata:"Total CGI Requests"`
WebServiceTotalConnectionAttemptsAllInstances float64 `perfdata:"Total Connection Attempts (all instances)"`
WebServiceTotalFilesReceived float64 `perfdata:"Total Files Received"`
WebServiceTotalFilesSent float64 `perfdata:"Total Files Sent"`
WebServiceTotalISAPIExtensionRequests float64 `perfdata:"Total ISAPI Extension Requests"`
WebServiceTotalLockedErrors float64 `perfdata:"Total Locked Errors"`
WebServiceTotalLogonAttempts float64 `perfdata:"Total Logon Attempts"`
WebServiceTotalNonAnonymousUsers float64 `perfdata:"Total NonAnonymous Users"`
WebServiceTotalNotFoundErrors float64 `perfdata:"Total Not Found Errors"`
WebServiceTotalRejectedAsyncIORequests float64 `perfdata:"Total Rejected Async I/O Requests"`
WebServiceTotalCopyRequests float64 `perfdata:"Total Copy Requests"`
WebServiceTotalDeleteRequests float64 `perfdata:"Total Delete Requests"`
WebServiceTotalGetRequests float64 `perfdata:"Total Get Requests"`
WebServiceTotalHeadRequests float64 `perfdata:"Total Head Requests"`
WebServiceTotalLockRequests float64 `perfdata:"Total Lock Requests"`
WebServiceTotalMkcolRequests float64 `perfdata:"Total Mkcol Requests"`
WebServiceTotalMoveRequests float64 `perfdata:"Total Move Requests"`
WebServiceTotalOptionsRequests float64 `perfdata:"Total Options Requests"`
WebServiceTotalOtherRequests float64 `perfdata:"Total Other Request Methods"`
WebServiceTotalPostRequests float64 `perfdata:"Total Post Requests"`
WebServiceTotalPropfindRequests float64 `perfdata:"Total Propfind Requests"`
WebServiceTotalProppatchRequests float64 `perfdata:"Total Proppatch Requests"`
WebServiceTotalPutRequests float64 `perfdata:"Total Put Requests"`
WebServiceTotalSearchRequests float64 `perfdata:"Total Search Requests"`
WebServiceTotalTraceRequests float64 `perfdata:"Total Trace Requests"`
WebServiceTotalUnlockRequests float64 `perfdata:"Total Unlock Requests"`
}
func (p perfDataCounterValuesWebService) GetName() string {
return p.Name
}
func (c *Collector) buildWebService() error {
var err error
c.perfDataCollectorWebService, err = perfdata.NewCollector("Web Service", perfdata.InstanceAll, []string{
CurrentAnonymousUsers,
CurrentBlockedAsyncIORequests,
CurrentCGIRequests,
CurrentConnections,
CurrentISAPIExtensionRequests,
CurrentNonAnonymousUsers,
ServiceUptime,
TotalBytesReceived,
TotalBytesSent,
TotalAnonymousUsers,
TotalBlockedAsyncIORequests,
TotalCGIRequests,
TotalConnectionAttemptsAllInstances,
TotalFilesReceived,
TotalFilesSent,
TotalISAPIExtensionRequests,
TotalLockedErrors,
TotalLogonAttempts,
TotalNonAnonymousUsers,
TotalNotFoundErrors,
TotalRejectedAsyncIORequests,
TotalCopyRequests,
TotalDeleteRequests,
TotalGetRequests,
TotalHeadRequests,
TotalLockRequests,
TotalMkcolRequests,
TotalMoveRequests,
TotalOptionsRequests,
TotalOtherRequests,
TotalPostRequests,
TotalPropfindRequests,
TotalProppatchRequests,
TotalPutRequests,
TotalSearchRequests,
TotalTraceRequests,
TotalUnlockRequests,
})
c.perfDataCollectorWebService, err = pdh.NewCollector[perfDataCounterValuesWebService]("Web Service", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Web Service collector: %w", err)
}
c.currentAnonymousUsers = prometheus.NewDesc(
c.webServiceCurrentAnonymousUsers = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "current_anonymous_users"),
"Number of users who currently have an anonymous connection using the Web service (WebService.CurrentAnonymousUsers)",
[]string{"site"},
nil,
)
c.currentBlockedAsyncIORequests = prometheus.NewDesc(
c.webServiceCurrentBlockedAsyncIORequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "current_blocked_async_io_requests"),
"Current requests temporarily blocked due to bandwidth throttling settings (WebService.CurrentBlockedAsyncIORequests)",
[]string{"site"},
nil,
)
c.currentCGIRequests = prometheus.NewDesc(
c.webServiceCurrentCGIRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "current_cgi_requests"),
"Current number of CGI requests being simultaneously processed by the Web service (WebService.CurrentCGIRequests)",
[]string{"site"},
nil,
)
c.currentConnections = prometheus.NewDesc(
c.webServiceCurrentConnections = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "current_connections"),
"Current number of connections established with the Web service (WebService.CurrentConnections)",
[]string{"site"},
nil,
)
c.currentISAPIExtensionRequests = prometheus.NewDesc(
c.webServiceCurrentISAPIExtensionRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "current_isapi_extension_requests"),
"Current number of ISAPI requests being simultaneously processed by the Web service (WebService.CurrentISAPIExtensionRequests)",
[]string{"site"},
nil,
)
c.currentNonAnonymousUsers = prometheus.NewDesc(
c.webServiceCurrentNonAnonymousUsers = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "current_non_anonymous_users"),
"Number of users who currently have a non-anonymous connection using the Web service (WebService.CurrentNonAnonymousUsers)",
[]string{"site"},
nil,
)
c.serviceUptime = prometheus.NewDesc(
c.webServiceServiceUptime = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "service_uptime"),
"Number of seconds the WebService is up (WebService.ServiceUptime)",
[]string{"site"},
nil,
)
c.totalBytesReceived = prometheus.NewDesc(
c.webServiceTotalBytesReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "received_bytes_total"),
"Number of data bytes that have been received by the Web service (WebService.TotalBytesReceived)",
[]string{"site"},
nil,
)
c.totalBytesSent = prometheus.NewDesc(
c.webServiceTotalBytesSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "sent_bytes_total"),
"Number of data bytes that have been sent by the Web service (WebService.TotalBytesSent)",
[]string{"site"},
nil,
)
c.totalAnonymousUsers = prometheus.NewDesc(
c.webServiceTotalAnonymousUsers = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "anonymous_users_total"),
"Total number of users who established an anonymous connection with the Web service (WebService.TotalAnonymousUsers)",
[]string{"site"},
nil,
)
c.totalBlockedAsyncIORequests = prometheus.NewDesc(
c.webServiceTotalBlockedAsyncIORequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "blocked_async_io_requests_total"),
"Total requests temporarily blocked due to bandwidth throttling settings (WebService.TotalBlockedAsyncIORequests)",
[]string{"site"},
nil,
)
c.totalCGIRequests = prometheus.NewDesc(
c.webServiceTotalCGIRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "cgi_requests_total"),
"Total CGI requests is the total number of CGI requests (WebService.TotalCGIRequests)",
[]string{"site"},
nil,
)
c.totalConnectionAttemptsAllInstances = prometheus.NewDesc(
c.webServiceTotalConnectionAttemptsAllInstances = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "connection_attempts_all_instances_total"),
"Number of connections that have been attempted using the Web service (WebService.TotalConnectionAttemptsAllInstances)",
[]string{"site"},
nil,
)
c.totalRequests = prometheus.NewDesc(
c.webServiceTotalRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "requests_total"),
"Number of HTTP requests (WebService.TotalRequests)",
[]string{"site", "method"},
nil,
)
c.totalFilesReceived = prometheus.NewDesc(
c.webServiceTotalFilesReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "files_received_total"),
"Number of files received by the Web service (WebService.TotalFilesReceived)",
[]string{"site"},
nil,
)
c.totalFilesSent = prometheus.NewDesc(
c.webServiceTotalFilesSent = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "files_sent_total"),
"Number of files sent by the Web service (WebService.TotalFilesSent)",
[]string{"site"},
nil,
)
c.totalISAPIExtensionRequests = prometheus.NewDesc(
c.webServiceTotalISAPIExtensionRequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "ipapi_extension_requests_total"),
"ISAPI Extension Requests received (WebService.TotalISAPIExtensionRequests)",
[]string{"site"},
nil,
)
c.totalLockedErrors = prometheus.NewDesc(
c.webServiceTotalLockedErrors = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "locked_errors_total"),
"Number of requests that couldn't be satisfied by the server because the requested resource was locked (WebService.TotalLockedErrors)",
[]string{"site"},
nil,
)
c.totalLogonAttempts = prometheus.NewDesc(
c.webServiceTotalLogonAttempts = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "logon_attempts_total"),
"Number of logons attempts to the Web Service (WebService.TotalLogonAttempts)",
[]string{"site"},
nil,
)
c.totalNonAnonymousUsers = prometheus.NewDesc(
c.webServiceTotalNonAnonymousUsers = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "non_anonymous_users_total"),
"Number of users who established a non-anonymous connection with the Web service (WebService.TotalNonAnonymousUsers)",
[]string{"site"},
nil,
)
c.totalNotFoundErrors = prometheus.NewDesc(
c.webServiceTotalNotFoundErrors = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "not_found_errors_total"),
"Number of requests that couldn't be satisfied by the server because the requested document could not be found (WebService.TotalNotFoundErrors)",
[]string{"site"},
nil,
)
c.totalRejectedAsyncIORequests = prometheus.NewDesc(
c.webServiceTotalRejectedAsyncIORequests = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "rejected_async_io_requests_total"),
"Requests rejected due to bandwidth throttling settings (WebService.TotalRejectedAsyncIORequests)",
[]string{"site"},
@@ -260,254 +242,254 @@ func (c *Collector) buildWebService() error {
}
func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollectorWebService.Collect()
err := c.perfDataCollectorWebService.Collect(&c.perfDataObjectWebService)
if err != nil {
return fmt.Errorf("failed to collect Web Service metrics: %w", err)
}
deduplicateIISNames(perfData)
deduplicateIISNames(c.perfDataObjectWebService)
for name, app := range perfData {
if c.config.SiteExclude.MatchString(name) || !c.config.SiteInclude.MatchString(name) {
for _, data := range c.perfDataObjectWebService {
if c.config.SiteExclude.MatchString(data.Name) || !c.config.SiteInclude.MatchString(data.Name) {
continue
}
ch <- prometheus.MustNewConstMetric(
c.currentAnonymousUsers,
c.webServiceCurrentAnonymousUsers,
prometheus.GaugeValue,
app[CurrentAnonymousUsers].FirstValue,
name,
data.WebServiceCurrentAnonymousUsers,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.currentBlockedAsyncIORequests,
c.webServiceCurrentBlockedAsyncIORequests,
prometheus.GaugeValue,
app[CurrentBlockedAsyncIORequests].FirstValue,
name,
data.WebServiceCurrentBlockedAsyncIORequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.currentCGIRequests,
c.webServiceCurrentCGIRequests,
prometheus.GaugeValue,
app[CurrentCGIRequests].FirstValue,
name,
data.WebServiceCurrentCGIRequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.currentConnections,
c.webServiceCurrentConnections,
prometheus.GaugeValue,
app[CurrentConnections].FirstValue,
name,
data.WebServiceCurrentConnections,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.currentISAPIExtensionRequests,
c.webServiceCurrentISAPIExtensionRequests,
prometheus.GaugeValue,
app[CurrentISAPIExtensionRequests].FirstValue,
name,
data.WebServiceCurrentISAPIExtensionRequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.currentNonAnonymousUsers,
c.webServiceCurrentNonAnonymousUsers,
prometheus.GaugeValue,
app[CurrentNonAnonymousUsers].FirstValue,
name,
data.WebServiceCurrentNonAnonymousUsers,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.serviceUptime,
c.webServiceServiceUptime,
prometheus.GaugeValue,
app[ServiceUptime].FirstValue,
name,
data.WebServiceServiceUptime,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalBytesReceived,
c.webServiceTotalBytesReceived,
prometheus.CounterValue,
app[TotalBytesReceived].FirstValue,
name,
data.WebServiceTotalBytesReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalBytesSent,
c.webServiceTotalBytesSent,
prometheus.CounterValue,
app[TotalBytesSent].FirstValue,
name,
data.WebServiceTotalBytesSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalAnonymousUsers,
c.webServiceTotalAnonymousUsers,
prometheus.CounterValue,
app[TotalAnonymousUsers].FirstValue,
name,
data.WebServiceTotalAnonymousUsers,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalBlockedAsyncIORequests,
c.webServiceTotalBlockedAsyncIORequests,
prometheus.CounterValue,
app[TotalBlockedAsyncIORequests].FirstValue,
name,
data.WebServiceTotalBlockedAsyncIORequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalCGIRequests,
c.webServiceTotalCGIRequests,
prometheus.CounterValue,
app[TotalCGIRequests].FirstValue,
name,
data.WebServiceTotalCGIRequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalConnectionAttemptsAllInstances,
c.webServiceTotalConnectionAttemptsAllInstances,
prometheus.CounterValue,
app[TotalConnectionAttemptsAllInstances].FirstValue,
name,
data.WebServiceTotalConnectionAttemptsAllInstances,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalFilesReceived,
c.webServiceTotalFilesReceived,
prometheus.CounterValue,
app[TotalFilesReceived].FirstValue,
name,
data.WebServiceTotalFilesReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalFilesSent,
c.webServiceTotalFilesSent,
prometheus.CounterValue,
app[TotalFilesSent].FirstValue,
name,
data.WebServiceTotalFilesSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalISAPIExtensionRequests,
c.webServiceTotalISAPIExtensionRequests,
prometheus.CounterValue,
app[TotalISAPIExtensionRequests].FirstValue,
name,
data.WebServiceTotalISAPIExtensionRequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalLockedErrors,
c.webServiceTotalLockedErrors,
prometheus.CounterValue,
app[TotalLockedErrors].FirstValue,
name,
data.WebServiceTotalLockedErrors,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalLogonAttempts,
c.webServiceTotalLogonAttempts,
prometheus.CounterValue,
app[TotalLogonAttempts].FirstValue,
name,
data.WebServiceTotalLogonAttempts,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalNonAnonymousUsers,
c.webServiceTotalNonAnonymousUsers,
prometheus.CounterValue,
app[TotalNonAnonymousUsers].FirstValue,
name,
data.WebServiceTotalNonAnonymousUsers,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalNotFoundErrors,
c.webServiceTotalNotFoundErrors,
prometheus.CounterValue,
app[TotalNotFoundErrors].FirstValue,
name,
data.WebServiceTotalNotFoundErrors,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalRejectedAsyncIORequests,
c.webServiceTotalRejectedAsyncIORequests,
prometheus.CounterValue,
app[TotalRejectedAsyncIORequests].FirstValue,
name,
data.WebServiceTotalRejectedAsyncIORequests,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalOtherRequests].FirstValue,
name,
data.WebServiceTotalOtherRequests,
data.Name,
"other",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalCopyRequests].FirstValue,
name,
data.WebServiceTotalCopyRequests,
data.Name,
"COPY",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalDeleteRequests].FirstValue,
name,
data.WebServiceTotalDeleteRequests,
data.Name,
"DELETE",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalGetRequests].FirstValue,
name,
data.WebServiceTotalGetRequests,
data.Name,
"GET",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalHeadRequests].FirstValue,
name,
data.WebServiceTotalHeadRequests,
data.Name,
"HEAD",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalLockRequests].FirstValue,
name,
data.WebServiceTotalLockRequests,
data.Name,
"LOCK",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalMkcolRequests].FirstValue,
name,
data.WebServiceTotalMkcolRequests,
data.Name,
"MKCOL",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalMoveRequests].FirstValue,
name,
data.WebServiceTotalMoveRequests,
data.Name,
"MOVE",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalOptionsRequests].FirstValue,
name,
data.WebServiceTotalOptionsRequests,
data.Name,
"OPTIONS",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalPostRequests].FirstValue,
name,
data.WebServiceTotalPostRequests,
data.Name,
"POST",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalPropfindRequests].FirstValue,
name,
data.WebServiceTotalPropfindRequests,
data.Name,
"PROPFIND",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalProppatchRequests].FirstValue,
name,
data.WebServiceTotalProppatchRequests,
data.Name,
"PROPPATCH",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalPutRequests].FirstValue,
name,
data.WebServiceTotalPutRequests,
data.Name,
"PUT",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalSearchRequests].FirstValue,
name,
data.WebServiceTotalSearchRequests,
data.Name,
"SEARCH",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalTraceRequests].FirstValue,
name,
data.WebServiceTotalTraceRequests,
data.Name,
"TRACE",
)
ch <- prometheus.MustNewConstMetric(
c.totalRequests,
c.webServiceTotalRequests,
prometheus.CounterValue,
app[TotalUnlockRequests].FirstValue,
name,
data.WebServiceTotalUnlockRequests,
data.Name,
"UNLOCK",
)
}

Some files were not shown because too many files have changed in this diff Show More