Compare commits

...

84 Commits

Author SHA1 Message Date
Jan-Otto Kröpke
d451acbd63 [0.30] fix: Avoid COINIT_MULTITHREADED in CoInitializeEx (#2066) (#2091) 2025-06-21 11:29:06 +02:00
Jan-Otto Kröpke
7c14a79ef2 [0.30] service: report invalid parameter errors as debug (#2051) (#2092) 2025-06-21 11:28:48 +02:00
Jan-Otto Kröpke
3d7b16d61d [0.30] fix: added count checks (#2083) (#2089) 2025-06-21 11:28:30 +02:00
Jan-Otto Kröpke
a3131dc087 [0.30] logical_disk: skip unmounted volumes (#2084) (#2090)
Co-authored-by: Nic Jansma <nic@nicj.net>
2025-06-21 11:28:16 +02:00
Karl Persson
93940569fa update: export properties so that they can be read from yaml file (#2054) 2025-05-22 16:33:56 +02:00
Jan-Otto Kröpke
1e24d7b2c9 dns: add enhanced metrics (#1999) (#2040)
Co-authored-by: Matthew Wimpelberg <120263653+mwimpelberg28@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-17 14:15:07 +02:00
Jan-Otto Kröpke
109f537c14 terminal_services: Expose disconnected sessions agains (#2026) (#2039) 2025-05-17 14:14:54 +02:00
Jan-Otto Kröpke
62b796e6f6 exchange: fix The specified counter could not be found (#1994) (#2038) 2025-05-17 14:12:43 +02:00
Jan-Otto Kröpke
8bae1abe20 fix: Support running as Windows Service within containers [0.30.x] (#2009) 2025-04-24 10:57:58 +02:00
Jan-Otto Kröpke
db60c78f32 Release 0.30.6 (#1977) 2025-04-06 12:27:19 +02:00
Jan-Otto Kröpke
bdd7725f17 chore: CI fixes
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-04-06 12:21:00 +02:00
Jan-Otto Kröpke
9ed3769765 chore: CI fixes
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-04-06 12:08:43 +02:00
Jan-Otto Kröpke
aa7157e27c system: Metric windows_system_boot_time_timestamp returns a UNIX timestamp again. (#1967)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
(cherry picked from commit ba605cffcc)
2025-04-06 11:57:42 +02:00
Jan-Otto Kröpke
13d5e1cd12 chore: CI fixes
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-04-06 11:55:38 +02:00
Jan-Otto Kröpke
2c4698f119 [0.30] support web.listen-addr from CLI (#3)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
2025-04-06 03:36:58 +02:00
Jan-Otto Kröpke
759faee1c3 mssql: support initial non default instances names (#1958)
(cherry picked from commit fa8af098c8)
2025-04-06 03:33:45 +02:00
Jan-Otto Kröpke
50808c73fe logon: deprecate collector. Use terminal_services instead (#1957)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
(cherry picked from commit 0846c2805f)
2025-04-06 03:33:45 +02:00
Jan-Otto Kröpke
fe17f5f597 memory: fix panics if metrics does not exists (#1960)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>

(cherry picked from commit ecc805f0fa)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-04-06 03:33:45 +02:00
Jan-Otto Kröpke
b62c724977 service: fix windows.EnumServicesStatusEx reports buffer too small (#1954)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
(cherry picked from commit 63efa92be7)
2025-04-06 03:33:45 +02:00
Jan-Otto Kröpke
7252d403ae fix: return Windows 11 as product name, if build number is >= 22000 (#1935)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
(cherry picked from commit 041c2cd170)
2025-04-06 03:33:45 +02:00
Jan-Otto Kröpke
3180315cff hyperv: fix Windows Server 2016 compatibility (#1925)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
(cherry picked from commit bc1b40c679)
2025-04-06 03:33:45 +02:00
Jan-Otto Kröpke
9da6e56fcf fix: buffer length panic (#1936)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
(cherry picked from commit eecc6ce574)
2025-04-06 03:33:42 +02:00
Jan-Otto Kröpke
c300935170 fix: windows_cpu_processor_utility_total is always 0 (#1966)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>

(cherry picked from commit 9db4318ea9)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-04-05 22:23:53 +02:00
Jan-Otto Kröpke
6f0209ddb7 time: windows_time_clock_frequency_adjustment_ppb_total -> windows_time_clock_frequency_adjustment_ppb and add windows_time_clock_frequency_adjustment metric for Win2016 (#1910)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
(cherry picked from commit d6196c5c6b)
2025-04-04 23:18:14 +02:00
Jan-Otto Kröpke
a56e1ac71a fix: Support running as Windows Service within containers (#1907)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
(cherry picked from commit 3f2633d0b0)
2025-03-15 10:11:42 +01:00
Jan-Otto Kröpke
0c44a934f4 fix: update dependencies (#1920)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-03-11 10:46:14 +01:00
dependabot[bot]
d1151e91f3 chore(deps): bump github.com/prometheus/client_golang from 1.21.0 to 1.21.1 (#1919)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-10 15:52:45 +01:00
Jan-Otto Kröpke
cbe94c1ea5 netframework: fix metric names (re-add the collector sub-type to metrics) (#1908)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-03-01 17:22:59 +01:00
Jan-Otto Kröpke
b809f5a8ee docs: added examples for alternative installer dir (#1909)
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
2025-03-01 00:17:48 +01:00
dependabot[bot]
756d9c160d chore(deps): bump github.com/prometheus/client_golang from 1.21.0-rc.0 to 1.21.0 (#1899)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-01 00:09:41 +01:00
Jan-Otto Kröpke
a0e132b30e terminal_services: fix panic in collect (#1906) 2025-02-28 07:53:23 +01:00
Jan-Otto Kröpke
d645e89be9 ci: fix checksum (#1905) 2025-02-28 07:53:10 +01:00
Jan-Otto Kröpke
a73a08d704 fix: log to the Windows temp directory if of service detection failures. (#1890) 2025-02-28 01:35:41 +01:00
Jan-Otto Kröpke
228164765b docs: fix physical_disk docs (#1897) 2025-02-22 08:29:52 +00:00
Jan-Otto Kröpke
4c9c78c599 time: fix panic if counters aren't present (#1898) 2025-02-22 09:29:02 +01:00
Jan-Otto Kröpke
4b3c154049 docs: add disk activity query. (#1889)
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
2025-02-18 13:41:26 +01:00
Jan-Otto Kröpke
be0037eda5 ci: pin wix toolset version to avoid installing incompatible extensions (#1885)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-02-13 20:56:44 +01:00
Jan-Otto Kröpke
367fae95c4 mscluster: restore support for Windows Server 2016-2019 (#1882)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-02-12 21:03:24 +01:00
Jan-Otto Kröpke
96ffc3bf3f config: multiple web.listen-address args results into an error, if --config.file is defined. (#1876)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-02-12 20:30:12 +01:00
Jan-Otto Kröpke
285c4cc5ea feat: windows_exporter uses own event log source to correctly format messages. (#1873)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
2025-02-10 18:57:31 +01:00
Jan-Otto Kröpke
f07aceb0dd cs: fix metric description (#1881)
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-02-10 18:23:35 +01:00
Jan-Otto Kröpke
dcacce4577 fix: sign binaries (#1878)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-02-09 22:34:55 +01:00
Jan-Otto Kröpke
fc5b3051fa feat: sign binaries (#1875)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-02-08 20:04:37 +01:00
Jan-Otto Kröpke
1b2958a7cc fix: slow stop if run as service (#1870)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-02-07 22:26:09 +01:00
Jan-Otto Kröpke
a20e1854d1 netframework: fix MI_RESULT_INVALID_QUERY (#1862)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-02-02 09:14:56 +01:00
Jan-Otto Kröpke
fe21cb44f6 installer: add validation for EXTRA_FLAGS (#1867)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-02-02 09:14:45 +01:00
Jan-Otto Kröpke
71ec0bd6a3 process: negative values with windows_process_start_time (#1857)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-01-30 20:30:08 +01:00
dependabot[bot]
8bff623393 chore(deps): bump actions/stale from 9.0.0 to 9.1.0 (#1860) 2025-01-27 20:14:42 +01:00
dependabot[bot]
3eabd0a00c chore(deps): bump github.com/bmatcuk/doublestar/v4 from 4.8.0 to 4.8.1 (#1859) 2025-01-27 20:14:07 +01:00
Jan-Otto Kröpke
73186cde48 installer: force close application on uninstall (#1854)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-01-23 16:43:36 +01:00
Jan-Otto Kröpke
25e04fc947 service: re-use buffer for return all services (#1853)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-01-23 16:43:17 +01:00
Jan-Otto Kröpke
6b7201856c fix: process priority setting (#1852)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-01-23 14:56:49 +01:00
Jan-Otto Kröpke
608b83cfd8 config: deprecate remote http configuration (#1849)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-01-21 08:59:08 +01:00
Hamed Mansouri
40a42ca457 docs: fix typo in README.md (#1844)
Signed-off-by: Hamed Mansouri <hamed0381@gmail.com>
2025-01-21 00:47:03 +01:00
dependabot[bot]
423c8a787e chore(deps): bump golang.org/x/net from 0.32.0 to 0.33.0 (#1848)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-01-20 14:41:21 +00:00
dependabot[bot]
6cefbed7f7 chore(deps): bump github.com/bmatcuk/doublestar/v4 from 4.7.1 to 4.8.0 (#1846)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-01-20 15:35:43 +01:00
Jan-Otto Kröpke
5836a7dbf2 dhcp: add dhcp scope stats (#1840)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-01-20 12:03:03 +01:00
Jan-Otto Kröpke
d31ce0507c fix: Windows 11/Windows Server 2025 service compatibility (#1841)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-01-19 11:37:05 +01:00
Jan-Otto Kröpke
faa98d2708 Update LICENSE
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
2025-01-19 11:21:40 +01:00
Jan-Otto Kröpke
f0f3d0d96e net: fix sanitize # on the nic label for windows_net_nic_address_info (#1839)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-01-17 13:34:21 +01:00
Jan-Otto Kröpke
f73a74b678 netframework: add --collector.netframework.enabled CLI flag (#1833)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-01-15 21:23:50 +01:00
Jan-Otto Kröpke
b6f89ad92f docs: add CONTRIBUTING.md docs (#1834)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2025-01-15 21:23:42 +01:00
Jan-Otto Kröpke
86e6d12518 performancecounter: Add the possibility to request formatted values (#1830) 2025-01-14 23:32:44 +01:00
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
273 changed files with 12332 additions and 9878 deletions

View File

@@ -13,4 +13,4 @@ indent_size = 4
[*.{yml,yaml}]
indent_style = space
indent_size = 2
indent_size = 2

40
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,40 @@
<!--
Please give your PR a title in the form "area: short description". For example "cpu: reduce usage by 95%" or "docs: fix typo in installation.md".
If your PR is to fix an issue, put "Fixes #issue-number" in the description.
Don't forget!
- Please sign CNCF's Developer Certificate of Origin and sign-off your commits by adding the -s / --signoff flag to `git commit`. See https://github.com/apps/dco for more information.
- If the PR adds or changes a behaviour or fixes a bug of an exported API it would need a unit/e2e test.
- Performance improvements would need a benchmark test to prove it.
- All comments should start with a capital letter and end with a full stop.
-->
#### What this PR does / why we need it
#### Which issue this PR fixes
*(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
- fixes #
#### Special notes for your reviewer
#### Particularly user-facing changes
#### Checklist
Complete these before marking the PR as `ready to review`:
<!-- [Place an '[x]' (no spaces) in all applicable fields.] -->
- [ ] [DCO](https://github.com/prometheus-community/helm-charts/blob/main/CONTRIBUTING.md#sign-off-your-work) signed
- [ ] The PR title has a summary of the changes and the area they affect
- [ ] The PR body has a summary to reflect any significant (and particularly user-facing) changes introduced by this PR

View File

@@ -4,27 +4,13 @@ name: Linting
# have been changed.
on:
push:
paths:
- "go.mod"
- "go.sum"
- "**.go"
- ".github/workflows/lint.yml"
- "tools/e2e-output.txt"
branches:
- master
- next
- main
- "0.*"
- "1.*"
pull_request:
paths:
- "go.mod"
- "go.sum"
- "**.go"
- ".github/workflows/lint.yml"
- "tools/e2e-output.txt"
branches:
- master
- next
- main
env:
VERSION_PROMU: '0.14.0'
@@ -105,4 +91,4 @@ jobs:
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
args: "--max-same-issues=0"
args: "--max-same-issues=0"

View File

@@ -37,7 +37,7 @@ jobs:
- name: check
run: |
PR_TITLE_PREFIX=$(echo "$PR_TITLE" | cut -d':' -f1)
if [[ -d "internal/collector/$PR_TITLE_PREFIX" ]] || [[ -d "internal/$PR_TITLE_PREFIX" ]] || [[ -d "pkg/$PR_TITLE_PREFIX" ]] || [[ -d "$PR_TITLE_PREFIX" ]] || [[ "$PR_TITLE_PREFIX" == "docs" ]] || [[ "$PR_TITLE_PREFIX" == "ci" ]] || [[ "$PR_TITLE_PREFIX" == "revert" ]] || [[ "$PR_TITLE_PREFIX" == "fix" ]] || [[ "$PR_TITLE_PREFIX" == "feat" ]] || [[ "$PR_TITLE_PREFIX" == "chore" ]] || [[ "$PR_TITLE_PREFIX" == "chore(docs)" ]] || [[ "$PR_TITLE_PREFIX" == "chore(deps)" ]] || [[ "$PR_TITLE_PREFIX" == "*" ]] || [[ "$PR_TITLE_PREFIX" == "Synchronize common files from prometheus/prometheus" ]]; then
if [[ -d "internal/collector/$PR_TITLE_PREFIX" ]] || [[ -d "internal/$PR_TITLE_PREFIX" ]] || [[ -d "pkg/$PR_TITLE_PREFIX" ]] || [[ -d "$PR_TITLE_PREFIX" ]] || [[ "$PR_TITLE_PREFIX" == "docs" ]] || [[ "$PR_TITLE_PREFIX" == "ci" ]] || [[ "$PR_TITLE_PREFIX" == "revert" ]] || [[ "$PR_TITLE_PREFIX" == "fix" ]] || [[ "$PR_TITLE_PREFIX" == "fix(deps)" ]] || [[ "$PR_TITLE_PREFIX" == "feat" ]] || [[ "$PR_TITLE_PREFIX" == "chore" ]] || [[ "$PR_TITLE_PREFIX" == "chore(docs)" ]] || [[ "$PR_TITLE_PREFIX" == "chore(deps)" ]] || [[ "$PR_TITLE_PREFIX" == "*" ]] || [[ "$PR_TITLE_PREFIX" == "Release"* ]] || [[ "$PR_TITLE_PREFIX" == "Synchronize common files from prometheus/prometheus" ]]; then
exit 0
fi

View File

@@ -22,6 +22,7 @@ env:
jobs:
build:
runs-on: windows-2022
environment: build
steps:
- uses: actions/checkout@v4
with:
@@ -32,13 +33,14 @@ jobs:
go-version-file: 'go.mod'
- name: Install WiX
run: dotnet tool install --global wix
run: |
dotnet tool install --global wix --version 5.0.2
- name: Install WiX extensions
run: |
wix extension add -g WixToolset.Util.wixext
wix extension add -g WixToolset.Ui.wixext
wix extension add -g WixToolset.Firewall.wixext
wix extension add -g WixToolset.Util.wixext/5.0.2
wix extension add -g WixToolset.Ui.wixext/5.0.2
wix extension add -g WixToolset.Firewall.wixext/5.0.2
- name: Install Build deps
run: |
@@ -68,6 +70,40 @@ jobs:
Get-ChildItem -Path output
- name: Sign build artifacts
if: ${{ (github.event_name != 'pull_request' && github.repository == 'prometheus-community/windows_exporter') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'prometheus-community/windows_exporter') }}
run: |
$ErrorActionPreference = "Stop"
$Version = Get-Content VERSION
$b64 = $env:CODE_SIGN_KEY
$filename = 'windows_exporter_CodeSign.pfx'
$bytes = [Convert]::FromBase64String($b64)
[IO.File]::WriteAllBytes($filename, $bytes)
$basePath = "C:\Program Files (x86)\Windows Kits\10\bin"
$latestSigntool = Get-ChildItem -Path $basePath -Directory |
Where-Object { $_.Name -match "^\d+\.\d+\.\d+\.\d+$" } |
Sort-Object { [Version]$_.Name } -Descending |
Select-Object -First 1 |
ForEach-Object { Join-Path $_.FullName "x64\signtool.exe" }
if (Test-Path $latestSigntool) {
Write-Output $latestSigntool
} else {
Write-Output "signtool.exe not found"
}
foreach($Arch in "amd64", "arm64") {
& $latestSigntool sign /v /tr "http://timestamp.digicert.com" /d "Prometheus exporter for Windows machines" /td SHA256 /fd SHA256 /a /f "windows_exporter_CodeSign.pfx" /p $env:CODE_SIGN_PASSWORD "output\windows_exporter-$Version-$Arch.exe"
}
rm windows_exporter_CodeSign.pfx
env:
CODE_SIGN_KEY: ${{ secrets.CODE_SIGN_KEY }}
CODE_SIGN_PASSWORD: ${{ secrets.CODE_SIGN_PASSWORD }}
- name: Build Release Artifacts
run: |
$ErrorActionPreference = "Stop"
@@ -79,9 +115,46 @@ jobs:
}
Move-Item installer\*.msi output\
Get-ChildItem -Path output\
Get-ChildItem -Path output\ g
promu checksum output\
- name: Sign installer artifacts
if: ${{ (github.event_name != 'pull_request' && github.repository == 'prometheus-community/windows_exporter') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'prometheus-community/windows_exporter') }}
run: |
$ErrorActionPreference = "Stop"
$Version = Get-Content VERSION
$b64 = $env:CODE_SIGN_KEY
$filename = 'windows_exporter_CodeSign.pfx'
$bytes = [Convert]::FromBase64String($b64)
[IO.File]::WriteAllBytes($filename, $bytes)
$basePath = "C:\Program Files (x86)\Windows Kits\10\bin"
$latestSigntool = Get-ChildItem -Path $basePath -Directory |
Where-Object { $_.Name -match "^\d+\.\d+\.\d+\.\d+$" } |
Sort-Object { [Version]$_.Name } -Descending |
Select-Object -First 1 |
ForEach-Object { Join-Path $_.FullName "x64\signtool.exe" }
if (Test-Path $latestSigntool) {
Write-Output $latestSigntool
} else {
Write-Output "signtool.exe not found"
}
foreach($Arch in "amd64", "arm64") {
& $latestSigntool sign /v /tr "http://timestamp.digicert.com" /d "Prometheus exporter for Windows machines" /td SHA256 /fd SHA256 /a /f "windows_exporter_CodeSign.pfx" /p $env:CODE_SIGN_PASSWORD "output\windows_exporter-$Version-$Arch.msi"
}
rm windows_exporter_CodeSign.pfx
env:
CODE_SIGN_KEY: ${{ secrets.CODE_SIGN_KEY }}
CODE_SIGN_PASSWORD: ${{ secrets.CODE_SIGN_PASSWORD }}
- name: Generate checksums
run: |
promu checksum output
cat output\sha256sums.txt
- name: Upload Artifacts
uses: actions/upload-artifact@v4
@@ -103,6 +176,9 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
env:
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
steps:
- uses: actions/checkout@v4
with:
@@ -165,3 +241,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: windows/amd64
annotations: ${{ steps.meta.outputs.labels }}

View File

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

View File

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

View File

@@ -2,7 +2,7 @@
<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,perfdata,physical_disk,printer,process,remote_fx,scheduled_task,service,smb,smbclient,smtp,system,tcp,terminal_services,thermalzone,time,udp,update,vmware --debug.enabled" />
<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;type&quot;: &quot;formatted&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" />

82
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,82 @@
# Contributing
windows_exporter uses GitHub to manage reviews of pull requests.
* If you are a new contributor see: [Steps to Contribute](#steps-to-contribute)
* If you have a trivial fix or improvement, go ahead and create a pull request,
addressing (with `@...`) a suitable maintainer of this repository (see
[MAINTAINERS.md](MAINTAINERS.md)) in the description of the pull request.
* If you plan to do something more involved, first discuss your ideas
as [github issue](https://github.com/prometheus-community/windows_exporter/issues).
This will avoid unnecessary work and surely give you and us a good deal
of inspiration. New collectors are unlikely to be accepted, since the
`performancecounter` collector is the preferred way to collect metrics.
* Relevant coding style guidelines are the [Go Code Review
Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments)
and the _Formatting and style_ section of Peter Bourgon's [Go: Best
Practices for Production
Environments](https://peter.bourgon.org/go-in-production/#formatting-and-style).
gofmt and [golangci-lint](https://github.com/golangci/golangci-lint) are your friends.
* Be sure to sign off on the [DCO](https://github.com/probot/dco#how-it-works).
## Steps to Contribute
Should you wish to work on an issue, please claim it first by commenting on the GitHub issue that you want to work on it. This is to prevent duplicated efforts from contributors on the same issue.
For quickly compiling and testing your changes do:
```bash
# For building.
go build -o windows_exporter.exe ./cmd/windows_exporter/
./windows_exporter.exe
# For testing.
make test # Make sure all the tests pass before you commit and push :)
```
To run a collection of Go linters through [`golangci-lint`](https://github.com/golangci/golangci-lint), do:
```bash
make lint
```
If it reports an issue and you think that the warning needs to be disregarded or is a false-positive, you can add a special comment `//nolint:linter1[,linter2,...]` before the offending line. Use this sparingly though, fixing the code to comply with the linter's recommendation is in general the preferred course of action. See [this section of the golangci-lint documentation](https://golangci-lint.run/usage/false-positives/#nolint-directive) for more information.
All our issues are regularly tagged so that you can also filter down the issues involving the components you want to work on. For our labeling policy refer [the wiki page](https://github.com/prometheus/prometheus/wiki/Label-Names-and-Descriptions).
## Pull Request Checklist
* Branch from the main branch and, if needed, rebase to the current main branch before submitting your pull request. If it doesn't merge cleanly with main you may be asked to rebase your changes.
* Commits should be as small as possible, while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests).
* The PR title should be of the format: `subsystem: what this PR does` (for example, `cpu: Add support for thing` or `docs: fix typo`).
* If your patch is not getting reviewed or you need a specific person to review it, you can @-reply a reviewer asking for a review in the pull request or a comment.
* Add tests relevant to the fixed bug or new feature.
## Dependency management
The Prometheus project uses [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages.
To add or update a new dependency, use the `go get` command:
```bash
# Pick the latest tagged release.
go get example.com/some/module/pkg@latest
# Pick a specific version.
go get example.com/some/module/pkg@vX.Y.Z
```
Tidy up the `go.mod` and `go.sum` files:
```bash
# The GO111MODULE variable can be omitted when the code isn't located in GOPATH.
GO111MODULE=on go mod tidy
```
You have to commit the changes to `go.mod` and `go.sum` before submitting the pull request.

View File

@@ -1,6 +1,7 @@
The MIT License (MIT)
Copyright (c) 2016 Martin Lindhe
Copyright (c) 2021 The Prometheus Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -33,7 +33,6 @@ Name | Description | Enabled by default
[iis](docs/collector.iis.md) | IIS sites and applications |
[license](docs/collector.license.md) | Windows license status |
[logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | &#10003;
[logon](docs/collector.logon.md) | User logon sessions |
[memory](docs/collector.memory.md) | Memory usage metrics | &#10003;
[mscluster](docs/collector.mscluster.md) | MSCluster metrics |
[msmq](docs/collector.msmq.md) | MSMQ queues |
@@ -42,7 +41,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 |
@@ -88,7 +87,7 @@ windows_exporter accepts flags to configure certain behaviours. The ones configu
| `--web.listen-address` | host:port for exporter. | `:9182` |
| `--telemetry.path` | URL path for surfacing collected metrics. | `/metrics` |
| `--telemetry.max-requests` | Maximum number of concurrent requests. 0 to disable. | `5` |
| `--collectors.enabled` | Comma-separated list of collectors to use. Use `[defaults]` as a placeholder which gets expanded containing all the collectors enabled by default." | `[defaults]` |
| `--collectors.enabled` | Comma-separated list of collectors to use. Use `[defaults]` as a placeholder which gets expanded containing all the collectors enabled by default. | `[defaults]` |
| `--collectors.print` | If true, print available collectors and exit. | |
| `--scrape.timeout-margin` | Seconds to subtract from the timeout allowed by the client. Tune to allow for overhead or high loads. | `0.5` |
| `--web.config.file` | A [web config][web_config] for setting up TLS and Auth | None |
@@ -100,6 +99,9 @@ windows_exporter accepts flags to configure certain behaviours. The ones configu
The latest release can be downloaded from the [releases page](https://github.com/prometheus-community/windows_exporter/releases).
All binaries and installation packages are signed with an self-signed certificate. The public key can be found [here](https://github.com/prometheus-community/windows_exporter/blob/master/installer/codesign.cer).
Once import into the trusted root certificate store, the binaries and installation packages will be trusted.
Each release provides a .msi installer. The installer will setup the windows_exporter as a Windows service, as well as create an exception in the Windows Firewall.
If the installer is run without any parameters, the exporter will run with default settings for enabled collectors, ports, etc.
@@ -125,6 +127,8 @@ The following parameters are available:
| `EXTRA_FLAGS` | Allows passing full CLI flags. Defaults to an empty string. For `--collectors.enabled` and `--config.file`, use the specialized properties `ENABLED_COLLECTORS` and `CONFIG_FILE` |
| `ADDLOCAL` | Enables features within the windows_exporter installer. Supported values: `FirewallException` |
| `REMOVE` | Disables features within the windows_exporter installer. Supported values: `FirewallException` |
| `APPLICATIONFOLDER` | Directory to install windows_exporter. Defaults to `C:\Program Files\windows_exporter` |
Parameters are sent to the installer via `msiexec`.
On PowerShell, the `--%` should be passed before defining properties.
@@ -145,6 +149,11 @@ Define a config file.
msiexec /i <path-to-msi-file> --% CONFIG_FILE="D:\config.yaml"
```
Alternative install directory
```powershell
msiexec /i <path-to-msi-file> --% ADDLOCAL=FirewallException APPLICATIONFOLDER="F:\Program Files\windows_exporter"
```
On some older versions of Windows,
you may need to surround parameter values with double quotes to get the installation command parsing properly:
```powershell

View File

@@ -0,0 +1,209 @@
// Copyright 2025 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.
package main
import (
"errors"
"fmt"
"os"
"strings"
"unsafe"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/eventlog"
)
const serviceName = "windows_exporter"
//nolint:gochecknoglobals
var (
// exitCodeCh is a channel to send an exit code from the main function to the service manager.
// Additionally, if there is an error in the IsService var declaration,
// the exit code is sent to the service manager as well.
exitCodeCh = make(chan int, 1)
// stopCh is a channel to send a signal to the service manager that the service is stopping.
stopCh = make(chan struct{})
// serviceManagerFinishedCh is a channel to send a signal to the main function that the service manager has stopped the service.
serviceManagerFinishedCh = make(chan struct{}, 1)
)
// IsService variable declaration allows initiating time-sensitive components like registering the Windows service
// as early as possible in the startup process.
// init functions are called in the order they are declared, so this package should be imported first.
//
// Ref: https://github.com/prometheus-community/windows_exporter/issues/551#issuecomment-1220774835
//
// Declare imports on this package should be avoided where possible.
// var declaration run before init function, so it guarantees that windows_exporter respond to service manager early
// and avoid timeout.
// The order of the var declaration and init functions depends on the filename as well. The filename should be 0_service.go
// Ref: https://medium.com/@markbates/go-init-order-dafa89fcef22
//
//nolint:gochecknoglobals
var IsService = func() bool {
var err error
isService, err := isWindowsService()
if err != nil {
logToFile(fmt.Sprintf("failed to detect service: %v", err))
return false
}
if !isService {
return false
}
defer func() {
go func() {
err := svc.Run(serviceName, &windowsExporterService{})
if err != nil {
// https://github.com/open-telemetry/opentelemetry-collector/pull/9042
if !errors.Is(err, windows.ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
if logErr := logToEventToLog(windows.EVENTLOG_ERROR_TYPE, fmt.Sprintf("failed to start service: %v", err)); logErr != nil {
logToFile(fmt.Sprintf("failed to start service: %v", err))
}
}
}
serviceManagerFinishedCh <- struct{}{}
}()
}()
if err := logToEventToLog(windows.EVENTLOG_INFORMATION_TYPE, "attempting to start exporter service"); err != nil {
logToFile(fmt.Sprintf("failed sent log to event log: %v", err))
exitCodeCh <- 2
}
return true
}()
type windowsExporterService struct{}
// Execute is the entry point for the Windows service manager.
func (s *windowsExporterService) Execute(_ []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (bool, uint32) {
changes <- svc.Status{State: svc.StartPending}
changes <- svc.Status{State: svc.Running, Accepts: svc.AcceptStop | svc.AcceptShutdown}
for {
select {
case exitCodeCh := <-exitCodeCh:
// Stop the service if an exit code from the main function is received.
changes <- svc.Status{State: svc.StopPending}
return true, uint32(exitCodeCh)
case c := <-r:
// Handle the service control request.
switch c.Cmd {
case svc.Interrogate:
changes <- c.CurrentStatus
case svc.Stop, svc.Shutdown:
// Stop the service if a stop or shutdown request is received.
_ = logToEventToLog(windows.EVENTLOG_INFORMATION_TYPE, "service stop received")
changes <- svc.Status{State: svc.StopPending}
// Send a signal to the main function to stop the service.
stopCh <- struct{}{}
// Wait for the main function to stop the service.
return false, uint32(<-exitCodeCh)
default:
_ = logToEventToLog(windows.EVENTLOG_ERROR_TYPE, fmt.Sprintf("unexpected control request #%d", c))
}
}
}
}
// logToEventToLog logs a message to the Windows event log.
func logToEventToLog(eType uint16, msg string) error {
eventLog, err := eventlog.Open(serviceName)
if err != nil {
return fmt.Errorf("failed to open event log: %w", err)
}
defer func(eventLog *eventlog.Log) {
_ = eventLog.Close()
}(eventLog)
switch eType {
case windows.EVENTLOG_ERROR_TYPE:
err = eventLog.Error(102, msg)
case windows.EVENTLOG_WARNING_TYPE:
err = eventLog.Warning(101, msg)
case windows.EVENTLOG_INFORMATION_TYPE:
err = eventLog.Info(100, msg)
}
if err != nil {
return fmt.Errorf("error report event: %w", err)
}
return nil
}
func logToFile(msg string) {
if file, err := os.CreateTemp("", "windows_exporter.service.error.log"); err == nil {
_, _ = file.WriteString(msg)
_ = file.Close()
}
}
// isWindowsService is a clone of "golang.org/x/sys/windows/svc:IsWindowsService", but with a fix
// for Windows containers.
// Go cloned the .NET implementation of this function, which has since
// been patched to support Windows containers, which don't use Session ID 0 for services.
// https://github.com/dotnet/runtime/pull/74188
// This function can be replaced with go's once go brings in the fix.
//
// Copyright 2023-present Datadog, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// https://github.com/DataDog/datadog-agent/blob/46740e82ef40a04c4be545ed8c16a4b0d1f046cf/pkg/util/winutil/servicemain/servicemain.go#L128
func isWindowsService() (bool, error) {
var currentProcess windows.PROCESS_BASIC_INFORMATION
infoSize := uint32(unsafe.Sizeof(currentProcess))
err := windows.NtQueryInformationProcess(windows.CurrentProcess(), windows.ProcessBasicInformation, unsafe.Pointer(&currentProcess), infoSize, &infoSize)
if err != nil {
return false, err
}
var parentProcess *windows.SYSTEM_PROCESS_INFORMATION
for infoSize = uint32((unsafe.Sizeof(*parentProcess) + unsafe.Sizeof(uintptr(0))) * 1024); ; {
parentProcess = (*windows.SYSTEM_PROCESS_INFORMATION)(unsafe.Pointer(&make([]byte, infoSize)[0]))
err = windows.NtQuerySystemInformation(windows.SystemProcessInformation, unsafe.Pointer(parentProcess), infoSize, &infoSize)
if err == nil {
break
} else if !errors.Is(err, windows.STATUS_INFO_LENGTH_MISMATCH) {
return false, err
}
}
for ; ; parentProcess = (*windows.SYSTEM_PROCESS_INFORMATION)(unsafe.Pointer(uintptr(unsafe.Pointer(parentProcess)) + uintptr(parentProcess.NextEntryOffset))) {
if parentProcess.UniqueProcessID == currentProcess.InheritedFromUniqueProcessId {
return strings.EqualFold("services.exe", parentProcess.ImageName.String()), nil
}
if parentProcess.NextEntryOffset == 0 {
break
}
}
return false, nil
}

View File

@@ -17,12 +17,7 @@
package main
//goland:noinspection GoUnsortedImport
//nolint:gofumpt
import (
// Its important that we do these first so that we can register with the Windows service control ASAP to avoid timeouts.
"github.com/prometheus-community/windows_exporter/internal/windowsservice"
"context"
"errors"
"fmt"
@@ -33,6 +28,7 @@ import (
"os/signal"
"os/user"
"runtime"
"runtime/debug"
"slices"
"strings"
"time"
@@ -51,20 +47,24 @@ import (
)
func main() {
exitCode := run()
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
exitCode := run(ctx, os.Args[1:])
stop()
// If we are running as a service, we need to signal the service control manager that we are done.
if !windowsservice.IsService {
if !IsService {
os.Exit(exitCode)
}
windowsservice.ExitCodeCh <- exitCode
exitCodeCh <- exitCode
// Wait for the service control manager to signal that we are done.
<-windowsservice.StopCh
<-serviceManagerFinishedCh
}
func run() int {
func run(ctx context.Context, args []string) int {
startTime := time.Now()
app := kingpin.New("windows_exporter", "A metrics collector for Windows.")
@@ -74,7 +74,7 @@ func run() int {
"config.file",
"YAML configuration file to use. Values set in this file will be overridden by CLI flags.",
).String()
insecureSkipVerify = app.Flag(
_ = app.Flag(
"config.file.insecure-skip-verify",
"Skip TLS verification in loading YAML configuration.",
).Default("false").Bool()
@@ -103,12 +103,16 @@ 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()
)
logFile := &log.AllowedFile{}
_ = logFile.Set("stdout")
if windowsservice.IsService {
if IsService {
_ = logFile.Set("eventlog")
}
@@ -121,74 +125,35 @@ func run() int {
// Initialize collectors before loading and parsing CLI arguments
collectors := collector.NewWithFlags(app)
// Load values from configuration file(s). Executable flags must first be parsed, in order
// to load the specified file(s).
if _, err := app.Parse(os.Args[1:]); err != nil {
//nolint:contextcheck
if err := config.Parse(app, args); err != nil {
//nolint:sloglint // we do not have an logger yet
slog.Error("Failed to parse CLI args",
slog.LogAttrs(ctx, slog.LevelError, "Failed to load configuration",
slog.Any("err", err),
)
return 1
}
debug.SetMemoryLimit(*memoryLimit)
logger, err := log.New(logConfig)
if err != nil {
//nolint:sloglint // we do not have an logger yet
slog.Error("failed to create logger",
logger.LogAttrs(ctx, slog.LevelError, "failed to create logger",
slog.Any("err", err),
)
return 1
}
if *configFile != "" {
resolver, err := config.NewResolver(*configFile, logger, *insecureSkipVerify)
if err != nil {
logger.Error("could not load config file",
slog.Any("err", err),
)
return 1
}
if err = resolver.Bind(app, os.Args[1:]); err != nil {
logger.Error("Failed to bind configuration",
slog.Any("err", err),
)
return 1
}
// NOTE: This is temporary fix for issue #1092, calling kingpin.Parse
// twice makes slices flags duplicate its value, this clean up
// the first parse before the second call.
*webConfig.WebListenAddresses = (*webConfig.WebListenAddresses)[1:]
// 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",
slog.Any("err", err),
)
return 1
}
logger, err = log.New(logConfig)
if err != nil {
//nolint:sloglint // we do not have an logger yet
slog.Error("failed to create logger",
slog.Any("err", err),
)
return 1
}
if configFile != nil && *configFile != "" {
logger.InfoContext(ctx, "using configuration file: "+*configFile)
}
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",
if err = setPriorityWindows(ctx, logger, os.Getpid(), *processPriority); err != nil {
logger.LogAttrs(ctx, slog.LevelError, "failed to set process priority",
slog.Any("err", err),
)
@@ -197,7 +162,7 @@ func run() int {
enabledCollectorList := expandEnabledCollectors(*enabledCollectors)
if err := collectors.Enable(enabledCollectorList); err != nil {
logger.Error("couldn't enable collectors",
logger.LogAttrs(ctx, slog.LevelError, "couldn't enable collectors",
slog.Any("err", err),
)
@@ -205,17 +170,19 @@ func run() int {
}
// Initialize collectors before loading
if err = collectors.Build(logger); err != nil {
if err = collectors.Build(ctx, logger); err != nil {
for _, err := range utils.SplitError(err) {
logger.Warn("couldn't initialize collector",
logger.LogAttrs(ctx, slog.LevelError, "couldn't initialize collector",
slog.Any("err", err),
)
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())
@@ -233,7 +200,7 @@ func run() int {
mux.HandleFunc("GET /debug/pprof/trace", pprof.Trace)
}
logger.Info(fmt.Sprintf("starting windows_exporter in %s", time.Since(startTime)),
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()),
@@ -260,17 +227,14 @@ func run() int {
close(errCh)
}()
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
defer stop()
select {
case <-ctx.Done():
logger.Info("Shutting down windows_exporter via kill signal")
case <-windowsservice.StopCh:
logger.Info("Shutting down windows_exporter via service control")
logger.LogAttrs(ctx, slog.LevelInfo, "Shutting down windows_exporter via kill signal")
case <-stopCh:
logger.LogAttrs(ctx, slog.LevelInfo, "Shutting down windows_exporter via service control")
case err := <-errCh:
if err != nil {
logger.Error("Failed to start windows_exporter",
logger.LogAttrs(ctx, slog.LevelError, "Failed to start windows_exporter",
slog.Any("err", err),
)
@@ -281,9 +245,9 @@ func run() int {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_ = server.Shutdown(ctx)
_ = server.Shutdown(ctx) //nolint:contextcheck // create a new context for server shutdown
logger.Info("windows_exporter has shut down")
logger.LogAttrs(ctx, slog.LevelInfo, "windows_exporter has shut down") //nolint:contextcheck
return 0
}
@@ -306,7 +270,7 @@ func logCurrentUser(logger *slog.Logger) {
}
// setPriorityWindows sets the priority of the current process to the specified value.
func setPriorityWindows(logger *slog.Logger, pid int, priority string) error {
func setPriorityWindows(ctx context.Context, logger *slog.Logger, pid int, priority string) error {
// Mapping of priority names to uin32 values required by windows.SetPriorityClass.
priorityStringToInt := map[string]uint32{
"realtime": windows.REALTIME_PRIORITY_CLASS,
@@ -320,11 +284,11 @@ func setPriorityWindows(logger *slog.Logger, pid int, priority string) error {
winPriority, ok := priorityStringToInt[priority]
// Only set process priority if a non-default and valid value has been set
if !ok || winPriority != windows.NORMAL_PRIORITY_CLASS {
if !ok || winPriority == windows.NORMAL_PRIORITY_CLASS {
return nil
}
logger.Debug("setting process priority to " + priority)
logger.LogAttrs(ctx, 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(

View File

@@ -0,0 +1,188 @@
// 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 main
import (
"context"
"errors"
"fmt"
"io"
"net"
"net/http"
"net/url"
"os"
"strings"
"testing"
"time"
"github.com/stretchr/testify/require"
"golang.org/x/sys/windows"
)
//nolint:tparallel
func TestRun(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
args []string
config string
metricsEndpoint string
exitCode int
}{
{
name: "default",
args: []string{},
metricsEndpoint: "http://127.0.0.1:9182/metrics",
},
{
name: "web.listen-address",
args: []string{"--web.listen-address=127.0.0.1:8080"},
metricsEndpoint: "http://127.0.0.1:8080/metrics",
},
{
name: "web.listen-address",
args: []string{"--web.listen-address=127.0.0.1:8081", "--web.listen-address=[::1]:8081"},
metricsEndpoint: "http://[::1]:8081/metrics",
},
{
name: "config",
args: []string{"--config.file=config.yaml"},
config: `{"web":{"listen-address":"127.0.0.1:8082"}}`,
metricsEndpoint: "http://127.0.0.1:8082/metrics",
},
{
name: "web.listen-address with config",
args: []string{"--config.file=config.yaml", "--web.listen-address=127.0.0.1:8084"},
config: `{"web":{"listen-address":"127.0.0.1:8083"}}`,
metricsEndpoint: "http://127.0.0.1:8084/metrics",
},
} {
t.Run(tc.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if tc.config != "" {
// Create a temporary config file.
tmpfile, err := os.CreateTemp(t.TempDir(), "config-*.yaml")
require.NoError(t, err)
t.Cleanup(func() {
require.NoError(t, tmpfile.Close())
})
_, err = tmpfile.WriteString(tc.config)
require.NoError(t, err)
for i, arg := range tc.args {
tc.args[i] = strings.ReplaceAll(arg, "config.yaml", tmpfile.Name())
}
}
exitCodeCh := make(chan int)
var stdout string
go func() {
stdout = captureOutput(t, func() {
// Simulate the service control manager signaling that we are done.
exitCodeCh <- run(ctx, tc.args)
})
}()
t.Cleanup(func() {
select {
case exitCode := <-exitCodeCh:
require.Equal(t, tc.exitCode, exitCode)
case <-time.After(2 * time.Second):
t.Fatalf("timed out waiting for exit code, want %d", tc.exitCode)
}
})
if tc.exitCode != 0 {
return
}
uri, err := url.Parse(tc.metricsEndpoint)
require.NoError(t, err)
err = waitUntilListening(t, "tcp", uri.Host)
require.NoError(t, err, "LOGS:\n%s", stdout)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, tc.metricsEndpoint, nil)
require.NoError(t, err)
resp, err := http.DefaultClient.Do(req)
require.NoError(t, err, "LOGS:\n%s", stdout)
require.Equal(t, http.StatusOK, resp.StatusCode)
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
err = resp.Body.Close()
require.NoError(t, err)
require.NotEmpty(t, body)
require.Contains(t, string(body), "# HELP windows_exporter_build_info")
cancel()
})
}
}
func captureOutput(tb testing.TB, f func()) string {
tb.Helper()
orig := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
f()
os.Stdout = orig
_ = w.Close()
out, _ := io.ReadAll(r)
return string(out)
}
func waitUntilListening(tb testing.TB, network, address string) error {
tb.Helper()
var (
conn net.Conn
err error
)
for range 10 {
conn, err = net.DialTimeout(network, address, 100*time.Millisecond)
if err == nil {
_ = conn.Close()
return nil
}
if errors.Is(err, windows.Errno(10061)) {
time.Sleep(50 * time.Millisecond)
continue
}
}
return fmt.Errorf("listener not listening: %w", err)
}

View File

@@ -1,9 +1,2 @@
# 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
collector:
service:
include: "windows_exporter"
log:
level: warn
web:
listen-address: ":9183"

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

@@ -2,49 +2,177 @@
The dhcp collector exposes DHCP Server metrics
|||
-|-
Metric name prefix | `dhcp`
Data source | Perflib
Classes | `DHCP Server`
Enabled by default? | No
| | |
|---------------------|---------------|
| Metric name prefix | `dhcp` |
| Data source | Perflib |
| Classes | `DHCP Server` |
| Enabled by default? | No |
## Flags
None
### `--collector.dhcp.enabled`
Comma-separated list of collectors to use. Defaults to all, if not specified.
## Metrics
Name | Description | Type | Labels
-----|-------------|------|-------
`packets_received_total` | Total number of packets received by the DHCP server | counter | None
`duplicates_dropped_total` | Total number of duplicate packets received by the DHCP server | counter | None
`packets_expired_total` | Total number of packets expired in the DHCP server message queue | counter | None
`active_queue_length` | Number of packets in the processing queue of the DHCP server | gauge | None
`conflict_check_queue_length` | Number of packets in the DHCP server queue waiting on conflict detection (ping) | gauge | None
`discovers_total` | Total DHCP Discovers received by the DHCP server | counter | None
`offers_total` | Total DHCP Offers sent by the DHCP server | counter | None
`requests_total` | Total DHCP Requests received by the DHCP server | counter | None
`informs_total` | Total DHCP Informs received by the DHCP server | counter | None
`acks_total` | Total DHCP Acks sent by the DHCP server | counter | None
`nacks_total` | Total DHCP Nacks sent by the DHCP server | counter | None
`declines_total` | Total DHCP Declines received by the DHCP server | counter | None
`releases_total` | Total DHCP Releases received by the DHCP server | counter | None
`offer_queue_length` | Number of packets in the offer queue of the DHCP server | gauge | None
`denied_due_to_match_total` | Total number of DHCP requests denied, based on matches from the Deny List | gauge | None
`denied_due_to_nonmatch_total` | Total number of DHCP requests denied, based on non-matches from the Allow List | gauge | None
`failover_bndupd_sent_total` | Number of DHCP failover Binding Update messages sent | counter | None
`failover_bndupd_received_total` | Number of DHCP failover Binding Update messages received | counter | None
`failover_bndack_sent_total` | Number of DHCP failover Binding Ack messages sent | counter | None
`failover_bndack_received_total` | Number of DHCP failover Binding Ack messages received | counter | None
`failover_bndupd_pending_in_outbound_queue` | Number of pending outbound DHCP failover Binding Update messages | counter | None
`failover_transitions_communicationinterrupted_state_total` | Total number of transitions into COMMUNICATION INTERRUPTED state | counter | None
`failover_transitions_partnerdown_state_total` | Total number of transitions into PARTNER DOWN state | counter | None
`failover_transitions_recover_total` | Total number of transitions into RECOVER state | counter | None
`failover_bndupd_dropped_total` | Total number of DHCP faileover Binding Updates dropped | counter | None
| Name | Description | Type | Labels |
|--------------------------------------------------------------------------|--------------------------------------------------------------------------------|---------|-----------------------------------------------------|
| `windows_dhcp_ack_total` | Total DHCP Acks sent by the DHCP server | counter | None |
| `windows_dhcp_denied_due_to_match_total` | Total number of DHCP requests denied, based on matches from the Deny List | gauge | None |
| `windows_dhcp_denied_due_to_nonmatch_total` | Total number of DHCP requests denied, based on non-matches from the Allow List | gauge | None |
| `windows_dhcp_declines_total` | Total DHCP Declines received by the DHCP server | counter | None |
| `windows_dhcp_discovers_total` | Total DHCP Discovers received by the DHCP server | counter | None |
| `windows_dhcp_failover_bndack_received_total` | Number of DHCP failover Binding Ack messages received | counter | None |
| `windows_dhcp_failover_bndack_sent_total` | Number of DHCP failover Binding Ack messages sent | counter | None |
| `windows_dhcp_failover_bndupd_dropped_total` | Total number of DHCP failover Binding Updates dropped | counter | None |
| `windows_dhcp_failover_bndupd_received_total` | Number of DHCP failover Binding Update messages received | counter | None |
| `windows_dhcp_failover_bndupd_sent_total` | Number of DHCP failover Binding Update messages sent | counter | None |
| `windows_dhcp_failover_bndupd_pending_in_outbound_queue` | Number of pending outbound DHCP failover Binding Update messages | counter | None |
| `windows_dhcp_failover_transitions_communicationinterrupted_state_total` | Total number of transitions into COMMUNICATION INTERRUPTED state | counter | None |
| `windows_dhcp_failover_transitions_partnerdown_state_total` | Total number of transitions into PARTNER DOWN state | counter | None |
| `windows_dhcp_failover_transitions_recover_total` | Total number of transitions into RECOVER state | counter | None |
| `windows_dhcp_informs_total` | Total DHCP Informs received by the DHCP server | counter | None |
| `windows_dhcp_nacks_total` | Total DHCP Nacks sent by the DHCP server | counter | None |
| `windows_dhcp_offers_total` | Total DHCP Offers sent by the DHCP server | counter | None |
| `windows_dhcp_packets_expired_total` | Total number of packets expired in the DHCP server message queue | counter | None |
| `windows_dhcp_packets_received_total` | Total number of packets received by the DHCP server | counter | None |
| `windows_dhcp_pending_offers_total` | Total number of pending offers in the DHCP server | counter | None |
| `windows_dhcp_releases_total` | Total DHCP Releases received by the DHCP server | counter | None |
| `windows_dhcp_requests_total` | Total DHCP Requests received by the DHCP server | counter | None |
| `windows_dhcp_scope_addresses_free_on_this_server` | DHCP Scope free addresses on this server | gauge | `scope` |
| `windows_dhcp_scope_addresses_free_on_partner_server` | DHCP Scope free addresses on partner server | gauge | `scope` |
| `windows_dhcp_scope_addresses_free` | DHCP Scope free addresses | gauge | `scope` |
| `windows_dhcp_scope_addresses_in_use_on_this_server` | DHCP Scope addresses in use on this server | gauge | `scope` |
| `windows_dhcp_scope_addresses_in_use_on_partner_server` | DHCP Scope addresses in use on partner server | gauge | `scope` |
| `windows_dhcp_scope_addresses_in_use` | DHCP Scope addresses in use | gauge | `scope` |
| `windows_dhcp_scope_info` | DHCP Scope information | gauge | `name`, `superscope_name`, `superscope_id`, `scope` |
| `windows_dhcp_scope_pending_offers` | DHCP Scope pending offers | gauge | `scope` |
| `windows_dhcp_scope_reserved_address` | DHCP Scope reserved addresses | gauge | `scope` |
| `windows_dhcp_scope_state` | DHCP Scope state | gauge | `scope`, `state` |
### Example metric
_This collector does not yet have explained examples, we would appreciate your help adding them!_
```
# HELP windows_dhcp_acks_total Total DHCP Acks sent by the DHCP server (AcksTotal)
# TYPE windows_dhcp_acks_total counter
windows_dhcp_acks_total 0
# HELP windows_dhcp_active_queue_length Number of packets in the processing queue of the DHCP server (ActiveQueueLength)
# TYPE windows_dhcp_active_queue_length gauge
windows_dhcp_active_queue_length 0
# HELP windows_dhcp_conflict_check_queue_length Number of packets in the DHCP server queue waiting on conflict detection (ping). (ConflictCheckQueueLength)
# TYPE windows_dhcp_conflict_check_queue_length gauge
windows_dhcp_conflict_check_queue_length 0
# HELP windows_dhcp_declines_total Total DHCP Declines received by the DHCP server (DeclinesTotal)
# TYPE windows_dhcp_declines_total counter
windows_dhcp_declines_total 0
# HELP windows_dhcp_denied_due_to_match_total Total number of DHCP requests denied, based on matches from the Deny list (DeniedDueToMatch)
# TYPE windows_dhcp_denied_due_to_match_total counter
windows_dhcp_denied_due_to_match_total 0
# HELP windows_dhcp_denied_due_to_nonmatch_total Total number of DHCP requests denied, based on non-matches from the Allow list (DeniedDueToNonMatch)
# TYPE windows_dhcp_denied_due_to_nonmatch_total counter
windows_dhcp_denied_due_to_nonmatch_total 0
# HELP windows_dhcp_discovers_total Total DHCP Discovers received by the DHCP server (DiscoversTotal)
# TYPE windows_dhcp_discovers_total counter
windows_dhcp_discovers_total 0
# HELP windows_dhcp_duplicates_dropped_total Total number of duplicate packets received by the DHCP server (DuplicatesDroppedTotal)
# TYPE windows_dhcp_duplicates_dropped_total counter
windows_dhcp_duplicates_dropped_total 0
# HELP windows_dhcp_failover_bndack_received_total Number of DHCP fail over Binding Ack messages received (FailoverBndackReceivedTotal)
# TYPE windows_dhcp_failover_bndack_received_total counter
windows_dhcp_failover_bndack_received_total 0
# HELP windows_dhcp_failover_bndack_sent_total Number of DHCP fail over Binding Ack messages sent (FailoverBndackSentTotal)
# TYPE windows_dhcp_failover_bndack_sent_total counter
windows_dhcp_failover_bndack_sent_total 0
# HELP windows_dhcp_failover_bndupd_dropped_total Total number of DHCP fail over Binding Updates dropped (FailoverBndupdDropped)
# TYPE windows_dhcp_failover_bndupd_dropped_total counter
windows_dhcp_failover_bndupd_dropped_total 0
# HELP windows_dhcp_failover_bndupd_pending_in_outbound_queue Number of pending outbound DHCP fail over Binding Update messages (FailoverBndupdPendingOutboundQueue)
# TYPE windows_dhcp_failover_bndupd_pending_in_outbound_queue gauge
windows_dhcp_failover_bndupd_pending_in_outbound_queue 0
# HELP windows_dhcp_failover_bndupd_received_total Number of DHCP fail over Binding Update messages received (FailoverBndupdReceivedTotal)
# TYPE windows_dhcp_failover_bndupd_received_total counter
windows_dhcp_failover_bndupd_received_total 0
# HELP windows_dhcp_failover_bndupd_sent_total Number of DHCP fail over Binding Update messages sent (FailoverBndupdSentTotal)
# TYPE windows_dhcp_failover_bndupd_sent_total counter
windows_dhcp_failover_bndupd_sent_total 0
# HELP windows_dhcp_failover_transitions_communicationinterrupted_state_total Total number of transitions into COMMUNICATION INTERRUPTED state (FailoverTransitionsCommunicationinterruptedState)
# TYPE windows_dhcp_failover_transitions_communicationinterrupted_state_total counter
windows_dhcp_failover_transitions_communicationinterrupted_state_total 0
# HELP windows_dhcp_failover_transitions_partnerdown_state_total Total number of transitions into PARTNER DOWN state (FailoverTransitionsPartnerdownState)
# TYPE windows_dhcp_failover_transitions_partnerdown_state_total counter
windows_dhcp_failover_transitions_partnerdown_state_total 0
# HELP windows_dhcp_failover_transitions_recover_total Total number of transitions into RECOVER state (FailoverTransitionsRecoverState)
# TYPE windows_dhcp_failover_transitions_recover_total counter
windows_dhcp_failover_transitions_recover_total 0
# HELP windows_dhcp_informs_total Total DHCP Informs received by the DHCP server (InformsTotal)
# TYPE windows_dhcp_informs_total counter
windows_dhcp_informs_total 0
# HELP windows_dhcp_nacks_total Total DHCP Nacks sent by the DHCP server (NacksTotal)
# TYPE windows_dhcp_nacks_total counter
windows_dhcp_nacks_total 0
# HELP windows_dhcp_offer_queue_length Number of packets in the offer queue of the DHCP server (OfferQueueLength)
# TYPE windows_dhcp_offer_queue_length gauge
windows_dhcp_offer_queue_length 0
# HELP windows_dhcp_offers_total Total DHCP Offers sent by the DHCP server (OffersTotal)
# TYPE windows_dhcp_offers_total counter
windows_dhcp_offers_total 0
# HELP windows_dhcp_packets_expired_total Total number of packets expired in the DHCP server message queue (PacketsExpiredTotal)
# TYPE windows_dhcp_packets_expired_total counter
windows_dhcp_packets_expired_total 0
# HELP windows_dhcp_packets_received_total Total number of packets received by the DHCP server (PacketsReceivedTotal)
# TYPE windows_dhcp_packets_received_total counter
windows_dhcp_packets_received_total 0
# HELP windows_dhcp_releases_total Total DHCP Releases received by the DHCP server (ReleasesTotal)
# TYPE windows_dhcp_releases_total counter
windows_dhcp_releases_total 0
# HELP windows_dhcp_requests_total Total DHCP Requests received by the DHCP server (RequestsTotal)
# TYPE windows_dhcp_requests_total counter
windows_dhcp_requests_total 0
# HELP windows_dhcp_scope_addresses_free_total DHCP Scope free addresses
# TYPE windows_dhcp_scope_addresses_free_total gauge
windows_dhcp_scope_addresses_free_total{scope="10.11.12.0/25"} 0
windows_dhcp_scope_addresses_free_total{scope="172.16.0.0/24"} 0
windows_dhcp_scope_addresses_free_total{scope="192.168.0.0/24"} 231
# HELP windows_dhcp_scope_addresses_in_use_total DHCP Scope addresses in use
# TYPE windows_dhcp_scope_addresses_in_use_total gauge
windows_dhcp_scope_addresses_in_use_total{scope="10.11.12.0/25"} 0
windows_dhcp_scope_addresses_in_use_total{scope="172.16.0.0/24"} 0
windows_dhcp_scope_addresses_in_use_total{scope="192.168.0.0/24"} 0
# HELP windows_dhcp_scope_info DHCP Scope information
# TYPE windows_dhcp_scope_info gauge
windows_dhcp_scope_info{name="SUBSUPERSCOPE",scope="172.16.0.0/24",superscope_id="2",superscope_name="SUPERSCOPE"} 1
windows_dhcp_scope_info{name="TEST",scope="192.168.0.0/24",superscope_id="0",superscope_name=""} 1
windows_dhcp_scope_info{name="TEST2",scope="10.11.12.0/25",superscope_id="2",superscope_name="SUPERSCOPE"} 1
# HELP windows_dhcp_scope_pending_offers_total DHCP Scope pending offers
# TYPE windows_dhcp_scope_pending_offers_total gauge
windows_dhcp_scope_pending_offers_total{scope="10.11.12.0/25"} 0
windows_dhcp_scope_pending_offers_total{scope="172.16.0.0/24"} 0
windows_dhcp_scope_pending_offers_total{scope="192.168.0.0/24"} 0
# HELP windows_dhcp_scope_reserved_address_total DHCP Scope reserved addresses
# TYPE windows_dhcp_scope_reserved_address_total gauge
windows_dhcp_scope_reserved_address_total{scope="10.11.12.0/25"} 0
windows_dhcp_scope_reserved_address_total{scope="172.16.0.0/24"} 0
windows_dhcp_scope_reserved_address_total{scope="192.168.0.0/24"} 2
# HELP windows_dhcp_scope_state DHCP Scope state
# TYPE windows_dhcp_scope_state gauge
windows_dhcp_scope_state{scope="10.11.12.0/25",state="Disabled"} 1
windows_dhcp_scope_state{scope="10.11.12.0/25",state="DisabledSwitched"} 0
windows_dhcp_scope_state{scope="10.11.12.0/25",state="Enabled"} 0
windows_dhcp_scope_state{scope="10.11.12.0/25",state="EnabledSwitched"} 0
windows_dhcp_scope_state{scope="10.11.12.0/25",state="InvalidState"} 0
windows_dhcp_scope_state{scope="172.16.0.0/24",state="Disabled"} 1
windows_dhcp_scope_state{scope="172.16.0.0/24",state="DisabledSwitched"} 0
windows_dhcp_scope_state{scope="172.16.0.0/24",state="Enabled"} 0
windows_dhcp_scope_state{scope="172.16.0.0/24",state="EnabledSwitched"} 0
windows_dhcp_scope_state{scope="172.16.0.0/24",state="InvalidState"} 0
windows_dhcp_scope_state{scope="192.168.0.0/24",state="Disabled"} 0
windows_dhcp_scope_state{scope="192.168.0.0/24",state="DisabledSwitched"} 0
windows_dhcp_scope_state{scope="192.168.0.0/24",state="Enabled"} 1
windows_dhcp_scope_state{scope="192.168.0.0/24",state="EnabledSwitched"} 0
windows_dhcp_scope_state{scope="192.168.0.0/24",state="InvalidState"} 0
```
## Useful queries
_This collector does not yet have any useful queries added, we would appreciate your help adding them!_

View File

@@ -3,14 +3,19 @@
The dns collector exposes metrics about the DNS server
|||
-|-
Metric name prefix | `dns`
Classes | [`Win32_PerfRawData_DNS_DNS`](https://technet.microsoft.com/en-us/library/cc977686.aspx)
Enabled by default? | No
-|-|-
Metric name prefix | `dns` |
Classes | [`Win32_PerfRawData_DNS_DNS`](https://technet.microsoft.com/en-us/library/cc977686.aspx) |
Enabled by default | Yes |
Metric name prefix (error stats) | `windows_dns` |
Classes | [`MicrosoftDNS_Statistic`](https://learn.microsoft.com/en-us/windows/win32/dns/dns-wmi-provider-overview) |
Enabled by default (error stats)? | Yes |
## Flags
None
Name | Description
-----|------------
`collector.dns.enabled` | Comma-separated list of collectors to use. Available collectors: `metrics`, `error_stats`. Defaults to all collectors if not specified.
## Metrics
@@ -38,12 +43,56 @@ Name | Description | Type | Labels
`windows_dns_wins_queries_total` | _Not yet documented_ | counter | `direction`
`windows_dns_wins_responses_total` | _Not yet documented_ | counter | `direction`
`windows_dns_unmatched_responses_total` | _Not yet documented_ | counter | None
`windows_dns_error_stats_total` | DNS error statistics from MicrosoftDNS_Statistic | counter | `name`, `collection_name`, `dns_server`
### Sub-collectors
The DNS collector is split into two sub-collectors:
1. `metrics` - Collects standard DNS performance metrics using PDH (Performance Data Helper)
2. `wmi_stats` - Collects DNS error statistics from the MicrosoftDNS_Statistic WMI class
By default, both sub-collectors are enabled. You can enable specific sub-collectors using the `collector.dns.enabled` flag.
### Example Usage
To enable only DNS error statistics collection:
```powershell
windows_exporter.exe --collector.dns.enabled=wmi_stats
```
To enable only standard DNS metrics:
```powershell
windows_exporter.exe --collector.dns.enabled=metrics
```
To enable both (default behavior):
```powershell
windows_exporter.exe --collector.dns.enabled=metrics,wmi_stats
```
### Example metric
_This collector does not yet have explained examples, we would appreciate your help adding them!_
```
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="BadKey"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="BadSig"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="BadTime"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="FormError"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="Max"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="NoError"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="NotAuth"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="NotImpl"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="NotZone"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="NxDomain"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="NxRRSet"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="Refused"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="ServFail"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="UnknownError"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="YxDomain"} 0
windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5NNM8M1",name="YxRRSet"} 0
```
## Useful queries
_This collector does not yet have any useful queries added, we would appreciate your help adding them!_
## Alerting examples
_This collector does not yet have alerting examples, we would appreciate your help adding them!_
_This collector does not yet have alerting examples, we would appreciate your help adding them!_

View File

@@ -43,7 +43,7 @@ Comma-separated list of collectors to use, for example: `--collectors.exchange.e
| `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_aggregate_shadow_queue_length` | The current number of messages in shadow queues |
| `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 |
@@ -54,7 +54,7 @@ Comma-separated list of collectors to use, for example: `--collectors.exchange.e
| `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_availability_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 |
@@ -77,4 +77,3 @@ _This collector does not yet have any useful queries added, we would appreciate
## Alerting examples
_This collector does not yet have alerting examples, we would appreciate your help adding them!_

View File

@@ -69,6 +69,23 @@ Show volume usage (%)
100.0 - 100 * (windows_logical_disk_free_bytes{instance="localhost", volume="C:"} / windows_logical_disk_size_bytes{instance="localhost", volume="C:"})
```
Disk Activity
```promql
(
rate(windows_logical_disk_read_seconds_total[2m])
+
rate(windows_logical_disk_write_seconds_total[2m])
)
/
(
rate(windows_logical_disk_read_seconds_total[2m])
+
rate(windows_logical_disk_write_seconds_total[2m])
+
rate(windows_logical_disk_idle_seconds_total[2m])
)
```
## Alerting examples
**prometheus.rules**
```yaml

View File

@@ -1,78 +0,0 @@
# logon collector
The logon collector exposes metrics detailing the active user logon sessions.
| | |
|---------------------|-----------|
| Metric name prefix | `logon` |
| Source | Win32 API |
| Enabled by default? | No |
## Flags
None
## Metrics
| Name | Description | Type | Labels |
|-------------------------------------------|--------------------------------------------|-------|------------------------------------|
| `windows_logon_session_logon_timestamp_seconds` | timestamp of the logon session in seconds. | gauge | `domain`, `id`, `type`, `username` |
### Example metric
Query the total number of interactive logon sessions
```
# HELP windows_logon_session_logon_timestamp_seconds timestamp of the logon session in seconds.
# TYPE windows_logon_session_logon_timestamp_seconds gauge
windows_logon_session_logon_timestamp_seconds{domain="",id="0x0:0x8c54",type="System",username=""} 1.72876928e+09
windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0x991a",type="Interactive",username="UMFD-1"} 1.728769282e+09
windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0x9933",type="Interactive",username="UMFD-0"} 1.728769282e+09
windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0x994a",type="Interactive",username="UMFD-0"} 1.728769282e+09
windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0x999d",type="Interactive",username="UMFD-1"} 1.728769282e+09
windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0xbf25a",type="Interactive",username="UMFD-2"} 1.728769532e+09
windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0xbf290",type="Interactive",username="UMFD-2"} 1.728769532e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x130241",type="Network",username="vm-jok-dev$"} 1.728769625e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x24f7c9",type="Network",username="vm-jok-dev$"} 1.728770121e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x276846",type="Network",username="vm-jok-dev$"} 1.728770195e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x3e4",type="Service",username="vm-jok-dev$"} 1.728769283e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x3e7",type="System",username="vm-jok-dev$"} 1.728769279e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x71d0f",type="Network",username="vm-jok-dev$"} 1.728769324e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x720a3",type="Network",username="vm-jok-dev$"} 1.728769324e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x725cb",type="Network",username="vm-jok-dev$"} 1.728769324e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x753d8",type="Network",username="vm-jok-dev$"} 1.728769325e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0xa3913",type="Network",username="vm-jok-dev$"} 1.728769385e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0xbe7f2",type="Network",username="jok"} 1.728769531e+09
windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0xc76c4",type="RemoteInteractive",username="jok"} 1.728769533e+09
windows_logon_session_logon_timestamp_seconds{domain="NT AUTHORITY",id="0x0:0x3e3",type="Service",username="IUSR"} 1.728769295e+09
windows_logon_session_logon_timestamp_seconds{domain="NT AUTHORITY",id="0x0:0x3e5",type="Service",username="LOCAL SERVICE"} 1.728769283e+09
windows_logon_session_logon_timestamp_seconds{domain="NT Service",id="0x0:0xae4c7",type="Service",username="MSSQLSERVER"} 1.728769425e+09
windows_logon_session_logon_timestamp_seconds{domain="NT Service",id="0x0:0xb42f1",type="Service",username="SQLTELEMETRY"} 1.728769431e+09
windows_logon_session_logon_timestamp_seconds{domain="Window Manager",id="0x0:0xbfbac",type="Interactive",username="DWM-2"} 1.728769532e+09
windows_logon_session_logon_timestamp_seconds{domain="Window Manager",id="0x0:0xbfc72",type="Interactive",username="DWM-2"} 1.728769532e+09
windows_logon_session_logon_timestamp_seconds{domain="Window Manager",id="0x0:0xdedd",type="Interactive",username="DWM-1"} 1.728769283e+09
windows_logon_session_logon_timestamp_seconds{domain="Window Manager",id="0x0:0xdefd",type="Interactive",username="DWM-1"} 1.728769283e+09
```
### Possible values for `type`
- System
- Interactive
- Network
- Batch
- Service
- Proxy
- Unlock
- NetworkCleartext
- NewCredentials
- RemoteInteractive
- CachedInteractive
- CachedRemoteInteractive
- CachedUnlock
## Useful queries
Query the total number of local and remote (I.E. Terminal Services) interactive sessions.
```
count(windows_logon_logon_type{type=~"Interactive|RemoteInteractive"}) by (type)
```
## Alerting examples
_This collector doesnt yet have alerting examples, we would appreciate your help adding them!_

View File

@@ -18,15 +18,10 @@ Comma-separated list of MSSQL WMI classes to use. Supported values are `accessme
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`.
### `--collector.mssql.port`
Port of MSSQL server used for `windows_mssql_info` metric. Default is `1433`.
## Metrics
| Name | Description | Type | Labels |
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-------------------------------|
| `windows_mssql_info` | Returns information about the MSSQL server running on port 1433 | gauge | `version` |
| `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` |
@@ -197,6 +192,7 @@ Port of MSSQL server used for `windows_mssql_info` metric. Default is `1433`.
| `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` |

View File

@@ -19,6 +19,10 @@ If given, an interface name needs to match the include regexp in order for the c
If given, an interface name needs to *not* match the exclude regexp in order for the corresponding metrics to be reported
### `--collector.net.enabled`
Comma-separated list of collectors to use. Defaults to all, if not specified.
## Metrics
Name | Description | Type | Labels

View File

@@ -10,7 +10,9 @@ The netframework collector exposes metrics about dotnet framework.
## Flags
None
### `--collector.netframework.enabled`
Comma-separated list of collectors to use. Defaults to all, if not specified.
## Metrics

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,262 @@
# 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"
type: "formatted"
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",
"type": "formatted",
"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.
#### type
The counter-type. The value can be `raw` or `formatted`. Optional and defaults to `raw`.
- `raw` returns the raw value of the counter. This is the default.
- `formatted` returns the formatted value of the counter. This is useful for counters like `Processor Information` where the value is a percentage.
The difference between a raw Windows Performance Counter and a formatted Windows Performance Counter is about how the data is presented and processed:
1. Raw Windows Performance Counter:
This provides the counter's data in its basic, unprocessed form.
The values may represent cumulative counts, time intervals, or other uncalibrated metrics.
Interpreting these values often requires more calculations or context, such as calculating deltas or normalizing values over time.
2. Formatted Windows Performance Counter:
This presents data that has already been processed and interpreted according to the counter type (e.g., rates per second, averages, percentages).
Formatted counters are easier to understand directly since the necessary calculations have been applied.
These are often what monitoring tools display to users because they are meaningful at a glance.
For example:
* A raw counter for CPU time might give the total number of clock ticks used since the system started.
* A formatted counter would convert this into a percentage of CPU utilization over a specific time interval.
#### 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

@@ -21,19 +21,21 @@ If given, a disk needs to *not* match the exclude regexp in order for the corres
## Metrics
Name | Description | Type | Labels
-----|-------------|------|-------
`requests_queued` | Number of requests outstanding on the disk at the time the performance data is collected | gauge | `disk`
`read_bytes_total` | Rate at which bytes are transferred from the disk during read operations | counter | `disk`
`reads_total` | Rate of read operations on the disk | counter | `disk`
`write_bytes_total` | Rate at which bytes are transferred to the disk during write operations | counter | `disk`
`writes_total` | Rate of write operations on the disk | counter | `disk`
`read_seconds_total` | Seconds the disk was busy servicing read requests | counter | `disk`
`write_seconds_total` | Seconds the disk was busy servicing write requests | counter | `disk`
`free_bytes` | Unused space of the disk in bytes (not real time, updates every 10-15 min) | gauge | `disk`
`size_bytes` | Total size of the disk in bytes (not real time, updates every 10-15 min) | gauge | `disk`
`idle_seconds_total` | Seconds the disk was idle (not servicing read/write requests) | counter | `disk`
`split_ios_total` | Number of I/Os to the disk split into multiple I/Os | counter | `disk`
| Name | Description | Type | Labels |
|--------------------------------------------------------|---------------------------------------------------------------------------------------------------------|---------|--------|
| windows_physical_disk_requests_queued | The number of requests queued to the disk (PhysicalDisk.CurrentDiskQueueLength) | Gauge | disk |
| windows_physical_disk_read_bytes_total | The number of bytes transferred from the disk during read operations (PhysicalDisk.DiskReadBytesPerSec) | Counter | disk |
| windows_physical_disk_reads_total | The number of read operations on the disk (PhysicalDisk.DiskReadsPerSec) | Counter | disk |
| windows_physical_disk_write_bytes_total | The number of bytes transferred to the disk during write operations (PhysicalDisk.DiskWriteBytesPerSec) | Counter | disk |
| windows_physical_disk_writes_total | The number of write operations on the disk (PhysicalDisk.DiskWritesPerSec) | Counter | disk |
| windows_physical_disk_read_seconds_total | Seconds that the disk was busy servicing read requests (PhysicalDisk.PercentDiskReadTime) | Counter | disk |
| windows_physical_disk_write_seconds_total | Seconds that the disk was busy servicing write requests (PhysicalDisk.PercentDiskWriteTime) | Counter | disk |
| windows_physical_disk_idle_seconds_total | Seconds that the disk was idle (PhysicalDisk.PercentIdleTime) | Counter | disk |
| windows_physical_disk_split_ios_total | The number of I/Os to the disk that were split into multiple I/Os (PhysicalDisk.SplitIOPerSec) | Counter | disk |
| windows_physical_disk_read_latency_seconds_total | The average time, in seconds, of a read operation from the disk (PhysicalDisk.AvgDiskSecPerRead) | Counter | disk |
| windows_physical_disk_write_latency_seconds_total | The average time, in seconds, of a write operation to the disk (PhysicalDisk.AvgDiskSecPerWrite) | Counter | disk |
| windows_physical_disk_read_write_latency_seconds_total | The time, in seconds, of the average disk transfer (PhysicalDisk.AvgDiskSecPerTransfer) | Counter | disk |
### Warning about size metrics
The `free_bytes` and `size_bytes` metrics are not updated in real time and might have a delay of 10-15min.
@@ -52,29 +54,4 @@ rate(windows_physical_disk_reads_total{instance="localhost", disk=~"0"}[2m]) + r
```
## Alerting examples
**prometheus.rules**
```yaml
groups:
- name: Windows Disk Alerts
rules:
# Sends an alert when disk space usage is above 95%
- alert: DiskSpaceUsage
expr: 100.0 - 100 * (windows_physical_disk_free_bytes / windows_physical_disk_size_bytes) > 95
for: 10m
labels:
severity: high
annotations:
summary: "Disk Space Usage (instance {{ $labels.instance }})"
description: "Disk Space on Drive is used more than 95%\n VALUE = {{ $value }}\n LABELS: {{ $labels }}"
# Alerts on disks with over 85% space usage predicted to fill within the next four days
- alert: DiskFilling
expr: 100 * (windows_physical_disk_free_bytes / windows_physical_disk_size_bytes) < 15 and predict_linear(windows_physical_disk_free_bytes[6h], 4 * 24 * 3600) < 0
for: 10m
labels:
severity: warning
annotations:
summary: "Disk full in four days (instance {{ $labels.instance }})"
description: "{{ $labels.disk }} is expected to fill up within four days. Currently {{ $value | humanize }}% is available.\n VALUE = {{ $value }}\n LABELS: {{ $labels }}"
```
_This collector does not yet have alerting examples, we would appreciate your help adding them!_

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` | 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 < 86400
```
## Alerting examples

View File

@@ -21,16 +21,17 @@ Matching is case-sensitive.
## Metrics
| Name | Description | Type | Labels |
|-----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|------------|
| `windows_time_clock_frequency_adjustment_ppb_total` | Total adjustment made to the local system clock frequency by W32Time in parts per billion (PPB) units. 1 PPB adjustment implies the system clock was adjusted at a rate of 1 nanosecond per second (1 ns/s). The smallest possible adjustment can vary and is expected to be in the order of 100's of PPB. | counter | None |
| `windows_time_computed_time_offset_seconds` | The absolute time offset between the system clock and the chosen time source, as computed by the W32Time service in microseconds. When a new valid sample is available, the computed time is updated with the time offset indicated by the sample. This time is the actual time offset of the local clock. W32Time initiates clock correction by using this offset and updates the computed time in between samples with the remaining time offset that needs to be applied to the local clock. Clock accuracy can be tracked by using this performance counter with a low polling interval (for example, 256 seconds or less) and looking for the counter value to be smaller than the desired clock accuracy limit. | gauge | None |
| `windows_time_ntp_client_time_sources` | Active number of NTP Time sources being used by the client. This is a count of active, distinct IP addresses of time servers that are responding to this client's requests. | gauge | None |
| `windows_time_ntp_round_trip_delay_seconds` | Total roundtrip delay experienced by the NTP client in receiving a response from the server for the most recent request, in seconds. This is the time elapsed on the NTP client between transmitting a request to the NTP server and receiving a valid response from the server. | gauge | None |
| `windows_time_ntp_server_outgoing_responses_total` | Total number of requests responded to by the NTP server. | counter | None |
| `windows_time_ntp_server_incoming_requests_total` | Total number of requests received by the NTP server. | counter | None |
| `windows_time_current_timestamp_seconds` | Current time as reported by the operating system, in [Unix time](https://en.wikipedia.org/wiki/Unix_time). See [time.Unix()](https://golang.org/pkg/time/#Unix) for details | gauge | None |
| `windows_time_timezone` | Current timezone as reported by the operating system. | gauge | `timezone` |
| Name | Description | Type | Labels |
|----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|------------|
| `windows_time_clock_frequency_adjustment` | Adjustment made to the local system clock frequency by W32Time in parts per billion (PPB) units. 1 PPB adjustment implies the system clock was adjusted at a rate of 1 nanosecond per second (1 ns/s). The smallest possible adjustment can vary and is expected to be in the order of 100's of PPB. | gauge | None |
| `windows_time_clock_frequency_adjustment_ppb` | Adjustment made to the local system clock frequency by W32Time in parts per billion (PPB) units. 1 PPB adjustment implies the system clock was adjusted at a rate of 1 nanosecond per second (1 ns/s). The smallest possible adjustment can vary and is expected to be in the order of 100's of PPB. | gauge | None |
| `windows_time_computed_time_offset_seconds` | The absolute time offset between the system clock and the chosen time source, as computed by the W32Time service in microseconds. When a new valid sample is available, the computed time is updated with the time offset indicated by the sample. This time is the actual time offset of the local clock. W32Time initiates clock correction by using this offset and updates the computed time in between samples with the remaining time offset that needs to be applied to the local clock. Clock accuracy can be tracked by using this performance counter with a low polling interval (for example, 256 seconds or less) and looking for the counter value to be smaller than the desired clock accuracy limit. | gauge | None |
| `windows_time_ntp_client_time_sources` | Active number of NTP Time sources being used by the client. This is a count of active, distinct IP addresses of time servers that are responding to this client's requests. | gauge | None |
| `windows_time_ntp_round_trip_delay_seconds` | Total roundtrip delay experienced by the NTP client in receiving a response from the server for the most recent request, in seconds. This is the time elapsed on the NTP client between transmitting a request to the NTP server and receiving a valid response from the server. | gauge | None |
| `windows_time_ntp_server_outgoing_responses_total` | Total number of requests responded to by the NTP server. | counter | None |
| `windows_time_ntp_server_incoming_requests_total` | Total number of requests received by the NTP server. | counter | None |
| `windows_time_current_timestamp_seconds` | Current time as reported by the operating system, in [Unix time](https://en.wikipedia.org/wiki/Unix_time). See [time.Unix()](https://golang.org/pkg/time/#Unix) for details | gauge | None |
| `windows_time_timezone` | Current timezone as reported by the operating system. | gauge | `timezone` |
### Example metric
_This collector does not yet have explained examples, we would appreciate your help adding them!_

43
go.mod
View File

@@ -1,38 +1,39 @@
module github.com/prometheus-community/windows_exporter
go 1.23
go 1.23.0
toolchain go1.23.4
require (
github.com/Microsoft/go-winio v0.6.2
github.com/Microsoft/hcsshim v0.12.9
github.com/alecthomas/kingpin/v2 v2.4.0
github.com/bmatcuk/doublestar/v4 v4.7.1
github.com/bmatcuk/doublestar/v4 v4.8.1
github.com/dimchansky/utfbom v1.1.1
github.com/go-ole/go-ole v1.3.0
github.com/google/uuid v1.6.0
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/client_golang v1.21.1
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/prometheus/common v0.62.0
github.com/prometheus/exporter-toolkit v0.14.0
github.com/stretchr/testify v1.10.0
golang.org/x/sys v0.27.0
golang.org/x/sys v0.31.0
gopkg.in/yaml.v3 v3.0.1
)
require (
github.com/Microsoft/go-winio v0.6.2 // indirect
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.5 // 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/klauspost/compress v1.18.0 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
github.com/mdlayher/vsock v1.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
@@ -43,13 +44,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.36.0 // indirect
golang.org/x/net v0.37.0 // indirect
golang.org/x/oauth2 v0.28.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/text v0.23.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
google.golang.org/grpc v1.71.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

90
go.sum
View File

@@ -10,21 +10,21 @@ github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b h1:mimo19zliBX/vS
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bmatcuk/doublestar/v4 v4.7.1 h1:fdDeAqgT47acgwd9bd9HxJRDmc9UAmPpc+2m0CXv75Q=
github.com/bmatcuk/doublestar/v4 v4.7.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR5wKP38=
github.com/bmatcuk/doublestar/v4 v4.8.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
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.5 h1:44na7Ud+VwyE7LIoJ8JTNQOa549a8543BmzaJHo6Bzo=
github.com/containerd/cgroups/v3 v3.0.5/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=
@@ -64,14 +66,14 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -90,15 +92,15 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk=
github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg=
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.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
github.com/prometheus/exporter-toolkit v0.14.0 h1:NMlswfibpcZZ+H0sZBiTjrA3/aBFHkNZqE+iCj5EmRg=
github.com/prometheus/exporter-toolkit v0.14.0/go.mod h1:Gu5LnVvt7Nr/oqTBUC23WILZepW0nffNo10XdhQcwWA=
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=
@@ -126,8 +128,10 @@ 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.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
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=
@@ -143,30 +147,40 @@ 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.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
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.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE=
golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
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.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
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.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
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.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
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=
@@ -184,15 +198,19 @@ 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-20250204164813-702378808489 h1:5bKytslY8ViY0Cj/ewmRtrWHW64bNF03cAatUUFCdFI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250204164813-702378808489/go.mod h1:8BS3B93F/U1juMFq9+EDk+qOT5CO1R9IzXxG3PTqiRk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb h1:TLPQVbx1GJ8VKZxz52VAxl1EBgKXXbTiU9Fc5fZeLn4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I=
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.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ=
google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw=
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
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=
@@ -202,8 +220,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.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
google.golang.org/protobuf v1.36.5/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

@@ -28,7 +28,7 @@ Copy-Item -Force $PathToExecutable Work/windows_exporter.exe
Write-Verbose "Creating windows_exporter-${Version}-${Arch}.msi"
$wixArch = @{"amd64" = "x64"; "arm64" = "arm64"}[$Arch]
Invoke-Expression "wix build -arch $wixArch -o .\windows_exporter-$($Version)-$($Arch).msi .\files.wxs .\main.wxs -d ProductName=windows_exporter -d Version=$($MsiVersion) -ext WixToolset.Firewall.wixext -ext WixToolset.UI.wixext -ext WixToolset.Util.wixext"
Invoke-Expression "wix build -sw1149 -arch $wixArch -o .\windows_exporter-$($Version)-$($Arch).msi .\files.wxs .\main.wxs -d ProductName=windows_exporter -d Version=$($MsiVersion) -ext WixToolset.Firewall.wixext -ext WixToolset.UI.wixext -ext WixToolset.Util.wixext"
Write-Verbose "Done!"
Pop-Location

BIN
installer/codesign.cer Normal file

Binary file not shown.

View File

@@ -27,10 +27,15 @@
ErrorControl="normal"
Start="auto"
Type="ownProcess"
Interactive="no"
Vital="yes"
Arguments="[ConfigFileFlag] [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirsFlag] [ExtraFlags]">
<ServiceConfig
DelayedAutoStart="yes"
OnInstall="yes"
OnReinstall="yes" />
<util:ServiceConfig
ResetPeriodInDays="1"
ResetPeriodInDays="0"
FirstFailureActionType="restart"
SecondFailureActionType="restart"
ThirdFailureActionType="restart"
@@ -39,6 +44,12 @@
<ServiceDependency Id="wmiApSrv" />
</ServiceInstall>
<ServiceControl Id="ServiceStateControl" Name="windows_exporter" Remove="uninstall" Start="install" Stop="both"/>
<!-- The "Name" field must match the argument to eventlog.Open() -->
<util:EventSource Log="Application" Name="windows_exporter"
EventMessageFile="%SystemRoot%\System32\EventCreate.exe"
SupportsErrors="yes"
SupportsInformationals="yes"
SupportsWarnings="yes"/>
</Component>
<Component Id="CreateTextfileDirectory" Directory="textfile_inputs" Guid="d03ef58a-9cbf-4165-ad39-d143e9b27e14">
<CreateFolder />

View File

@@ -43,6 +43,9 @@
Property="OLDERVERSIONBEINGUPGRADED" />
</Upgrade>
<CustomAction Id="CheckExtraFlags"
Error="The parameter '--config.file' must not be included in EXTRA_FLAGS. Use CONFIG_FILE instead. Please remove it and try again." />
<CustomAction Id="set_maintenance" Property="MAINTENANCE" Value="true" />
<!-- Set to reinstall all features. -->
@@ -54,12 +57,12 @@
<CustomAction Id="set_reinstallmode_property"
Property="REINSTALLMODE"
Value="amus" />
<!-- START CUSTOM ACTION FOR CONFIG FILE CREATION -->
<SetProperty
Id="CreateConfigFile"
Value="&quot;[%ComSpec]&quot; /c TYPE NUL >>&quot;[ConfigFile_NonDefault][ConfigFile_Default]&quot;"
Before="CreateConfigFile"
Sequence="execute"
Condition="ConfigFile_NonDefault OR ConfigFile_Default"
/>
<CustomAction
Id="CreateConfigFile"
@@ -69,6 +72,24 @@
Return="check"
Impersonate="no"
/>
<!-- END CUSTOM ACTION FOR CONFIG FILE CREATION -->
<!-- START CUSTOM ACTION FOR KILLING THE PROCESS -->
<SetProperty
Id="KillProcess"
Value="&quot;[WindowsFolder]\System32\taskkill.exe&quot; /T /F /IM windows_exporter.exe"
Before="KillProcess"
Sequence="execute"
/>
<CustomAction
Id="KillProcess"
BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)"
DllEntry="WixQuietExec"
Execute="deferred"
Return="ignore"
Impersonate="no"
/>
<!-- END CUSTOM ACTION FOR KILLING THE PROCESS -->
<InstallExecuteSequence>
<!-- Set REINSTALL=all and REINSTALLMODE=amus if the user reruns the
@@ -78,6 +99,10 @@
<Custom Action="set_reinstall_all_property" Before="set_reinstallmode_property" Condition="MAINTENANCE"/>
<Custom Action="set_reinstallmode_property" Before="LaunchConditions" Condition="MAINTENANCE"/>
<Custom Action="CreateConfigFile" Before="InstallServices" Condition="ConfigFile_NonDefault OR ConfigFile_Default" />
<Custom Action="KillProcess" Before="RemoveFiles" />
<Custom Action="CheckExtraFlags" Before="InstallInitialize"
Condition="EXTRA_FLAGS AND (EXTRA_FLAGS&gt;&lt;&quot;--config.file&quot;)" />
</InstallExecuteSequence>
<Media Id="1" Cabinet="windows_exporter.cab" EmbedCab="yes" />
@@ -90,9 +115,10 @@
<SetProperty Id="ExtraFlags" After="InstallFiles" Sequence="execute" Value="[EXTRA_FLAGS]" Condition="EXTRA_FLAGS" />
<Property Id="CONFIG_FILE" Secure="yes" Value="config.yaml" />
<SetProperty Id="ConfigFile_NonDefault" After="InstallFiles" Sequence="execute" Value="[CONFIG_FILE]" Condition="CONFIG_FILE AND CONFIG_FILE&lt;&gt;&quot;config.yaml&quot;" />
<SetProperty Id="ConfigFile_Remote" After="InstallFiles" Sequence="execute" Value="[CONFIG_FILE]" Condition="CONFIG_FILE AND (CONFIG_FILE&lt;&lt;&quot;http://&quot; OR CONFIG_FILE&lt;&lt;&quot;https://&quot;)" />
<SetProperty Id="ConfigFile_NonDefault" After="InstallFiles" Sequence="execute" Value="[CONFIG_FILE]" Condition="CONFIG_FILE AND CONFIG_FILE&lt;&gt;&quot;config.yaml&quot; AND NOT (CONFIG_FILE&lt;&lt;&quot;http://&quot; OR CONFIG_FILE&lt;&lt;&quot;https://&quot;)" />
<SetProperty Id="ConfigFile_Default" After="InstallFiles" Sequence="execute" Value="[APPLICATIONFOLDER]config.yaml" Condition="CONFIG_FILE=&quot;config.yaml&quot;" />
<SetProperty Id="ConfigFileFlag" After="InstallFiles" Sequence="execute" Value="--config.file=&quot;[ConfigFile_NonDefault][ConfigFile_Default]&quot;" Condition="ConfigFile_NonDefault OR ConfigFile_Default" />
<SetProperty Id="ConfigFileFlag" After="InstallFiles" Sequence="execute" Value="--config.file=&quot;[ConfigFile_Remote][ConfigFile_NonDefault][ConfigFile_Default]&quot;" Condition="ConfigFile_Remote OR ConfigFile_NonDefault OR ConfigFile_Default" />
<Property Id="LISTEN_PORT" Secure="yes" Value="9182" />
<SetProperty Id="ListenFlag" After="InstallFiles" Sequence="execute" Value="--web.listen-address [LISTEN_ADDR]:[LISTEN_PORT]" Condition="LISTEN_ADDR&lt;&gt;&quot;&quot; OR LISTEN_PORT&lt;&gt;9182" />

View File

@@ -21,7 +21,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"
)
@@ -36,7 +36,8 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
addressBookClientSessions *prometheus.Desc
addressBookOperationsTotal *prometheus.Desc
@@ -129,160 +130,6 @@ func (c *Collector) Close() error {
}
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
counters := []string{
abANRPerSec,
abBrowsesPerSec,
abClientSessions,
abMatchesPerSec,
abPropertyReadsPerSec,
abProxyLookupsPerSec,
abSearchesPerSec,
approximateHighestDNT,
atqEstimatedQueueDelay,
atqOutstandingQueuedRequests,
atqRequestLatency,
atqThreadsLDAP,
atqThreadsOther,
atqThreadsTotal,
baseSearchesPerSec,
databaseAddsPerSec,
databaseDeletesPerSec,
databaseModifiesPerSec,
databaseRecyclesPerSec,
digestBindsPerSec,
draHighestUSNCommittedHighPart,
draHighestUSNCommittedLowPart,
draHighestUSNIssuedHighPart,
draHighestUSNIssuedLowPart,
draInboundBytesCompressedBetweenSitesAfterCompressionSinceBoot,
draInboundBytesCompressedBetweenSitesAfterCompressionPerSec,
draInboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot,
draInboundBytesCompressedBetweenSitesBeforeCompressionPerSec,
draInboundBytesNotCompressedWithinSiteSinceBoot,
draInboundBytesNotCompressedWithinSitePerSec,
draInboundBytesTotalSinceBoot,
draInboundBytesTotalPerSec,
draInboundFullSyncObjectsRemaining,
draInboundLinkValueUpdatesRemainingInPacket,
draInboundObjectUpdatesRemainingInPacket,
draInboundObjectsAppliedPerSec,
draInboundObjectsFilteredPerSec,
draInboundObjectsPerSec,
draInboundPropertiesAppliedPerSec,
draInboundPropertiesFilteredPerSec,
draInboundPropertiesTotalPerSec,
draInboundTotalUpdatesRemainingInPacket,
draInboundValuesDNsOnlyPerSec,
draInboundValuesTotalPerSec,
draOutboundBytesCompressedBetweenSitesAfterCompressionSinceBoot,
draOutboundBytesCompressedBetweenSitesAfterCompressionPerSec,
draOutboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot,
draOutboundBytesCompressedBetweenSitesBeforeCompressionPerSec,
draOutboundBytesNotCompressedWithinSiteSinceBoot,
draOutboundBytesNotCompressedWithinSitePerSec,
draOutboundBytesTotalSinceBoot,
draOutboundBytesTotalPerSec,
draOutboundObjectsFilteredPerSec,
draOutboundObjectsPerSec,
draOutboundPropertiesPerSec,
draOutboundValuesDNsOnlyPerSec,
draOutboundValuesTotalPerSec,
draPendingReplicationOperations,
draPendingReplicationSynchronizations,
draSyncFailuresOnSchemaMismatch,
draSyncRequestsMade,
draSyncRequestsSuccessful,
draThreadsGettingNCChanges,
draThreadsGettingNCChangesHoldingSemaphore,
dsPercentReadsFromDRA,
dsPercentReadsFromKCC,
dsPercentReadsFromLSA,
dsPercentReadsFromNSPI,
dsPercentReadsFromNTDSAPI,
dsPercentReadsFromSAM,
dsPercentReadsOther,
dsPercentSearchesFromDRA,
dsPercentSearchesFromKCC,
dsPercentSearchesFromLDAP,
dsPercentSearchesFromLSA,
dsPercentSearchesFromNSPI,
dsPercentSearchesFromNTDSAPI,
dsPercentSearchesFromSAM,
dsPercentSearchesOther,
dsPercentWritesFromDRA,
dsPercentWritesFromKCC,
dsPercentWritesFromLDAP,
dsPercentWritesFromLSA,
dsPercentWritesFromNSPI,
dsPercentWritesFromNTDSAPI,
dsPercentWritesFromSAM,
dsPercentWritesOther,
dsClientBindsPerSec,
dsClientNameTranslationsPerSec,
dsDirectoryReadsPerSec,
dsDirectorySearchesPerSec,
dsDirectoryWritesPerSec,
dsMonitorListSize,
dsNameCacheHitRate,
dsNotifyQueueSize,
dsSearchSubOperationsPerSec,
dsSecurityDescriptorPropagationsEvents,
dsSecurityDescriptorPropagatorAverageExclusionTime,
dsSecurityDescriptorPropagatorRuntimeQueue,
dsSecurityDescriptorSubOperationsPerSec,
dsServerBindsPerSec,
dsServerNameTranslationsPerSec,
dsThreadsInUse,
externalBindsPerSec,
fastBindsPerSec,
ldapActiveThreads,
ldapBindTime,
ldapClientSessions,
ldapClosedConnectionsPerSec,
ldapNewConnectionsPerSec,
ldapNewSSLConnectionsPerSec,
ldapSearchesPerSec,
ldapSuccessfulBindsPerSec,
ldapUDPOperationsPerSec,
ldapWritesPerSec,
linkValuesCleanedPerSec,
negotiatedBindsPerSec,
ntlmBindsPerSec,
oneLevelSearchesPerSec,
phantomsCleanedPerSec,
phantomsVisitedPerSec,
samAccountGroupEvaluationLatency,
samDisplayInformationQueriesPerSec,
samDomainLocalGroupMembershipEvaluationsPerSec,
samEnumerationsPerSec,
samGCEvaluationsPerSec,
samGlobalGroupMembershipEvaluationsPerSec,
samMachineCreationAttemptsPerSec,
samMembershipChangesPerSec,
samNonTransitiveMembershipEvaluationsPerSec,
samPasswordChangesPerSec,
samResourceGroupEvaluationLatency,
samSuccessfulComputerCreationsPerSecIncludesAllRequests,
samSuccessfulUserCreationsPerSec,
samTransitiveMembershipEvaluationsPerSec,
samUniversalGroupMembershipEvaluationsPerSec,
samUserCreationAttemptsPerSec,
simpleBindsPerSec,
subtreeSearchesPerSec,
tombstonesGarbageCollectedPerSec,
tombstonesVisitedPerSec,
transitiveOperationsMillisecondsRun,
transitiveOperationsPerSec,
transitiveSubOperationsPerSec,
}
var err error
c.perfDataCollector, err = perfdata.NewCollector("DirectoryServices", perfdata.InstancesAll, counters)
if err != nil {
return fmt.Errorf("failed to create DirectoryServices collector: %w", err)
}
c.addressBookOperationsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "address_book_operations_total"),
"",
@@ -657,216 +504,219 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
nil,
)
var err error
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "DirectoryServices", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create DirectoryServices collector: %w", err)
}
return nil
}
// 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 DirectoryServices (AD) metrics: %w", err)
}
data, ok := perfData["NTDS"]
if !ok {
return fmt.Errorf("failed to collect DirectoryServices (AD) metrics: %w", types.ErrNoData)
} else if len(c.perfDataObject) == 0 {
return fmt.Errorf("failed to collect DirectoryServices (AD) metrics: %w", types.ErrNoDataUnexpected)
}
ch <- prometheus.MustNewConstMetric(
c.addressBookOperationsTotal,
prometheus.CounterValue,
data[abANRPerSec].FirstValue,
c.perfDataObject[0].AbANRPerSec,
"ambiguous_name_resolution",
)
ch <- prometheus.MustNewConstMetric(
c.addressBookOperationsTotal,
prometheus.CounterValue,
data[abBrowsesPerSec].FirstValue,
c.perfDataObject[0].AbBrowsesPerSec,
"browse",
)
ch <- prometheus.MustNewConstMetric(
c.addressBookOperationsTotal,
prometheus.CounterValue,
data[abMatchesPerSec].FirstValue,
c.perfDataObject[0].AbMatchesPerSec,
"find",
)
ch <- prometheus.MustNewConstMetric(
c.addressBookOperationsTotal,
prometheus.CounterValue,
data[abPropertyReadsPerSec].FirstValue,
c.perfDataObject[0].AbPropertyReadsPerSec,
"property_read",
)
ch <- prometheus.MustNewConstMetric(
c.addressBookOperationsTotal,
prometheus.CounterValue,
data[abSearchesPerSec].FirstValue,
c.perfDataObject[0].AbSearchesPerSec,
"search",
)
ch <- prometheus.MustNewConstMetric(
c.addressBookOperationsTotal,
prometheus.CounterValue,
data[abProxyLookupsPerSec].FirstValue,
c.perfDataObject[0].AbProxyLookupsPerSec,
"proxy_search",
)
ch <- prometheus.MustNewConstMetric(
c.addressBookClientSessions,
prometheus.GaugeValue,
data[abClientSessions].FirstValue,
c.perfDataObject[0].AbClientSessions,
)
ch <- prometheus.MustNewConstMetric(
c.approximateHighestDistinguishedNameTag,
prometheus.GaugeValue,
data[approximateHighestDNT].FirstValue,
c.perfDataObject[0].ApproximateHighestDNT,
)
ch <- prometheus.MustNewConstMetric(
c.atqEstimatedDelaySeconds,
prometheus.GaugeValue,
data[atqEstimatedQueueDelay].FirstValue/1000,
c.perfDataObject[0].AtqEstimatedQueueDelay/1000,
)
ch <- prometheus.MustNewConstMetric(
c.atqOutstandingRequests,
prometheus.GaugeValue,
data[atqOutstandingQueuedRequests].FirstValue,
c.perfDataObject[0].AtqOutstandingQueuedRequests,
)
ch <- prometheus.MustNewConstMetric(
c.atqAverageRequestLatency,
prometheus.GaugeValue,
data[atqRequestLatency].FirstValue,
c.perfDataObject[0].AtqRequestLatency,
)
ch <- prometheus.MustNewConstMetric(
c.atqCurrentThreads,
prometheus.GaugeValue,
data[atqThreadsLDAP].FirstValue,
c.perfDataObject[0].AtqThreadsLDAP,
"ldap",
)
ch <- prometheus.MustNewConstMetric(
c.atqCurrentThreads,
prometheus.GaugeValue,
data[atqThreadsOther].FirstValue,
c.perfDataObject[0].AtqThreadsOther,
"other",
)
ch <- prometheus.MustNewConstMetric(
c.searchesTotal,
prometheus.CounterValue,
data[baseSearchesPerSec].FirstValue,
c.perfDataObject[0].BaseSearchesPerSec,
"base",
)
ch <- prometheus.MustNewConstMetric(
c.searchesTotal,
prometheus.CounterValue,
data[subtreeSearchesPerSec].FirstValue,
c.perfDataObject[0].SubtreeSearchesPerSec,
"subtree",
)
ch <- prometheus.MustNewConstMetric(
c.searchesTotal,
prometheus.CounterValue,
data[oneLevelSearchesPerSec].FirstValue,
c.perfDataObject[0].OneLevelSearchesPerSec,
"one_level",
)
ch <- prometheus.MustNewConstMetric(
c.databaseOperationsTotal,
prometheus.CounterValue,
data[databaseAddsPerSec].FirstValue,
c.perfDataObject[0].DatabaseAddsPerSec,
"add",
)
ch <- prometheus.MustNewConstMetric(
c.databaseOperationsTotal,
prometheus.CounterValue,
data[databaseDeletesPerSec].FirstValue,
c.perfDataObject[0].DatabaseDeletesPerSec,
"delete",
)
ch <- prometheus.MustNewConstMetric(
c.databaseOperationsTotal,
prometheus.CounterValue,
data[databaseModifiesPerSec].FirstValue,
c.perfDataObject[0].DatabaseModifiesPerSec,
"modify",
)
ch <- prometheus.MustNewConstMetric(
c.databaseOperationsTotal,
prometheus.CounterValue,
data[databaseRecyclesPerSec].FirstValue,
c.perfDataObject[0].DatabaseRecyclesPerSec,
"recycle",
)
ch <- prometheus.MustNewConstMetric(
c.bindsTotal,
prometheus.CounterValue,
data[digestBindsPerSec].FirstValue,
c.perfDataObject[0].DigestBindsPerSec,
"digest",
)
ch <- prometheus.MustNewConstMetric(
c.bindsTotal,
prometheus.CounterValue,
data[dsClientBindsPerSec].FirstValue,
c.perfDataObject[0].DsClientBindsPerSec,
"ds_client",
)
ch <- prometheus.MustNewConstMetric(
c.bindsTotal,
prometheus.CounterValue,
data[dsServerBindsPerSec].FirstValue,
c.perfDataObject[0].DsServerBindsPerSec,
"ds_server",
)
ch <- prometheus.MustNewConstMetric(
c.bindsTotal,
prometheus.CounterValue,
data[externalBindsPerSec].FirstValue,
c.perfDataObject[0].ExternalBindsPerSec,
"external",
)
ch <- prometheus.MustNewConstMetric(
c.bindsTotal,
prometheus.CounterValue,
data[fastBindsPerSec].FirstValue,
c.perfDataObject[0].FastBindsPerSec,
"fast",
)
ch <- prometheus.MustNewConstMetric(
c.bindsTotal,
prometheus.CounterValue,
data[negotiatedBindsPerSec].FirstValue,
c.perfDataObject[0].NegotiatedBindsPerSec,
"negotiate",
)
ch <- prometheus.MustNewConstMetric(
c.bindsTotal,
prometheus.CounterValue,
data[ntlmBindsPerSec].FirstValue,
c.perfDataObject[0].NTLMBindsPerSec,
"ntlm",
)
ch <- prometheus.MustNewConstMetric(
c.bindsTotal,
prometheus.CounterValue,
data[simpleBindsPerSec].FirstValue,
c.perfDataObject[0].SimpleBindsPerSec,
"simple",
)
ch <- prometheus.MustNewConstMetric(
c.bindsTotal,
prometheus.CounterValue,
data[ldapSuccessfulBindsPerSec].FirstValue,
c.perfDataObject[0].LdapSuccessfulBindsPerSec,
"ldap",
)
ch <- prometheus.MustNewConstMetric(
c.replicationHighestUsn,
prometheus.CounterValue,
float64(uint64(data[draHighestUSNCommittedHighPart].FirstValue)<<32)+data[draHighestUSNCommittedLowPart].FirstValue,
float64(uint64(c.perfDataObject[0].DRAHighestUSNCommittedHighPart)<<32)+c.perfDataObject[0].DRAHighestUSNCommittedLowPart,
"committed",
)
ch <- prometheus.MustNewConstMetric(
c.replicationHighestUsn,
prometheus.CounterValue,
float64(uint64(data[draHighestUSNIssuedHighPart].FirstValue)<<32)+data[draHighestUSNIssuedLowPart].FirstValue,
float64(uint64(c.perfDataObject[0].DRAHighestUSNIssuedHighPart)<<32)+c.perfDataObject[0].DRAHighestUSNIssuedLowPart,
"issued",
)
ch <- prometheus.MustNewConstMetric(
c.interSiteReplicationDataBytesTotal,
prometheus.CounterValue,
data[draInboundBytesCompressedBetweenSitesAfterCompressionPerSec].FirstValue,
c.perfDataObject[0].DRAInboundBytesCompressedBetweenSitesAfterCompressionPerSec,
"inbound",
)
// The pre-compression perfData size seems to have little value? Skipping for now
@@ -879,7 +729,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(
c.interSiteReplicationDataBytesTotal,
prometheus.CounterValue,
data[draOutboundBytesCompressedBetweenSitesAfterCompressionPerSec].FirstValue,
c.perfDataObject[0].DRAOutboundBytesCompressedBetweenSitesAfterCompressionPerSec,
"outbound",
)
// ch <- prometheus.MustNewConstMetric(
@@ -891,270 +741,270 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(
c.intraSiteReplicationDataBytesTotal,
prometheus.CounterValue,
data[draInboundBytesNotCompressedWithinSitePerSec].FirstValue,
c.perfDataObject[0].DRAInboundBytesNotCompressedWithinSitePerSec,
"inbound",
)
ch <- prometheus.MustNewConstMetric(
c.intraSiteReplicationDataBytesTotal,
prometheus.CounterValue,
data[draOutboundBytesNotCompressedWithinSitePerSec].FirstValue,
c.perfDataObject[0].DRAOutboundBytesNotCompressedWithinSitePerSec,
"outbound",
)
ch <- prometheus.MustNewConstMetric(
c.replicationInboundSyncObjectsRemaining,
prometheus.GaugeValue,
data[draInboundFullSyncObjectsRemaining].FirstValue,
c.perfDataObject[0].DRAInboundFullSyncObjectsRemaining,
)
ch <- prometheus.MustNewConstMetric(
c.replicationInboundLinkValueUpdatesRemaining,
prometheus.GaugeValue,
data[draInboundLinkValueUpdatesRemainingInPacket].FirstValue,
c.perfDataObject[0].DRAInboundLinkValueUpdatesRemainingInPacket,
)
ch <- prometheus.MustNewConstMetric(
c.replicationInboundObjectsUpdatedTotal,
prometheus.CounterValue,
data[draInboundObjectsAppliedPerSec].FirstValue,
c.perfDataObject[0].DRAInboundObjectsAppliedPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.replicationInboundObjectsFilteredTotal,
prometheus.CounterValue,
data[draInboundObjectsFilteredPerSec].FirstValue,
c.perfDataObject[0].DRAInboundObjectsFilteredPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.replicationInboundPropertiesUpdatedTotal,
prometheus.CounterValue,
data[draInboundPropertiesAppliedPerSec].FirstValue,
c.perfDataObject[0].DRAInboundPropertiesAppliedPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.replicationInboundPropertiesFilteredTotal,
prometheus.CounterValue,
data[draInboundPropertiesFilteredPerSec].FirstValue,
c.perfDataObject[0].DRAInboundPropertiesFilteredPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.replicationPendingOperations,
prometheus.GaugeValue,
data[draPendingReplicationOperations].FirstValue,
c.perfDataObject[0].DRAPendingReplicationOperations,
)
ch <- prometheus.MustNewConstMetric(
c.replicationPendingSynchronizations,
prometheus.GaugeValue,
data[draPendingReplicationSynchronizations].FirstValue,
c.perfDataObject[0].DRAPendingReplicationSynchronizations,
)
ch <- prometheus.MustNewConstMetric(
c.replicationSyncRequestsTotal,
prometheus.CounterValue,
data[draSyncRequestsMade].FirstValue,
c.perfDataObject[0].DRASyncRequestsMade,
)
ch <- prometheus.MustNewConstMetric(
c.replicationSyncRequestsSuccessTotal,
prometheus.CounterValue,
data[draSyncRequestsSuccessful].FirstValue,
c.perfDataObject[0].DRASyncRequestsSuccessful,
)
ch <- prometheus.MustNewConstMetric(
c.replicationSyncRequestsSchemaMismatchFailureTotal,
prometheus.CounterValue,
data[draSyncFailuresOnSchemaMismatch].FirstValue,
c.perfDataObject[0].DRASyncFailuresOnSchemaMismatch,
)
ch <- prometheus.MustNewConstMetric(
c.nameTranslationsTotal,
prometheus.CounterValue,
data[dsClientNameTranslationsPerSec].FirstValue,
c.perfDataObject[0].DsClientNameTranslationsPerSec,
"client",
)
ch <- prometheus.MustNewConstMetric(
c.nameTranslationsTotal,
prometheus.CounterValue,
data[dsServerNameTranslationsPerSec].FirstValue,
c.perfDataObject[0].DsServerNameTranslationsPerSec,
"server",
)
ch <- prometheus.MustNewConstMetric(
c.changeMonitorsRegistered,
prometheus.GaugeValue,
data[dsMonitorListSize].FirstValue,
c.perfDataObject[0].DsMonitorListSize,
)
ch <- prometheus.MustNewConstMetric(
c.changeMonitorUpdatesPending,
prometheus.GaugeValue,
data[dsNotifyQueueSize].FirstValue,
c.perfDataObject[0].DsNotifyQueueSize,
)
ch <- prometheus.MustNewConstMetric(
c.nameCacheHitsTotal,
prometheus.CounterValue,
data[dsNameCacheHitRate].FirstValue,
c.perfDataObject[0].DsNameCacheHitRate,
)
ch <- prometheus.MustNewConstMetric(
c.nameCacheLookupsTotal,
prometheus.CounterValue,
data[dsNameCacheHitRate].SecondValue,
c.perfDataObject[0].DsNameCacheHitRateSecondValue,
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentReadsFromDRA].FirstValue,
c.perfDataObject[0].DsPercentReadsFromDRA,
"read",
"replication_agent",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentReadsFromKCC].FirstValue,
c.perfDataObject[0].DsPercentReadsFromKCC,
"read",
"knowledge_consistency_checker",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentReadsFromLSA].FirstValue,
c.perfDataObject[0].DsPercentReadsFromLSA,
"read",
"local_security_authority",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentReadsFromNSPI].FirstValue,
c.perfDataObject[0].DsPercentReadsFromNSPI,
"read",
"name_service_provider_interface",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentReadsFromNTDSAPI].FirstValue,
c.perfDataObject[0].DsPercentReadsFromNTDSAPI,
"read",
"directory_service_api",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentReadsFromSAM].FirstValue,
c.perfDataObject[0].DsPercentReadsFromSAM,
"read",
"security_account_manager",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentReadsOther].FirstValue,
c.perfDataObject[0].DsPercentReadsOther,
"read",
"other",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentSearchesFromDRA].FirstValue,
c.perfDataObject[0].DsPercentSearchesFromDRA,
"search",
"replication_agent",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentSearchesFromKCC].FirstValue,
c.perfDataObject[0].DsPercentSearchesFromKCC,
"search",
"knowledge_consistency_checker",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentSearchesFromLDAP].FirstValue,
c.perfDataObject[0].DsPercentSearchesFromLDAP,
"search",
"ldap",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentSearchesFromLSA].FirstValue,
c.perfDataObject[0].DsPercentSearchesFromLSA,
"search",
"local_security_authority",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentSearchesFromNSPI].FirstValue,
c.perfDataObject[0].DsPercentSearchesFromNSPI,
"search",
"name_service_provider_interface",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentSearchesFromNTDSAPI].FirstValue,
c.perfDataObject[0].DsPercentSearchesFromNTDSAPI,
"search",
"directory_service_api",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentSearchesFromSAM].FirstValue,
c.perfDataObject[0].DsPercentSearchesFromSAM,
"search",
"security_account_manager",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentSearchesOther].FirstValue,
c.perfDataObject[0].DsPercentSearchesOther,
"search",
"other",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentWritesFromDRA].FirstValue,
c.perfDataObject[0].DsPercentWritesFromDRA,
"write",
"replication_agent",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentWritesFromKCC].FirstValue,
c.perfDataObject[0].DsPercentWritesFromKCC,
"write",
"knowledge_consistency_checker",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentWritesFromLDAP].FirstValue,
c.perfDataObject[0].DsPercentWritesFromLDAP,
"write",
"ldap",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentSearchesFromLSA].FirstValue,
c.perfDataObject[0].DsPercentSearchesFromLSA,
"write",
"local_security_authority",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentWritesFromNSPI].FirstValue,
c.perfDataObject[0].DsPercentWritesFromNSPI,
"write",
"name_service_provider_interface",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentWritesFromNTDSAPI].FirstValue,
c.perfDataObject[0].DsPercentWritesFromNTDSAPI,
"write",
"directory_service_api",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentWritesFromSAM].FirstValue,
c.perfDataObject[0].DsPercentWritesFromSAM,
"write",
"security_account_manager",
)
ch <- prometheus.MustNewConstMetric(
c.directoryOperationsTotal,
prometheus.CounterValue,
data[dsPercentWritesOther].FirstValue,
c.perfDataObject[0].DsPercentWritesOther,
"write",
"other",
)
@@ -1162,207 +1012,207 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(
c.directorySearchSubOperationsTotal,
prometheus.CounterValue,
data[dsSearchSubOperationsPerSec].FirstValue,
c.perfDataObject[0].DsSearchSubOperationsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.securityDescriptorPropagationEventsTotal,
prometheus.CounterValue,
data[dsSecurityDescriptorSubOperationsPerSec].FirstValue,
c.perfDataObject[0].DsSecurityDescriptorSubOperationsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.securityDescriptorPropagationEventsQueued,
prometheus.GaugeValue,
data[dsSecurityDescriptorPropagationsEvents].FirstValue,
c.perfDataObject[0].DsSecurityDescriptorPropagationsEvents,
)
ch <- prometheus.MustNewConstMetric(
c.securityDescriptorPropagationAccessWaitTotalSeconds,
prometheus.GaugeValue,
data[dsSecurityDescriptorPropagatorAverageExclusionTime].FirstValue,
c.perfDataObject[0].DsSecurityDescriptorPropagatorAverageExclusionTime,
)
ch <- prometheus.MustNewConstMetric(
c.securityDescriptorPropagationItemsQueuedTotal,
prometheus.CounterValue,
data[dsSecurityDescriptorPropagatorRuntimeQueue].FirstValue,
c.perfDataObject[0].DsSecurityDescriptorPropagatorRuntimeQueue,
)
ch <- prometheus.MustNewConstMetric(
c.directoryServiceThreads,
prometheus.GaugeValue,
data[dsThreadsInUse].FirstValue,
c.perfDataObject[0].DsThreadsInUse,
)
ch <- prometheus.MustNewConstMetric(
c.ldapClosedConnectionsTotal,
prometheus.CounterValue,
data[ldapClosedConnectionsPerSec].FirstValue,
c.perfDataObject[0].LdapClosedConnectionsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.ldapOpenedConnectionsTotal,
prometheus.CounterValue,
data[ldapNewConnectionsPerSec].FirstValue,
c.perfDataObject[0].LdapNewConnectionsPerSec,
"ldap",
)
ch <- prometheus.MustNewConstMetric(
c.ldapOpenedConnectionsTotal,
prometheus.CounterValue,
data[ldapNewSSLConnectionsPerSec].FirstValue,
c.perfDataObject[0].LdapNewSSLConnectionsPerSec,
"ldaps",
)
ch <- prometheus.MustNewConstMetric(
c.ldapActiveThreads,
prometheus.GaugeValue,
data[ldapActiveThreads].FirstValue,
c.perfDataObject[0].LdapActiveThreads,
)
ch <- prometheus.MustNewConstMetric(
c.ldapLastBindTimeSeconds,
prometheus.GaugeValue,
data[ldapBindTime].FirstValue/1000,
c.perfDataObject[0].LdapBindTime/1000,
)
ch <- prometheus.MustNewConstMetric(
c.ldapSearchesTotal,
prometheus.CounterValue,
data[ldapSearchesPerSec].FirstValue,
c.perfDataObject[0].LdapSearchesPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.ldapUdpOperationsTotal,
prometheus.CounterValue,
data[ldapUDPOperationsPerSec].FirstValue,
c.perfDataObject[0].LdapUDPOperationsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.ldapWritesTotal,
prometheus.CounterValue,
data[ldapWritesPerSec].FirstValue,
c.perfDataObject[0].LdapWritesPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.ldapClientSessions,
prometheus.GaugeValue,
data[ldapClientSessions].FirstValue,
c.perfDataObject[0].LdapClientSessions,
)
ch <- prometheus.MustNewConstMetric(
c.linkValuesCleanedTotal,
prometheus.CounterValue,
data[linkValuesCleanedPerSec].FirstValue,
c.perfDataObject[0].LinkValuesCleanedPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.phantomObjectsCleanedTotal,
prometheus.CounterValue,
data[phantomsCleanedPerSec].FirstValue,
c.perfDataObject[0].PhantomsCleanedPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.phantomObjectsVisitedTotal,
prometheus.CounterValue,
data[phantomsVisitedPerSec].FirstValue,
c.perfDataObject[0].PhantomsVisitedPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.samGroupMembershipEvaluationsTotal,
prometheus.CounterValue,
data[samGlobalGroupMembershipEvaluationsPerSec].FirstValue,
c.perfDataObject[0].SamGlobalGroupMembershipEvaluationsPerSec,
"global",
)
ch <- prometheus.MustNewConstMetric(
c.samGroupMembershipEvaluationsTotal,
prometheus.CounterValue,
data[samDomainLocalGroupMembershipEvaluationsPerSec].FirstValue,
c.perfDataObject[0].SamDomainLocalGroupMembershipEvaluationsPerSec,
"domain_local",
)
ch <- prometheus.MustNewConstMetric(
c.samGroupMembershipEvaluationsTotal,
prometheus.CounterValue,
data[samUniversalGroupMembershipEvaluationsPerSec].FirstValue,
c.perfDataObject[0].SamUniversalGroupMembershipEvaluationsPerSec,
"universal",
)
ch <- prometheus.MustNewConstMetric(
c.samGroupMembershipGlobalCatalogEvaluationsTotal,
prometheus.CounterValue,
data[samGCEvaluationsPerSec].FirstValue,
c.perfDataObject[0].SamGCEvaluationsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.samGroupMembershipEvaluationsNonTransitiveTotal,
prometheus.CounterValue,
data[samNonTransitiveMembershipEvaluationsPerSec].FirstValue,
c.perfDataObject[0].SamNonTransitiveMembershipEvaluationsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.samGroupMembershipEvaluationsTransitiveTotal,
prometheus.CounterValue,
data[samTransitiveMembershipEvaluationsPerSec].FirstValue,
c.perfDataObject[0].SamTransitiveMembershipEvaluationsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.samGroupEvaluationLatency,
prometheus.GaugeValue,
data[samAccountGroupEvaluationLatency].FirstValue,
c.perfDataObject[0].SamAccountGroupEvaluationLatency,
"account_group",
)
ch <- prometheus.MustNewConstMetric(
c.samGroupEvaluationLatency,
prometheus.GaugeValue,
data[samResourceGroupEvaluationLatency].FirstValue,
c.perfDataObject[0].SamResourceGroupEvaluationLatency,
"resource_group",
)
ch <- prometheus.MustNewConstMetric(
c.samComputerCreationRequestsTotal,
prometheus.CounterValue,
data[samSuccessfulComputerCreationsPerSecIncludesAllRequests].FirstValue,
c.perfDataObject[0].SamSuccessfulComputerCreationsPerSecIncludesAllRequests,
)
ch <- prometheus.MustNewConstMetric(
c.samComputerCreationSuccessfulRequestsTotal,
prometheus.CounterValue,
data[samMachineCreationAttemptsPerSec].FirstValue,
c.perfDataObject[0].SamMachineCreationAttemptsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.samUserCreationRequestsTotal,
prometheus.CounterValue,
data[samUserCreationAttemptsPerSec].FirstValue,
c.perfDataObject[0].SamUserCreationAttemptsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.samUserCreationSuccessfulRequestsTotal,
prometheus.CounterValue,
data[samSuccessfulUserCreationsPerSec].FirstValue,
c.perfDataObject[0].SamSuccessfulUserCreationsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.samQueryDisplayRequestsTotal,
prometheus.CounterValue,
data[samDisplayInformationQueriesPerSec].FirstValue,
c.perfDataObject[0].SamDisplayInformationQueriesPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.samEnumerationsTotal,
prometheus.CounterValue,
data[samEnumerationsPerSec].FirstValue,
c.perfDataObject[0].SamEnumerationsPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.samMembershipChangesTotal,
prometheus.CounterValue,
data[samMembershipChangesPerSec].FirstValue,
c.perfDataObject[0].SamMembershipChangesPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.samPasswordChangesTotal,
prometheus.CounterValue,
data[samPasswordChangesPerSec].FirstValue,
c.perfDataObject[0].SamPasswordChangesPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.tombstonesObjectsCollectedTotal,
prometheus.CounterValue,
data[tombstonesGarbageCollectedPerSec].FirstValue,
c.perfDataObject[0].TombstonesGarbageCollectedPerSec,
)
ch <- prometheus.MustNewConstMetric(
c.tombstonesObjectsVisitedTotal,
prometheus.CounterValue,
data[tombstonesVisitedPerSec].FirstValue,
c.perfDataObject[0].TombstonesVisitedPerSec,
)
return nil

View File

@@ -25,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,222 +0,0 @@
// 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
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

@@ -21,7 +21,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"
@@ -37,7 +37,8 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
challengeResponseProcessingTime *prometheus.Desc
challengeResponsesPerSecond *prometheus.Desc
@@ -81,27 +82,6 @@ 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.InstancesAll, []string{
requestsPerSecond,
requestProcessingTime,
retrievalsPerSecond,
retrievalProcessingTime,
failedRequestsPerSecond,
issuedRequestsPerSecond,
pendingRequestsPerSecond,
requestCryptographicSigningTime,
requestPolicyModuleProcessingTime,
challengeResponsesPerSecond,
challengeResponseProcessingTime,
signedCertificateTimestampListsPerSecond,
signedCertificateTimestampListProcessingTime,
})
if err != nil {
return fmt.Errorf("failed to create Certification Authority collector: %w", err)
}
c.requestsPerSecond = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "requests_total"),
"Total certificate requests processed",
@@ -181,97 +161,100 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
nil,
)
var err error
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "Certification Authority", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Certification Authority collector: %w", err)
}
return nil
}
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 fmt.Errorf("failed to collect Certification Authority (ADCS) metrics: %w", types.ErrNoData)
}
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

@@ -25,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,32 +0,0 @@
// 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
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

@@ -18,13 +18,11 @@ package adfs
import (
"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"
)
@@ -39,7 +37,8 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
adLoginConnectionFailures *prometheus.Desc
artifactDBFailures *prometheus.Desc
@@ -113,57 +112,6 @@ func (c *Collector) Close() error {
}
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error
c.perfDataCollector, err = perfdata.NewCollector("AD FS", nil, []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,
})
if err != nil {
return fmt.Errorf("failed to create AD FS collector: %w", err)
}
c.adLoginConnectionFailures = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "ad_login_connection_failures_total"),
"Total number of connection failures to an Active Directory domain controller",
@@ -423,283 +371,280 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
nil,
)
var err error
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "AD FS", nil)
if err != nil {
return fmt.Errorf("failed to create AD FS collector: %w", err)
}
return nil
}
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 fmt.Errorf("failed to collect ADFS metrics: %w", types.ErrNoData)
}
adfsData, ok := data[instanceKey[0]]
if !ok {
return fmt.Errorf("failed to collect ADFS metrics: %w", types.ErrNoData)
} else if len(c.perfDataObject) == 0 {
return fmt.Errorf("failed to collect ADFS metrics: %w", types.ErrNoDataUnexpected)
}
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

@@ -25,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,62 +0,0 @@
// 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
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 Authentications"
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

@@ -21,7 +21,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"
)
@@ -37,7 +37,8 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
asyncCopyReadsTotal *prometheus.Desc
asyncDataMapsTotal *prometheus.Desc
@@ -97,43 +98,6 @@ func (c *Collector) Close() error {
}
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error
c.perfDataCollector, err = perfdata.NewCollector("Cache", perfdata.InstancesAll, []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,
})
if err != nil {
return fmt.Errorf("failed to create Cache collector: %w", err)
}
c.asyncCopyReadsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "async_copy_reads_total"),
"(AsyncCopyReadsTotal)",
@@ -309,194 +273,197 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
nil,
)
var err error
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "Cache", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Cache collector: %w", err)
}
return nil
}
// 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.InstanceEmpty]
if !ok {
return fmt.Errorf("failed to collect Cache metrics: %w", types.ErrNoData)
} else if len(c.perfDataObject) == 0 {
return fmt.Errorf("failed to collect Cache metrics: %w", types.ErrNoDataUnexpected)
}
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

@@ -25,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,50 +0,0 @@
// 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)
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

@@ -24,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"
)
@@ -322,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

@@ -25,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,43 +0,0 @@
// 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.
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

@@ -22,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"
@@ -38,7 +38,8 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config
perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector
perfDataObject []perfDataCounterValues
mu sync.Mutex
@@ -88,39 +89,8 @@ func (c *Collector) Close() error {
}
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error
c.mu = sync.Mutex{}
c.perfDataCollector, err = perfdata.NewCollector("Processor Information", perfdata.InstancesAll, []string{
c1TimeSeconds,
c2TimeSeconds,
c3TimeSeconds,
c1TransitionsTotal,
c2TransitionsTotal,
c3TransitionsTotal,
clockInterruptsTotal,
dpcQueuedPerSecond,
dpcTimeSeconds,
idleBreakEventsTotal,
idleTimeSeconds,
interruptsTotal,
interruptTimeSeconds,
parkingStatus,
performanceLimitPercent,
priorityTimeSeconds,
privilegedTimeSeconds,
privilegedUtilitySeconds,
processorFrequencyMHz,
processorPerformance,
processorTimeSeconds,
processorUtilityRate,
userTimeSeconds,
})
if err != nil {
return fmt.Errorf("failed to create Processor Information collector: %w", err)
}
c.logicalProcessors = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "logical_processor"),
"Total number of logical processors",
@@ -209,6 +179,13 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
c.processorRTCValues = map[string]utils.Counter{}
c.processorMPerfValues = map[string]utils.Counter{}
var err error
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "Processor Information", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Processor Information collector: %w", err)
}
return nil
}
@@ -216,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 (
@@ -233,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
@@ -251,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(
@@ -357,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

@@ -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

@@ -75,18 +75,6 @@ func (c *Collector) Close() error {
}
func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
if miSession == nil {
return errors.New("miSession is nil")
}
miQuery, err := mi.NewQuery("SELECT Architecture, DeviceId, Description, Family, L2CacheSize, L3CacheSize, Name, ThreadCount, NumberOfCores, NumberOfEnabledCore, NumberOfLogicalProcessors FROM Win32_Processor")
if err != nil {
return fmt.Errorf("failed to create WMI query: %w", err)
}
c.miQuery = miQuery
c.miSession = miSession
c.cpuInfo = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, "", Name),
"Labelled CPU information as provided by Win32_Processor",
@@ -148,6 +136,18 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
nil,
)
if miSession == nil {
return errors.New("miSession is nil")
}
miQuery, err := mi.NewQuery("SELECT Architecture, DeviceId, Description, Family, L2CacheSize, L3CacheSize, Name, ThreadCount, NumberOfCores, NumberOfEnabledCore, NumberOfLogicalProcessors FROM Win32_Processor")
if err != nil {
return fmt.Errorf("failed to create WMI query: %w", err)
}
c.miQuery = miQuery
c.miSession = miSession
var dst []miProcessor
if err := c.miSession.Query(&dst, mi.NamespaceRootCIMv2, c.miQuery); err != nil {
return fmt.Errorf("WMI query failed: %w", err)

View File

@@ -37,7 +37,7 @@ type Collector struct {
config Config
// physicalMemoryBytes
// Deprecated: Use windows_physical_memory_total_bytes instead
// Deprecated: Use windows_memory_physical_total_bytes instead
physicalMemoryBytes *prometheus.Desc
// logicalProcessors
// Deprecated: Use windows_cpu_logical_processor instead
@@ -85,7 +85,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
)
c.physicalMemoryBytes = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "physical_memory_bytes"),
"Deprecated: Use windows_physical_memory_total_bytes instead",
"Deprecated: Use windows_memory_physical_total_bytes instead",
nil,
nil,
)

View File

@@ -25,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,57 +0,0 @@
// 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
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 Unread Percentage"
)

View File

@@ -24,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"
)
@@ -44,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
@@ -157,72 +160,6 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
logger.Info("dfsr collector is in an experimental state! Metrics for this collector have not been tested.")
var err error
if slices.Contains(c.config.CollectorsEnabled, "connection") {
c.perfDataCollectorConnection, err = perfdata.NewCollector("DFS Replication Connections", perfdata.InstancesAll, []string{
bandwidthSavingsUsingDFSReplicationTotal,
bytesReceivedTotal,
compressedSizeOfFilesReceivedTotal,
filesReceivedTotal,
rdcBytesReceivedTotal,
rdcCompressedSizeOfFilesReceivedTotal,
rdcNumberOfFilesReceivedTotal,
rdcSizeOfFilesReceivedTotal,
sizeOfFilesReceivedTotal,
})
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.InstancesAll, []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,
})
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.InstancesAll, []string{
databaseCommitsTotal,
databaseLookupsTotal,
usnJournalRecordsReadTotal,
usnJournalRecordsAcceptedTotal,
usnJournalUnreadPercentage,
})
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"),
@@ -513,13 +450,36 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
nil,
)
var err error
if slices.Contains(c.config.CollectorsEnabled, "connection") {
c.perfDataCollectorConnection, err = pdh.NewCollector[perfDataCounterValuesConnection](pdh.CounterTypeRaw, "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 = pdh.NewCollector[perfDataCounterValuesFolder](pdh.CounterTypeRaw, "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 = pdh.NewCollector[perfDataCounterValuesVolume](pdh.CounterTypeRaw, "DFS Replication Service Volumes", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create DFS Replication Service Volumes collector: %w", err)
}
}
return nil
}
// Collect implements the Collector interface.
// Sends metric values for each metric to the provided prometheus Metric channel.
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
errs := make([]error, 0, 3)
errs := make([]error, 0)
if slices.Contains(c.config.CollectorsEnabled, "connection") {
errs = append(errs, c.collectPDHConnection(ch))
@@ -537,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 fmt.Errorf("failed to collect DFS Replication Connections metrics: %w", types.ErrNoData)
}
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,
)
}
@@ -615,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 fmt.Errorf("failed to collect DFS Replicated Folders metrics: %w", types.ErrNoData)
}
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,
)
}
@@ -819,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 fmt.Errorf("failed to collect DFS Replication Volumes metrics: %w", types.ErrNoData)
}
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

@@ -25,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,44 +0,0 @@
// 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
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

@@ -16,28 +16,46 @@
package dhcp
import (
"errors"
"fmt"
"log/slog"
"slices"
"strconv"
"strings"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/headers/dhcpsapi"
"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"
)
const Name = "dhcp"
const (
Name = "dhcp"
type Config struct{}
subCollectorServerMetrics = "server_metrics"
subCollectorScopeMetrics = "scope_metrics"
)
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
var ConfigDefaults = Config{
CollectorsEnabled: []string{
subCollectorServerMetrics,
subCollectorScopeMetrics,
},
}
// 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
@@ -64,6 +82,17 @@ type Collector struct {
packetsReceivedTotal *prometheus.Desc
releasesTotal *prometheus.Desc
requestsTotal *prometheus.Desc
scopeInfo *prometheus.Desc
scopeState *prometheus.Desc
scopeAddressesFreeTotal *prometheus.Desc
scopeAddressesFreeOnPartnerServerTotal *prometheus.Desc
scopeAddressesFreeOnThisServerTotal *prometheus.Desc
scopeAddressesInUseTotal *prometheus.Desc
scopeAddressesInUseOnPartnerServerTotal *prometheus.Desc
scopeAddressesInUseOnThisServerTotal *prometheus.Desc
scopePendingOffersTotal *prometheus.Desc
scopeReservedAddressTotal *prometheus.Desc
}
func New(config *Config) *Collector {
@@ -71,6 +100,10 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}
if config.CollectorsEnabled == nil {
config.CollectorsEnabled = ConfigDefaults.CollectorsEnabled
}
c := &Collector{
config: *config,
}
@@ -78,8 +111,26 @@ func New(config *Config) *Collector {
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
func NewWithFlags(app *kingpin.Application) *Collector {
c := &Collector{
config: ConfigDefaults,
}
c.config.CollectorsEnabled = make([]string, 0)
var collectorsEnabled string
app.Flag(
"collector.dhcp.enabled",
"Comma-separated list of collectors to use. Defaults to all, if not specified.",
).Default(strings.Join(ConfigDefaults.CollectorsEnabled, ",")).StringVar(&collectorsEnabled)
app.Action(func(*kingpin.ParseContext) error {
c.config.CollectorsEnabled = strings.Split(collectorsEnabled, ",")
return nil
})
return c
}
func (c *Collector) GetName() string {
@@ -87,7 +138,9 @@ func (c *Collector) GetName() string {
}
func (c *Collector) Close() error {
c.perfDataCollector.Close()
if slices.Contains(c.config.CollectorsEnabled, subCollectorServerMetrics) {
c.perfDataCollector.Close()
}
return nil
}
@@ -95,351 +148,524 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error
c.perfDataCollector, err = perfdata.NewCollector("DHCP Server", nil, []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,
})
if err != nil {
return fmt.Errorf("failed to create DHCP Server collector: %w", err)
if slices.Contains(c.config.CollectorsEnabled, subCollectorScopeMetrics) {
c.scopeInfo = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "scope_info"),
"DHCP Scope information",
[]string{"name", "superscope_name", "superscope_id", "scope"},
nil,
)
c.scopeState = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "scope_state"),
"DHCP Scope state",
[]string{"scope", "state"},
nil,
)
c.scopeAddressesFreeTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "scope_addresses_free"),
"DHCP Scope free addresses",
[]string{"scope"},
nil,
)
c.scopeAddressesFreeOnPartnerServerTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "scope_addresses_free_on_partner_server"),
"DHCP Scope free addresses on partner server",
[]string{"scope"},
nil,
)
c.scopeAddressesFreeOnThisServerTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "scope_addresses_free_on_this_server"),
"DHCP Scope free addresses on this server",
[]string{"scope"},
nil,
)
c.scopeAddressesInUseTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "scope_addresses_in_use"),
"DHCP Scope addresses in use",
[]string{"scope"},
nil,
)
c.scopeAddressesInUseOnPartnerServerTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "scope_addresses_in_use_on_partner_server"),
"DHCP Scope addresses in use on partner server",
[]string{"scope"},
nil,
)
c.scopeAddressesInUseOnThisServerTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "scope_addresses_in_use_on_this_server"),
"DHCP Scope addresses in use on this server",
[]string{"scope"},
nil,
)
c.scopePendingOffersTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "scope_pending_offers"),
"DHCP Scope pending offers",
[]string{"scope"},
nil,
)
c.scopeReservedAddressTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "scope_reserved_address"),
"DHCP Scope reserved addresses",
[]string{"scope"},
nil,
)
}
c.packetsReceivedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "packets_received_total"),
"Total number of packets received by the DHCP server (PacketsReceivedTotal)",
nil,
nil,
)
c.duplicatesDroppedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "duplicates_dropped_total"),
"Total number of duplicate packets received by the DHCP server (DuplicatesDroppedTotal)",
nil,
nil,
)
c.packetsExpiredTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "packets_expired_total"),
"Total number of packets expired in the DHCP server message queue (PacketsExpiredTotal)",
nil,
nil,
)
c.activeQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "active_queue_length"),
"Number of packets in the processing queue of the DHCP server (ActiveQueueLength)",
nil,
nil,
)
c.conflictCheckQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "conflict_check_queue_length"),
"Number of packets in the DHCP server queue waiting on conflict detection (ping). (ConflictCheckQueueLength)",
nil,
nil,
)
c.discoversTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "discovers_total"),
"Total DHCP Discovers received by the DHCP server (DiscoversTotal)",
nil,
nil,
)
c.offersTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "offers_total"),
"Total DHCP Offers sent by the DHCP server (OffersTotal)",
nil,
nil,
)
c.requestsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "requests_total"),
"Total DHCP Requests received by the DHCP server (RequestsTotal)",
nil,
nil,
)
c.informsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "informs_total"),
"Total DHCP Informs received by the DHCP server (InformsTotal)",
nil,
nil,
)
c.acksTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "acks_total"),
"Total DHCP Acks sent by the DHCP server (AcksTotal)",
nil,
nil,
)
c.nACKsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "nacks_total"),
"Total DHCP Nacks sent by the DHCP server (NacksTotal)",
nil,
nil,
)
c.declinesTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "declines_total"),
"Total DHCP Declines received by the DHCP server (DeclinesTotal)",
nil,
nil,
)
c.releasesTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "releases_total"),
"Total DHCP Releases received by the DHCP server (ReleasesTotal)",
nil,
nil,
)
c.offerQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "offer_queue_length"),
"Number of packets in the offer queue of the DHCP server (OfferQueueLength)",
nil,
nil,
)
c.deniedDueToMatch = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "denied_due_to_match_total"),
"Total number of DHCP requests denied, based on matches from the Deny list (DeniedDueToMatch)",
nil,
nil,
)
c.deniedDueToNonMatch = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "denied_due_to_nonmatch_total"),
"Total number of DHCP requests denied, based on non-matches from the Allow list (DeniedDueToNonMatch)",
nil,
nil,
)
c.failoverBndUpdSentTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndupd_sent_total"),
"Number of DHCP fail over Binding Update messages sent (FailoverBndupdSentTotal)",
nil,
nil,
)
c.failoverBndUpdReceivedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndupd_received_total"),
"Number of DHCP fail over Binding Update messages received (FailoverBndupdReceivedTotal)",
nil,
nil,
)
c.failoverBndAckSentTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndack_sent_total"),
"Number of DHCP fail over Binding Ack messages sent (FailoverBndackSentTotal)",
nil,
nil,
)
c.failoverBndAckReceivedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndack_received_total"),
"Number of DHCP fail over Binding Ack messages received (FailoverBndackReceivedTotal)",
nil,
nil,
)
c.failoverBndUpdPendingOutboundQueue = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndupd_pending_in_outbound_queue"),
"Number of pending outbound DHCP fail over Binding Update messages (FailoverBndupdPendingOutboundQueue)",
nil,
nil,
)
c.failoverTransitionsCommunicationInterruptedState = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_transitions_communicationinterrupted_state_total"),
"Total number of transitions into COMMUNICATION INTERRUPTED state (FailoverTransitionsCommunicationinterruptedState)",
nil,
nil,
)
c.failoverTransitionsPartnerDownState = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_transitions_partnerdown_state_total"),
"Total number of transitions into PARTNER DOWN state (FailoverTransitionsPartnerdownState)",
nil,
nil,
)
c.failoverTransitionsRecoverState = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_transitions_recover_total"),
"Total number of transitions into RECOVER state (FailoverTransitionsRecoverState)",
nil,
nil,
)
c.failoverBndUpdDropped = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndupd_dropped_total"),
"Total number of DHCP fail over Binding Updates dropped (FailoverBndupdDropped)",
nil,
nil,
)
if slices.Contains(c.config.CollectorsEnabled, subCollectorServerMetrics) {
c.packetsReceivedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "packets_received_total"),
"Total number of packets received by the DHCP server (PacketsReceivedTotal)",
nil,
nil,
)
c.duplicatesDroppedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "duplicates_dropped_total"),
"Total number of duplicate packets received by the DHCP server (DuplicatesDroppedTotal)",
nil,
nil,
)
c.packetsExpiredTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "packets_expired_total"),
"Total number of packets expired in the DHCP server message queue (PacketsExpiredTotal)",
nil,
nil,
)
c.activeQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "active_queue_length"),
"Number of packets in the processing queue of the DHCP server (ActiveQueueLength)",
nil,
nil,
)
c.conflictCheckQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "conflict_check_queue_length"),
"Number of packets in the DHCP server queue waiting on conflict detection (ping). (ConflictCheckQueueLength)",
nil,
nil,
)
c.discoversTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "discovers_total"),
"Total DHCP Discovers received by the DHCP server (DiscoversTotal)",
nil,
nil,
)
c.offersTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "offers_total"),
"Total DHCP Offers sent by the DHCP server (OffersTotal)",
nil,
nil,
)
c.requestsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "requests_total"),
"Total DHCP Requests received by the DHCP server (RequestsTotal)",
nil,
nil,
)
c.informsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "informs_total"),
"Total DHCP Informs received by the DHCP server (InformsTotal)",
nil,
nil,
)
c.acksTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "acks_total"),
"Total DHCP Acks sent by the DHCP server (AcksTotal)",
nil,
nil,
)
c.nACKsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "nacks_total"),
"Total DHCP Nacks sent by the DHCP server (NacksTotal)",
nil,
nil,
)
c.declinesTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "declines_total"),
"Total DHCP Declines received by the DHCP server (DeclinesTotal)",
nil,
nil,
)
c.releasesTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "releases_total"),
"Total DHCP Releases received by the DHCP server (ReleasesTotal)",
nil,
nil,
)
c.offerQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "offer_queue_length"),
"Number of packets in the offer queue of the DHCP server (OfferQueueLength)",
nil,
nil,
)
c.deniedDueToMatch = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "denied_due_to_match_total"),
"Total number of DHCP requests denied, based on matches from the Deny list (DeniedDueToMatch)",
nil,
nil,
)
c.deniedDueToNonMatch = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "denied_due_to_nonmatch_total"),
"Total number of DHCP requests denied, based on non-matches from the Allow list (DeniedDueToNonMatch)",
nil,
nil,
)
c.failoverBndUpdSentTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndupd_sent_total"),
"Number of DHCP fail over Binding Update messages sent (FailoverBndupdSentTotal)",
nil,
nil,
)
c.failoverBndUpdReceivedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndupd_received_total"),
"Number of DHCP fail over Binding Update messages received (FailoverBndupdReceivedTotal)",
nil,
nil,
)
c.failoverBndAckSentTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndack_sent_total"),
"Number of DHCP fail over Binding Ack messages sent (FailoverBndackSentTotal)",
nil,
nil,
)
c.failoverBndAckReceivedTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndack_received_total"),
"Number of DHCP fail over Binding Ack messages received (FailoverBndackReceivedTotal)",
nil,
nil,
)
c.failoverBndUpdPendingOutboundQueue = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndupd_pending_in_outbound_queue"),
"Number of pending outbound DHCP fail over Binding Update messages (FailoverBndupdPendingOutboundQueue)",
nil,
nil,
)
c.failoverTransitionsCommunicationInterruptedState = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_transitions_communicationinterrupted_state_total"),
"Total number of transitions into COMMUNICATION INTERRUPTED state (FailoverTransitionsCommunicationinterruptedState)",
nil,
nil,
)
c.failoverTransitionsPartnerDownState = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_transitions_partnerdown_state_total"),
"Total number of transitions into PARTNER DOWN state (FailoverTransitionsPartnerdownState)",
nil,
nil,
)
c.failoverTransitionsRecoverState = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_transitions_recover_total"),
"Total number of transitions into RECOVER state (FailoverTransitionsRecoverState)",
nil,
nil,
)
c.failoverBndUpdDropped = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "failover_bndupd_dropped_total"),
"Total number of DHCP fail over Binding Updates dropped (FailoverBndupdDropped)",
nil,
nil,
)
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "DHCP Server", nil)
if err != nil {
return fmt.Errorf("failed to create DHCP Server collector: %w", err)
}
}
return nil
}
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
perfData, err := c.perfDataCollector.Collect()
if err != nil {
return fmt.Errorf("failed to collect DHCP Server metrics: %w", err)
var errs []error
if slices.Contains(c.config.CollectorsEnabled, subCollectorServerMetrics) {
if err := c.collectServerMetrics(ch); err != nil {
errs = append(errs, err)
}
}
data, ok := perfData[perfdata.InstanceEmpty]
if !ok {
return fmt.Errorf("failed to collect DHCP Server metrics: %w", types.ErrNoData)
if slices.Contains(c.config.CollectorsEnabled, subCollectorScopeMetrics) {
if err := c.collectScopeMetrics(ch); err != nil {
errs = append(errs, err)
}
}
return errors.Join(errs...)
}
func (c *Collector) collectServerMetrics(ch chan<- prometheus.Metric) error {
err := c.perfDataCollector.Collect(&c.perfDataObject)
if err != nil {
return fmt.Errorf("failed to collect DHCP Server metrics: %w", err)
} else if len(c.perfDataObject) == 0 {
return fmt.Errorf("failed to collect DHCP Server metrics: %w", types.ErrNoDataUnexpected)
}
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
}
func (c *Collector) collectScopeMetrics(ch chan<- prometheus.Metric) error {
dhcpScopes, err := dhcpsapi.GetDHCPV4ScopeStatistics()
if err != nil {
return fmt.Errorf("failed to get DHCP scopes: %w", err)
}
for _, scope := range dhcpScopes {
scopeID := scope.ScopeIPAddress.String()
ch <- prometheus.MustNewConstMetric(
c.scopeInfo,
prometheus.GaugeValue,
1,
scope.Name,
scope.SuperScopeName,
strconv.Itoa(int(scope.SuperScopeNumber)),
scopeID,
)
for state, name := range dhcpsapi.DHCP_SUBNET_STATE_NAMES {
metric := 0.0
if state == scope.State {
metric = 1.0
}
ch <- prometheus.MustNewConstMetric(
c.scopeState,
prometheus.GaugeValue,
metric,
scopeID,
name,
)
}
if scope.AddressesFree != -1 {
ch <- prometheus.MustNewConstMetric(
c.scopeAddressesFreeTotal,
prometheus.GaugeValue,
scope.AddressesFree,
scopeID,
)
}
if scope.AddressesFreeOnPartnerServer != -1 {
ch <- prometheus.MustNewConstMetric(
c.scopeAddressesFreeOnPartnerServerTotal,
prometheus.GaugeValue,
scope.AddressesFreeOnPartnerServer,
scopeID,
)
}
if scope.AddressesFreeOnThisServer != -1 {
ch <- prometheus.MustNewConstMetric(
c.scopeAddressesFreeOnThisServerTotal,
prometheus.GaugeValue,
scope.AddressesFreeOnThisServer,
scopeID,
)
}
if scope.AddressesInUse != -1 {
ch <- prometheus.MustNewConstMetric(
c.scopeAddressesInUseTotal,
prometheus.GaugeValue,
scope.AddressesInUse,
scopeID,
)
}
if scope.AddressesInUseOnPartnerServer != -1 {
ch <- prometheus.MustNewConstMetric(
c.scopeAddressesInUseOnPartnerServerTotal,
prometheus.GaugeValue,
scope.AddressesInUseOnPartnerServer,
scopeID,
)
}
if scope.AddressesInUseOnThisServer != -1 {
ch <- prometheus.MustNewConstMetric(
c.scopeAddressesInUseOnThisServerTotal,
prometheus.GaugeValue,
scope.AddressesInUseOnThisServer,
scopeID,
)
}
if scope.PendingOffers != -1 {
ch <- prometheus.MustNewConstMetric(
c.scopePendingOffersTotal,
prometheus.GaugeValue,
scope.PendingOffers,
scopeID,
)
}
if scope.ReservedAddress != -1 {
ch <- prometheus.MustNewConstMetric(
c.scopeReservedAddressTotal,
prometheus.GaugeValue,
scope.ReservedAddress,
scopeID,
)
}
}
return nil
}

View File

@@ -25,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

@@ -72,18 +72,6 @@ func (c *Collector) Close() error {
}
func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
if miSession == nil {
return errors.New("miSession is nil")
}
miQuery, err := mi.NewQuery("SELECT DeviceID, Model, Caption, Name, Partitions, Size, Status, Availability FROM WIN32_DiskDrive")
if err != nil {
return fmt.Errorf("failed to create WMI query: %w", err)
}
c.miQuery = miQuery
c.miSession = miSession
c.diskInfo = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "info"),
"General drive information",
@@ -120,6 +108,18 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
nil,
)
if miSession == nil {
return errors.New("miSession is nil")
}
miQuery, err := mi.NewQuery("SELECT DeviceID, Model, Caption, Name, Partitions, Size, Status, Availability FROM WIN32_DiskDrive")
if err != nil {
return fmt.Errorf("failed to create WMI query: %w", err)
}
c.miQuery = miQuery
c.miSession = miSession
var dst []diskDrive
if err := c.miSession.Query(&dst, mi.NamespaceRootCIMv2, c.miQuery); err != nil {
return fmt.Errorf("WMI query failed: %w", err)

View File

@@ -25,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,107 +0,0 @@
// 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
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

@@ -16,28 +16,46 @@
package dns
import (
"errors"
"fmt"
"log/slog"
"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/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
const Name = "dns"
const (
Name = "dns"
subCollectorMetrics = "metrics"
subCollectorWMIStats = "wmi_stats"
)
type Config struct{}
type Config struct {
CollectorsEnabled []string `yaml:"collectors_enabled"`
}
//nolint:gochecknoglobals
var ConfigDefaults = Config{}
var ConfigDefaults = Config{
CollectorsEnabled: []string{
subCollectorMetrics,
subCollectorWMIStats,
},
}
// 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
miSession *mi.Session
miQuery mi.Query
dynamicUpdatesFailures *prometheus.Desc
dynamicUpdatesQueued *prometheus.Desc
@@ -61,6 +79,7 @@ type Collector struct {
zoneTransferResponsesReceived *prometheus.Desc
zoneTransferSuccessReceived *prometheus.Desc
zoneTransferSuccessSent *prometheus.Desc
dnsWMIStats *prometheus.Desc
}
func New(config *Config) *Collector {
@@ -68,6 +87,10 @@ func New(config *Config) *Collector {
config = &ConfigDefaults
}
if config.CollectorsEnabled == nil {
config.CollectorsEnabled = ConfigDefaults.CollectorsEnabled
}
c := &Collector{
config: *config,
}
@@ -75,8 +98,26 @@ func New(config *Config) *Collector {
return c
}
func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
func NewWithFlags(app *kingpin.Application) *Collector {
c := &Collector{
config: ConfigDefaults,
}
c.config.CollectorsEnabled = make([]string, 0)
var collectorsEnabled string
app.Flag(
"collector.dns.enabled",
"Comma-separated list of collectors to use. Defaults to all, if not specified.",
).Default(strings.Join(ConfigDefaults.CollectorsEnabled, ",")).StringVar(&collectorsEnabled)
app.Action(func(*kingpin.ParseContext) error {
c.config.CollectorsEnabled = strings.Split(collectorsEnabled, ",")
return nil
})
return c
}
func (c *Collector) GetName() string {
@@ -89,55 +130,31 @@ func (c *Collector) Close() error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error
c.perfDataCollector, err = perfdata.NewCollector("DNS", perfdata.InstancesAll, []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,
})
if err != nil {
return fmt.Errorf("failed to create DNS collector: %w", err)
func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
for _, collector := range c.config.CollectorsEnabled {
if !slices.Contains([]string{subCollectorMetrics, subCollectorWMIStats}, collector) {
return fmt.Errorf("unknown sub collector: %s. Possible values: %s", collector,
strings.Join([]string{subCollectorMetrics, subCollectorWMIStats}, ", "),
)
}
}
if slices.Contains(c.config.CollectorsEnabled, subCollectorMetrics) {
if err := c.buildMetricsCollector(); err != nil {
return err
}
}
if slices.Contains(c.config.CollectorsEnabled, subCollectorWMIStats) {
if err := c.buildErrorStatsCollector(miSession); err != nil {
return err
}
}
return nil
}
func (c *Collector) buildMetricsCollector() error {
c.zoneTransferRequestsReceived = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "zone_transfer_requests_received_total"),
"Number of zone transfer requests (AXFR/IXFR) received by the master DNS server",
@@ -271,85 +288,130 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
nil,
)
c.dnsWMIStats = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "wmi_stats_total"),
"DNS WMI statistics from MicrosoftDNS_Statistic",
[]string{"name", "collection_name", "dns_server"},
nil,
)
var err error
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "DNS", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create DNS collector: %w", err)
}
return nil
}
func (c *Collector) buildErrorStatsCollector(miSession *mi.Session) error {
if miSession == nil {
return errors.New("miSession is nil")
}
query, err := mi.NewQuery("SELECT Name, CollectionName, Value, DnsServerName FROM MicrosoftDNS_Statistic WHERE CollectionName = 'Error Stats'")
if err != nil {
return fmt.Errorf("failed to create query: %w", err)
}
c.miSession = miSession
c.miQuery = query
return nil
}
// 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()
errs := make([]error, 0)
if slices.Contains(c.config.CollectorsEnabled, subCollectorMetrics) {
if err := c.collectMetrics(ch); err != nil {
errs = append(errs, fmt.Errorf("failed collecting metrics: %w", err))
}
}
if slices.Contains(c.config.CollectorsEnabled, subCollectorWMIStats) {
if err := c.collectErrorStats(ch); err != nil {
errs = append(errs, fmt.Errorf("failed collecting WMI statistics: %w", err))
}
}
return errors.Join(errs...)
}
func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
err := c.perfDataCollector.Collect(&c.perfDataObject)
if err != nil {
return fmt.Errorf("failed to collect DNS metrics: %w", err)
}
data, ok := perfData[perfdata.InstanceEmpty]
if !ok {
return fmt.Errorf("failed to collect DNS metrics: %w", types.ErrNoData)
} else if len(c.perfDataObject) == 0 {
return fmt.Errorf("failed to collect DNS metrics: %w", types.ErrNoDataUnexpected)
}
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",
)
@@ -357,184 +419,205 @@ 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
}
func (c *Collector) collectErrorStats(ch chan<- prometheus.Metric) error {
var stats []Statistic
if err := c.miSession.Query(&stats, mi.NamespaceRootMicrosoftDNS, c.miQuery); err != nil {
return fmt.Errorf("failed to query DNS statistics: %w", err)
}
// Collect DNS error statistics
for _, stat := range stats {
ch <- prometheus.MustNewConstMetric(
c.dnsWMIStats,
prometheus.CounterValue,
float64(stat.Value),
stat.Name,
stat.CollectionName,
stat.DnsServerName,
)
}
return nil
}

View File

@@ -25,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,115 @@
// 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"`
}
// Statistic represents the structure for DNS error statistics
type Statistic struct {
Name string `mi:"Name"`
CollectionName string `mi:"CollectionName"`
Value uint64 `mi:"Value"`
DnsServerName string `mi:"DnsServerName"`
}

View File

@@ -21,26 +21,26 @@ 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/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 {
@@ -50,82 +50,35 @@ type Config struct {
//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
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
collectorADAccessProcesses
collectorActiveSync
collectorAutoDiscover
collectorAvailabilityService
collectorHTTPProxy
collectorMapiHttpEmsmdb
collectorOWA
collectorRpcClientAccess
collectorTransportQueues
collectorWorkloadManagementWorkloads
}
func New(config *Config) *Collector {
@@ -167,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{}
@@ -208,51 +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)
}
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...)
@@ -265,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

@@ -18,27 +18,30 @@ package exchange
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"
)
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.InstancesAll, counters)
c.perfDataCollectorActiveSync, err = pdh.NewCollector[perfDataCounterValuesActiveSync](pdh.CounterTypeRaw, "MSExchange ActiveSync", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange ActiveSync collector: %w", err)
}
@@ -66,30 +69,26 @@ func (c *Collector) buildActiveSync() error {
}
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 fmt.Errorf("failed to collect MSExchange ActiveSync metrics: %w", types.ErrNoData)
}
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

@@ -18,31 +18,37 @@ package exchange
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-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.InstancesAll, counters)
c.perfDataCollectorADAccessProcesses, err = pdh.NewCollector[perfDataCounterValuesADAccessProcesses](pdh.CounterTypeRaw, "MSExchange ADAccess Processes", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange ADAccess Processes collector: %w", err)
}
@@ -82,19 +88,15 @@ func (c *Collector) buildADAccessProcesses() error {
}
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 fmt.Errorf("failed to collect MSExchange ADAccess Processes metrics: %w", types.ErrNoData)
}
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.
@@ -106,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

@@ -18,19 +18,26 @@ package exchange
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"
)
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.InstancesAll, counters)
c.perfDataCollectorAutoDiscover, err = pdh.NewCollector[perfDataCounterValuesAutoDiscover](pdh.CounterTypeRaw, "MSExchangeAutodiscover", nil)
if err != nil {
return fmt.Errorf("failed to create MSExchange Autodiscover collector: %w", err)
}
@@ -46,20 +53,16 @@ func (c *Collector) buildAutoDiscover() error {
}
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 fmt.Errorf("failed to collect MSExchange Autodiscover metrics: %w", types.ErrNoData)
}
for _, data := range perfData {
for _, data := range c.perfDataObjectAutoDiscover {
ch <- prometheus.MustNewConstMetric(
c.autoDiscoverRequestsPerSec,
prometheus.CounterValue,
data[requestsPerSec].FirstValue,
data.RequestsPerSec,
)
}

View File

@@ -18,25 +18,32 @@ package exchange
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"
)
func (c *Collector) buildAvailabilityService() error {
counters := []string{
requestsPerSec,
}
type collectorAvailabilityService struct {
perfDataCollectorAvailabilityService *pdh.Collector
perfDataObjectAvailabilityService []perfDataCounterValuesAvailabilityService
availabilityRequestsSec *prometheus.Desc
}
type perfDataCounterValuesAvailabilityService struct {
AvailabilityRequestsPerSec float64 `perfdata:"Availability Requests (sec)"`
}
func (c *Collector) buildAvailabilityService() error {
var err error
c.perfDataCollectorAvailabilityService, err = perfdata.NewCollector("MSExchange Availability Service", perfdata.InstancesAll, counters)
c.perfDataCollectorAvailabilityService, err = pdh.NewCollector[perfDataCounterValuesAvailabilityService](pdh.CounterTypeRaw, "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"),
prometheus.BuildFQName(types.Namespace, Name, "availability_service_requests_per_sec"),
"Number of requests serviced per second",
nil,
nil,
@@ -46,20 +53,16 @@ func (c *Collector) buildAvailabilityService() error {
}
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 fmt.Errorf("failed to collect MSExchange Availability Service metrics: %w", types.ErrNoData)
}
for _, data := range perfData {
for _, data := range c.perfDataObjectAvailabilityService {
ch <- prometheus.MustNewConstMetric(
c.availabilityRequestsSec,
prometheus.CounterValue,
data[requestsPerSec].FirstValue,
data.AvailabilityRequestsPerSec,
)
}

View File

@@ -18,33 +18,39 @@ package exchange
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-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.InstancesAll, counters)
c.perfDataCollectorHTTPProxy, err = pdh.NewCollector[perfDataCounterValuesHTTPProxy](pdh.CounterTypeRaw, "MSExchange HttpProxy", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange HttpProxy collector: %w", err)
}
@@ -90,51 +96,47 @@ func (c *Collector) buildHTTPProxy() error {
}
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 fmt.Errorf("failed to collect MSExchange HttpProxy Service metrics: %w", types.ErrNoData)
}
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

@@ -18,23 +18,26 @@ package exchange
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"
)
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.InstancesAll, counters)
c.perfDataCollectorMapiHttpEmsmdb, err = pdh.NewCollector[perfDataCounterValuesMapiHttpEmsmdb](pdh.CounterTypeRaw, "MSExchange MapiHttp Emsmdb", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange MapiHttp Emsmdb: %w", err)
}
@@ -50,20 +53,16 @@ func (c *Collector) buildMapiHttpEmsmdb() error {
}
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 fmt.Errorf("failed to collect MSExchange MapiHttp Emsmdb metrics: %w", types.ErrNoData)
}
for _, data := range perfData {
for _, data := range c.perfDataObjectMapiHttpEmsmdb {
ch <- prometheus.MustNewConstMetric(
c.activeUserCountMapiHttpEmsMDB,
prometheus.GaugeValue,
data[activeUserCount].FirstValue,
data.ActiveUserCount,
)
}

View File

@@ -18,25 +18,28 @@ package exchange
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"
)
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.InstancesAll, counters)
c.perfDataCollectorOWA, err = pdh.NewCollector[perfDataCounterValuesOWA](pdh.CounterTypeRaw, "MSExchange OWA", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange OWA collector: %w", err)
}
@@ -58,25 +61,21 @@ func (c *Collector) buildOWA() error {
}
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 fmt.Errorf("failed to collect MSExchange OWA metrics: %w", types.ErrNoData)
}
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

@@ -18,33 +18,37 @@ package exchange
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-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.InstancesAll, counters)
c.perfDataCollectorRpcClientAccess, err = pdh.NewCollector[perfDataCounterValuesRpcClientAccess](pdh.CounterTypeRaw, "MSExchange RpcClientAccess", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange RpcClientAccess collector: %w", err)
}
@@ -89,46 +93,42 @@ func (c *Collector) buildRPC() error {
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 fmt.Errorf("failed to collect MSExchange RpcClientAccess metrics: %w", types.ErrNoData)
}
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

@@ -25,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

@@ -18,59 +18,64 @@ package exchange
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"
)
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"
messagesQueuedForDeliveryTotal = "Messages Queued For Delivery Total"
messagesSubmittedTotal = "Messages Submitted Total"
messagesDelayedTotal = "Messages Delayed Total"
messagesCompletedDeliveryTotal = "Messages Completed Delivery Total"
shadowQueueLength = "Shadow Queue Length"
submissionQueueLength = "Submission Queue Length"
delayQueueLength = "Delay Queue Length"
itemsCompletedDeliveryTotal = "Items Completed Delivery Total"
itemsQueuedForDeliveryExpiredTotal = "Items Queued For Delivery Expired Total"
itemsQueuedForDeliveryTotal = "Items Queued For Delivery Total"
itemsResubmittedTotal = "Items Resubmitted Total"
)
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
aggregateShadowQueueLength *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"`
AggregateShadowQueueLength float64 `perfdata:"Aggregate 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,
messagesQueuedForDeliveryTotal,
messagesSubmittedTotal,
messagesDelayedTotal,
messagesCompletedDeliveryTotal,
shadowQueueLength,
submissionQueueLength,
delayQueueLength,
itemsCompletedDeliveryTotal,
itemsQueuedForDeliveryExpiredTotal,
itemsQueuedForDeliveryTotal,
itemsResubmittedTotal,
}
var err error
c.perfDataCollectorTransportQueues, err = perfdata.NewCollector("MSExchangeTransport Queues", perfdata.InstancesAll, counters)
c.perfDataCollectorTransportQueues, err = pdh.NewCollector[perfDataCounterValuesTransportQueues](pdh.CounterTypeRaw, "MSExchangeTransport Queues", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchangeTransport Queues collector: %w", err)
}
@@ -147,9 +152,9 @@ func (c *Collector) buildTransportQueues() error {
[]string{"name"},
nil,
)
c.shadowQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_shadow_queue_length"),
"Shadow Queue Length",
c.aggregateShadowQueueLength = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "transport_queues_aggregate_shadow_queue_length"),
"The current number of messages in shadow queues.",
[]string{"name"},
nil,
)
@@ -194,130 +199,126 @@ func (c *Collector) buildTransportQueues() error {
}
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 fmt.Errorf("failed to collect MSExchangeTransport Queues metrics: %w", types.ErrNoData)
}
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].FirstValue,
data.MessagesQueuedForDeliveryTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.messagesSubmittedTotal,
prometheus.CounterValue,
data[messagesSubmittedTotal].FirstValue,
data.MessagesSubmittedTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.messagesDelayedTotal,
prometheus.CounterValue,
data[messagesDelayedTotal].FirstValue,
data.MessagesDelayedTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.messagesCompletedDeliveryTotal,
prometheus.CounterValue,
data[messagesCompletedDeliveryTotal].FirstValue,
data.MessagesCompletedDeliveryTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.shadowQueueLength,
c.aggregateShadowQueueLength,
prometheus.GaugeValue,
data[shadowQueueLength].FirstValue,
data.AggregateShadowQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.submissionQueueLength,
prometheus.GaugeValue,
data[submissionQueueLength].FirstValue,
data.SubmissionQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.delayQueueLength,
prometheus.GaugeValue,
data[delayQueueLength].FirstValue,
data.DelayQueueLength,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.itemsCompletedDeliveryTotal,
prometheus.CounterValue,
data[itemsCompletedDeliveryTotal].FirstValue,
data.ItemsCompletedDeliveryTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.itemsQueuedForDeliveryExpiredTotal,
prometheus.CounterValue,
data[itemsQueuedForDeliveryExpiredTotal].FirstValue,
data.ItemsQueuedForDeliveryExpiredTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.itemsQueuedForDeliveryTotal,
prometheus.CounterValue,
data[itemsQueuedForDeliveryTotal].FirstValue,
data.ItemsQueuedForDeliveryTotal,
labelName,
)
ch <- prometheus.MustNewConstMetric(
c.itemsResubmittedTotal,
prometheus.CounterValue,
data[itemsResubmittedTotal].FirstValue,
data.ItemsResubmittedTotal,
labelName,
)
}

View File

@@ -18,31 +18,36 @@ package exchange
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"
)
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.InstancesAll, counters)
c.perfDataCollectorWorkloadManagementWorkloads, err = pdh.NewCollector[perfDataCounterValuesWorkloadManagementWorkloads](pdh.CounterTypeRaw, "MSExchange WorkloadManagement Workloads", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create MSExchange WorkloadManagement Workloads collector: %w", err)
}
@@ -82,46 +87,42 @@ func (c *Collector) buildWorkloadManagementWorkloads() error {
}
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 fmt.Errorf("failed to collect MSExchange WorkloadManagement Workloads metrics: %w", types.ErrNoData)
}
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

@@ -25,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)
}

View File

@@ -23,11 +23,10 @@ import (
"strings"
"sync"
"github.com/Microsoft/hcsshim/osversion"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/sys/windows"
)
const (
@@ -149,7 +148,7 @@ func (c *Collector) Close() error {
return nil
}
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
c.collectorFns = make([]func(ch chan<- prometheus.Metric) error, 0, len(c.config.CollectorsEnabled))
c.closeFns = make([]func(), 0, len(c.config.CollectorsEnabled))
@@ -157,19 +156,17 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
return nil
}
version := windows.RtlGetVersion()
subCollectors := map[string]struct {
build func() error
collect func(ch chan<- prometheus.Metric) error
close func()
minBuildNumber uint32
minBuildNumber uint16
}{
subCollectorDataStore: {
build: c.buildDataStore,
collect: c.collectDataStore,
close: c.perfDataCollectorDataStore.Close,
minBuildNumber: types.BuildNumberWindowsServer2022,
minBuildNumber: osversion.LTSC2022,
},
subCollectorDynamicMemoryBalancer: {
build: c.buildDynamicMemoryBalancer,
@@ -227,9 +224,10 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
close: c.perfDataCollectorVirtualNetworkAdapterDropReasons.Close,
},
subCollectorVirtualSMB: {
build: c.buildVirtualSMB,
collect: c.collectVirtualSMB,
close: c.perfDataCollectorVirtualSMB.Close,
build: c.buildVirtualSMB,
collect: c.collectVirtualSMB,
close: c.perfDataCollectorVirtualSMB.Close,
minBuildNumber: osversion.LTSC2022,
},
subCollectorVirtualStorageDevice: {
build: c.buildVirtualStorageDevice,
@@ -243,6 +241,8 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
},
}
buildNumber := osversion.Build()
// Result must order, to prevent test failures.
sort.Strings(c.config.CollectorsEnabled)
@@ -253,8 +253,11 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
return fmt.Errorf("unknown collector: %s", name)
}
if version.BuildNumber < subCollectors[name].minBuildNumber {
errs = append(errs, fmt.Errorf("collector %s requires Windows Server 2022 or newer", name))
if buildNumber < subCollectors[name].minBuildNumber {
logger.Warn(fmt.Sprintf(
"collector %s requires windows build version %d. Current build version: %d",
name, subCollectors[name].minBuildNumber, buildNumber,
), slog.String("collector", name))
continue
}

View File

@@ -18,14 +18,15 @@ package hyperv
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"
)
// collectorDataStore Hyper-V DataStore metrics
type collectorDataStore struct {
perfDataCollectorDataStore *perfdata.Collector
perfDataCollectorDataStore *pdh.Collector
perfDataObjectDataStore []perfDataCounterValuesDataStore
dataStoreFragmentationRatio *prometheus.Desc // \Hyper-V DataStore(*)\Fragmentation ratio
dataStoreSectorSize *prometheus.Desc // \Hyper-V DataStore(*)\Sector size
@@ -75,107 +76,61 @@ type collectorDataStore struct {
dataStoreSetOperationCount *prometheus.Desc // \Hyper-V DataStore(*)\Set operation count
}
const (
type perfDataCounterValuesDataStore struct {
Name string
// Hyper-V DataStore metrics
dataStoreFragmentationRatio = "Fragmentation ratio"
dataStoreSectorSize = "Sector size"
dataStoreDataAlignment = "Data alignment"
dataStoreCurrentReplayLogSize = "Current replay logSize"
dataStoreAvailableEntries = "Number of available entries inside object tables"
dataStoreEmptyEntries = "Number of empty entries inside object tables"
dataStoreFreeBytes = "Number of free bytes inside key tables"
dataStoreDataEnd = "Data end"
dataStoreFileObjects = "Number of file objects"
dataStoreObjectTables = "Number of object tables"
dataStoreKeyTables = "Number of key tables"
dataStoreFileDataSize = "File data size in bytes"
dataStoreTableDataSize = "Table data size in bytes"
dataStoreNamesSize = "Names size in bytes"
dataStoreNumberOfKeys = "Number of keys"
dataStoreReconnectLatencyMicro = "Reconnect latency microseconds"
dataStoreDisconnectCount = "Disconnect count"
dataStoreWriteToFileByteLatency = "Write to file byte latency microseconds"
dataStoreWriteToFileByteCount = "Write to file byte count"
dataStoreWriteToFileCount = "Write to file count"
dataStoreReadFromFileByteLatency = "Read from file byte latency microseconds"
dataStoreReadFromFileByteCount = "Read from file byte count"
dataStoreReadFromFileCount = "Read from file count"
dataStoreWriteToStorageByteLatency = "Write to storage byte latency microseconds"
dataStoreWriteToStorageByteCount = "Write to storage byte count"
dataStoreWriteToStorageCount = "Write to storage count"
dataStoreReadFromStorageByteLatency = "Read from storage byte latency microseconds"
dataStoreReadFromStorageByteCount = "Read from storage byte count"
dataStoreReadFromStorageCount = "Read from storage count"
dataStoreCommitByteLatency = "Commit byte latency microseconds"
dataStoreCommitByteCount = "Commit byte count"
dataStoreCommitCount = "Commit count"
dataStoreCacheUpdateOperationLatency = "Cache update operation latency microseconds"
dataStoreCacheUpdateOperationCount = "Cache update operation count"
dataStoreCommitOperationLatency = "Commit operation latency microseconds"
dataStoreCommitOperationCount = "Commit operation count"
dataStoreCompactOperationLatency = "Compact operation latency microseconds"
dataStoreCompactOperationCount = "Compact operation count"
dataStoreLoadFileOperationLatency = "Load file operation latency microseconds"
dataStoreLoadFileOperationCount = "Load file operation count"
dataStoreRemoveOperationLatency = "Remove operation latency microseconds"
dataStoreRemoveOperationCount = "Remove operation count"
dataStoreQuerySizeOperationLatency = "Query size operation latency microseconds"
dataStoreQuerySizeOperationCount = "Query size operation count"
dataStoreSetOperationLatencyMicro = "Set operation latency microseconds"
dataStoreSetOperationCount = "Set operation count"
)
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 = perfdata.NewCollector("Hyper-V DataStore", perfdata.InstancesAll, []string{
dataStoreFragmentationRatio,
dataStoreSectorSize,
dataStoreDataAlignment,
dataStoreCurrentReplayLogSize,
dataStoreAvailableEntries,
dataStoreEmptyEntries,
dataStoreFreeBytes,
dataStoreDataEnd,
dataStoreFileObjects,
dataStoreObjectTables,
dataStoreKeyTables,
dataStoreFileDataSize,
dataStoreTableDataSize,
dataStoreNamesSize,
dataStoreNumberOfKeys,
dataStoreReconnectLatencyMicro,
dataStoreDisconnectCount,
dataStoreWriteToFileByteLatency,
dataStoreWriteToFileByteCount,
dataStoreWriteToFileCount,
dataStoreReadFromFileByteLatency,
dataStoreReadFromFileByteCount,
dataStoreReadFromFileCount,
dataStoreWriteToStorageByteLatency,
dataStoreWriteToStorageByteCount,
dataStoreWriteToStorageCount,
dataStoreReadFromStorageByteLatency,
dataStoreReadFromStorageByteCount,
dataStoreReadFromStorageCount,
dataStoreCommitByteLatency,
dataStoreCommitByteCount,
dataStoreCommitCount,
dataStoreCacheUpdateOperationLatency,
dataStoreCacheUpdateOperationCount,
dataStoreCommitOperationLatency,
dataStoreCommitOperationCount,
dataStoreCompactOperationLatency,
dataStoreCompactOperationCount,
dataStoreLoadFileOperationLatency,
dataStoreLoadFileOperationCount,
dataStoreRemoveOperationLatency,
dataStoreRemoveOperationCount,
dataStoreQuerySizeOperationLatency,
dataStoreQuerySizeOperationCount,
dataStoreSetOperationLatencyMicro,
dataStoreSetOperationCount,
})
c.perfDataCollectorDataStore, err = pdh.NewCollector[perfDataCounterValuesDataStore](pdh.CounterTypeRaw, "Hyper-V DataStore", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V DataStore collector: %w", err)
}
@@ -461,332 +416,332 @@ func (c *Collector) buildDataStore() error {
}
func (c *Collector) collectDataStore(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorDataStore.Collect()
err := c.perfDataCollectorDataStore.Collect(&c.perfDataObjectDataStore)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V DataStore metrics: %w", err)
}
for name, page := range data {
for _, data := range c.perfDataObjectDataStore {
ch <- prometheus.MustNewConstMetric(
c.dataStoreFragmentationRatio,
prometheus.GaugeValue,
page[dataStoreFragmentationRatio].FirstValue,
name,
data.DataStoreFragmentationRatio,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreSectorSize,
prometheus.GaugeValue,
page[dataStoreSectorSize].FirstValue,
name,
data.DataStoreSectorSize,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreDataAlignment,
prometheus.GaugeValue,
page[dataStoreDataAlignment].FirstValue,
name,
data.DataStoreDataAlignment,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCurrentReplayLogSize,
prometheus.GaugeValue,
page[dataStoreCurrentReplayLogSize].FirstValue,
name,
data.DataStoreCurrentReplayLogSize,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreAvailableEntries,
prometheus.GaugeValue,
page[dataStoreAvailableEntries].FirstValue,
name,
data.DataStoreAvailableEntries,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreEmptyEntries,
prometheus.GaugeValue,
page[dataStoreEmptyEntries].FirstValue,
name,
data.DataStoreEmptyEntries,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreFreeBytes,
prometheus.GaugeValue,
page[dataStoreFreeBytes].FirstValue,
name,
data.DataStoreFreeBytes,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreDataEnd,
prometheus.GaugeValue,
page[dataStoreDataEnd].FirstValue,
name,
data.DataStoreDataEnd,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreFileObjects,
prometheus.GaugeValue,
page[dataStoreFileObjects].FirstValue,
name,
data.DataStoreFileObjects,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreObjectTables,
prometheus.GaugeValue,
page[dataStoreObjectTables].FirstValue,
name,
data.DataStoreObjectTables,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreKeyTables,
prometheus.GaugeValue,
page[dataStoreKeyTables].FirstValue,
name,
data.DataStoreKeyTables,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreFileDataSize,
prometheus.GaugeValue,
page[dataStoreFileDataSize].FirstValue,
name,
data.DataStoreFileDataSize,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreTableDataSize,
prometheus.GaugeValue,
page[dataStoreTableDataSize].FirstValue,
name,
data.DataStoreTableDataSize,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreNamesSize,
prometheus.GaugeValue,
page[dataStoreNamesSize].FirstValue,
name,
data.DataStoreNamesSize,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreNumberOfKeys,
prometheus.GaugeValue,
page[dataStoreNumberOfKeys].FirstValue,
name,
data.DataStoreNumberOfKeys,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReconnectLatencyMicro,
prometheus.GaugeValue,
page[dataStoreReconnectLatencyMicro].FirstValue,
name,
data.DataStoreReconnectLatencyMicro,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreDisconnectCount,
prometheus.CounterValue,
page[dataStoreDisconnectCount].FirstValue,
name,
data.DataStoreDisconnectCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToFileByteLatency,
prometheus.GaugeValue,
page[dataStoreWriteToFileByteLatency].FirstValue,
name,
data.DataStoreWriteToFileByteLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToFileByteCount,
prometheus.CounterValue,
page[dataStoreWriteToFileByteCount].FirstValue,
name,
data.DataStoreWriteToFileByteCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToFileCount,
prometheus.CounterValue,
page[dataStoreWriteToFileCount].FirstValue,
name,
data.DataStoreWriteToFileCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromFileByteLatency,
prometheus.GaugeValue,
page[dataStoreReadFromFileByteLatency].FirstValue,
name,
data.DataStoreReadFromFileByteLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromFileByteCount,
prometheus.CounterValue,
page[dataStoreReadFromFileByteCount].FirstValue,
name,
data.DataStoreReadFromFileByteCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromFileCount,
prometheus.CounterValue,
page[dataStoreReadFromFileCount].FirstValue,
name,
data.DataStoreReadFromFileCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToStorageByteLatency,
prometheus.GaugeValue,
page[dataStoreWriteToStorageByteLatency].FirstValue,
name,
data.DataStoreWriteToStorageByteLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToStorageByteCount,
prometheus.CounterValue,
page[dataStoreWriteToStorageByteCount].FirstValue,
name,
data.DataStoreWriteToStorageByteCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreWriteToStorageCount,
prometheus.CounterValue,
page[dataStoreWriteToStorageCount].FirstValue,
name,
data.DataStoreWriteToStorageCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromStorageByteLatency,
prometheus.GaugeValue,
page[dataStoreReadFromStorageByteLatency].FirstValue,
name,
data.DataStoreReadFromStorageByteLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromStorageByteCount,
prometheus.CounterValue,
page[dataStoreReadFromStorageByteCount].FirstValue,
name,
data.DataStoreReadFromStorageByteCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreReadFromStorageCount,
prometheus.CounterValue,
page[dataStoreReadFromStorageCount].FirstValue,
name,
data.DataStoreReadFromStorageCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCommitByteLatency,
prometheus.GaugeValue,
page[dataStoreCommitByteLatency].FirstValue,
name,
data.DataStoreCommitByteLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCommitByteCount,
prometheus.CounterValue,
page[dataStoreCommitByteCount].FirstValue,
name,
data.DataStoreCommitByteCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCommitCount,
prometheus.CounterValue,
page[dataStoreCommitCount].FirstValue,
name,
data.DataStoreCommitCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCacheUpdateOperationLatency,
prometheus.GaugeValue,
page[dataStoreCacheUpdateOperationLatency].FirstValue,
name,
data.DataStoreCacheUpdateOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCacheUpdateOperationCount,
prometheus.CounterValue,
page[dataStoreCacheUpdateOperationCount].FirstValue,
name,
data.DataStoreCacheUpdateOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCommitOperationLatency,
prometheus.GaugeValue,
page[dataStoreCommitOperationLatency].FirstValue,
name,
data.DataStoreCommitOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCommitOperationCount,
prometheus.CounterValue,
page[dataStoreCommitOperationCount].FirstValue,
name,
data.DataStoreCommitOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCompactOperationLatency,
prometheus.GaugeValue,
page[dataStoreCompactOperationLatency].FirstValue,
name,
data.DataStoreCompactOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreCompactOperationCount,
prometheus.CounterValue,
page[dataStoreCompactOperationCount].FirstValue,
name,
data.DataStoreCompactOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreLoadFileOperationLatency,
prometheus.GaugeValue,
page[dataStoreLoadFileOperationLatency].FirstValue,
name,
data.DataStoreLoadFileOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreLoadFileOperationCount,
prometheus.CounterValue,
page[dataStoreLoadFileOperationCount].FirstValue,
name,
data.DataStoreLoadFileOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreRemoveOperationLatency,
prometheus.GaugeValue,
page[dataStoreRemoveOperationLatency].FirstValue,
name,
data.DataStoreRemoveOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreRemoveOperationCount,
prometheus.CounterValue,
page[dataStoreRemoveOperationCount].FirstValue,
name,
data.DataStoreRemoveOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreQuerySizeOperationLatency,
prometheus.GaugeValue,
page[dataStoreQuerySizeOperationLatency].FirstValue,
name,
data.DataStoreQuerySizeOperationLatency,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreQuerySizeOperationCount,
prometheus.CounterValue,
page[dataStoreQuerySizeOperationCount].FirstValue,
name,
data.DataStoreQuerySizeOperationCount,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreSetOperationLatencyMicro,
prometheus.GaugeValue,
page[dataStoreSetOperationLatencyMicro].FirstValue,
name,
data.DataStoreSetOperationLatencyMicro,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.dataStoreSetOperationCount,
prometheus.CounterValue,
page[dataStoreSetOperationCount].FirstValue,
name,
data.DataStoreSetOperationCount,
data.Name,
)
}

View File

@@ -18,7 +18,8 @@ package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/Microsoft/hcsshim/osversion"
"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"
@@ -26,31 +27,30 @@ import (
// collectorDynamicMemoryBalancer Hyper-V Dynamic Memory Balancer metrics
type collectorDynamicMemoryBalancer struct {
perfDataCollectorDynamicMemoryBalancer *perfdata.Collector
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
}
const (
type perfDataCounterValuesDynamicMemoryBalancer struct {
Name string
// Hyper-V Dynamic Memory Balancer metrics
vmDynamicMemoryBalancerAvailableMemory = "Available Memory"
vmDynamicMemoryBalancerAvailableMemoryForBalancing = "Available Memory For Balancing"
vmDynamicMemoryBalancerAveragePressure = "Average Pressure"
vmDynamicMemoryBalancerSystemCurrentPressure = "System Current Pressure"
)
VmDynamicMemoryBalancerAvailableMemory float64 `perfdata:"Available Memory"`
VmDynamicMemoryBalancerAvailableMemoryForBalancing float64 `perfdata:"Available Memory For Balancing" perfdata_min_build:"17763"`
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 = perfdata.NewCollector("Hyper-V Dynamic Memory Balancer", perfdata.InstancesAll, []string{
vmDynamicMemoryBalancerAvailableMemory,
vmDynamicMemoryBalancerAvailableMemoryForBalancing,
vmDynamicMemoryBalancerAveragePressure,
vmDynamicMemoryBalancerSystemCurrentPressure,
})
c.perfDataCollectorDynamicMemoryBalancer, err = pdh.NewCollector[perfDataCounterValuesDynamicMemoryBalancer](pdh.CounterTypeRaw, "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)
}
@@ -84,38 +84,40 @@ func (c *Collector) buildDynamicMemoryBalancer() error {
}
func (c *Collector) collectDynamicMemoryBalancer(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorDynamicMemoryBalancer.Collect()
err := c.perfDataCollectorDynamicMemoryBalancer.Collect(&c.perfDataObjectDynamicMemoryBalancer)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Dynamic Memory Balancer metrics: %w", err)
}
for name, page := range data {
for _, data := range c.perfDataObjectDynamicMemoryBalancer {
ch <- prometheus.MustNewConstMetric(
c.vmDynamicMemoryBalancerAvailableMemory,
prometheus.GaugeValue,
utils.MBToBytes(page[vmDynamicMemoryBalancerAvailableMemory].FirstValue),
name,
utils.MBToBytes(data.VmDynamicMemoryBalancerAvailableMemory),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmDynamicMemoryBalancerAvailableMemoryForBalancing,
prometheus.GaugeValue,
utils.MBToBytes(page[vmDynamicMemoryBalancerAvailableMemoryForBalancing].FirstValue),
name,
)
if osversion.Build() >= osversion.LTSC2019 {
ch <- prometheus.MustNewConstMetric(
c.vmDynamicMemoryBalancerAvailableMemoryForBalancing,
prometheus.GaugeValue,
utils.MBToBytes(data.VmDynamicMemoryBalancerAvailableMemoryForBalancing),
data.Name,
)
}
ch <- prometheus.MustNewConstMetric(
c.vmDynamicMemoryBalancerAveragePressure,
prometheus.GaugeValue,
utils.PercentageToRatio(page[vmDynamicMemoryBalancerAveragePressure].FirstValue),
name,
utils.PercentageToRatio(data.VmDynamicMemoryBalancerAveragePressure),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmDynamicMemoryBalancerSystemCurrentPressure,
prometheus.GaugeValue,
utils.PercentageToRatio(page[vmDynamicMemoryBalancerSystemCurrentPressure].FirstValue),
name,
utils.PercentageToRatio(data.VmDynamicMemoryBalancerSystemCurrentPressure),
data.Name,
)
}

View File

@@ -18,7 +18,8 @@ package hyperv
import (
"fmt"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/Microsoft/hcsshim/osversion"
"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"
@@ -26,7 +27,9 @@ import (
// collectorDynamicMemoryVM Hyper-V Dynamic Memory VM metrics
type collectorDynamicMemoryVM struct {
perfDataCollectorDynamicMemoryVM *perfdata.Collector
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
@@ -39,35 +42,26 @@ type collectorDynamicMemoryVM struct {
vmMemoryGuestAvailableMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Guest Available Memory
}
const (
type perfDataCounterValuesDynamicMemoryVM struct {
Name string
// Hyper-V Dynamic Memory VM metrics
vmMemoryAddedMemory = "Added Memory"
vmMemoryCurrentPressure = "Current Pressure"
vmMemoryGuestAvailableMemory = "Guest Available Memory"
vmMemoryGuestVisiblePhysicalMemory = "Guest Visible Physical Memory"
vmMemoryMaximumPressure = "Maximum Pressure"
vmMemoryMemoryAddOperations = "Memory Add Operations"
vmMemoryMemoryRemoveOperations = "Memory Remove Operations"
vmMemoryMinimumPressure = "Minimum Pressure"
vmMemoryPhysicalMemory = "Physical Memory"
vmMemoryRemovedMemory = "Removed Memory"
)
VmMemoryAddedMemory float64 `perfdata:"Added Memory"`
VmMemoryCurrentPressure float64 `perfdata:"Current Pressure"`
VmMemoryGuestAvailableMemory float64 `perfdata:"Guest Available Memory" perfdata_min_build:"17763"`
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 = perfdata.NewCollector("Hyper-V Dynamic Memory VM", perfdata.InstancesAll, []string{
vmMemoryAddedMemory,
vmMemoryCurrentPressure,
vmMemoryGuestVisiblePhysicalMemory,
vmMemoryMaximumPressure,
vmMemoryMemoryAddOperations,
vmMemoryMemoryRemoveOperations,
vmMemoryMinimumPressure,
vmMemoryPhysicalMemory,
vmMemoryRemovedMemory,
vmMemoryGuestAvailableMemory,
})
c.perfDataCollectorDynamicMemoryVM, err = pdh.NewCollector[perfDataCounterValuesDynamicMemoryVM](pdh.CounterTypeRaw, "Hyper-V Dynamic Memory VM", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Dynamic Memory VM collector: %w", err)
}
@@ -137,80 +131,82 @@ func (c *Collector) buildDynamicMemoryVM() error {
}
func (c *Collector) collectDynamicMemoryVM(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorDynamicMemoryVM.Collect()
err := c.perfDataCollectorDynamicMemoryVM.Collect(&c.perfDataObjectDynamicMemoryVM)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Dynamic Memory VM metrics: %w", err)
}
for vmName, vmData := range data {
for _, data := range c.perfDataObjectDynamicMemoryVM {
ch <- prometheus.MustNewConstMetric(
c.vmMemoryAddedMemory,
prometheus.CounterValue,
utils.MBToBytes(vmData[vmMemoryAddedMemory].FirstValue),
vmName,
utils.MBToBytes(data.VmMemoryAddedMemory),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryCurrentPressure,
prometheus.GaugeValue,
utils.PercentageToRatio(vmData[vmMemoryCurrentPressure].FirstValue),
vmName,
utils.PercentageToRatio(data.VmMemoryCurrentPressure),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryGuestAvailableMemory,
prometheus.GaugeValue,
utils.MBToBytes(vmData[vmMemoryGuestAvailableMemory].FirstValue),
vmName,
)
if osversion.Build() >= osversion.LTSC2019 {
ch <- prometheus.MustNewConstMetric(
c.vmMemoryGuestAvailableMemory,
prometheus.GaugeValue,
utils.MBToBytes(data.VmMemoryGuestAvailableMemory),
data.Name,
)
}
ch <- prometheus.MustNewConstMetric(
c.vmMemoryGuestVisiblePhysicalMemory,
prometheus.GaugeValue,
utils.MBToBytes(vmData[vmMemoryGuestVisiblePhysicalMemory].FirstValue),
vmName,
utils.MBToBytes(data.VmMemoryGuestVisiblePhysicalMemory),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryMaximumPressure,
prometheus.GaugeValue,
utils.PercentageToRatio(vmData[vmMemoryMaximumPressure].FirstValue),
vmName,
utils.PercentageToRatio(data.VmMemoryMaximumPressure),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryMemoryAddOperations,
prometheus.CounterValue,
vmData[vmMemoryMemoryAddOperations].FirstValue,
vmName,
data.VmMemoryMemoryAddOperations,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryMemoryRemoveOperations,
prometheus.CounterValue,
vmData[vmMemoryMemoryRemoveOperations].FirstValue,
vmName,
data.VmMemoryMemoryRemoveOperations,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryMinimumPressure,
prometheus.GaugeValue,
utils.PercentageToRatio(vmData[vmMemoryMinimumPressure].FirstValue),
vmName,
utils.PercentageToRatio(data.VmMemoryMinimumPressure),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryPhysicalMemory,
prometheus.GaugeValue,
utils.MBToBytes(vmData[vmMemoryPhysicalMemory].FirstValue),
vmName,
utils.MBToBytes(data.VmMemoryPhysicalMemory),
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.vmMemoryRemovedMemory,
prometheus.CounterValue,
utils.MBToBytes(vmData[vmMemoryRemovedMemory].FirstValue),
vmName,
utils.MBToBytes(data.VmMemoryRemovedMemory),
data.Name,
)
}

View File

@@ -19,14 +19,15 @@ import (
"fmt"
"strings"
"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"
)
// collectorHypervisorLogicalProcessor Hyper-V Hypervisor Logical Processor metrics
type collectorHypervisorLogicalProcessor struct {
perfDataCollectorHypervisorLogicalProcessor *perfdata.Collector
perfDataCollectorHypervisorLogicalProcessor *pdh.Collector
perfDataObjectHypervisorLogicalProcessor []perfDataCounterValuesHypervisorLogicalProcessor
// \Hyper-V Hypervisor Logical Processor(*)\% Guest Run Time
// \Hyper-V Hypervisor Logical Processor(*)\% Hypervisor Run Time
@@ -36,24 +37,20 @@ type collectorHypervisorLogicalProcessor struct {
hypervisorLogicalProcessorContextSwitches *prometheus.Desc // \Hyper-V Hypervisor Logical Processor(*)\Context Switches/sec
}
const (
hypervisorLogicalProcessorGuestRunTimePercent = "% Guest Run Time"
hypervisorLogicalProcessorHypervisorRunTimePercent = "% Hypervisor Run Time"
hypervisorLogicalProcessorTotalRunTimePercent = "% Total Run Time"
hypervisorLogicalProcessorIdleRunTimePercent = "% Idle Time"
hypervisorLogicalProcessorContextSwitches = "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 = perfdata.NewCollector("Hyper-V Hypervisor Logical Processor", perfdata.InstancesAll, []string{
hypervisorLogicalProcessorGuestRunTimePercent,
hypervisorLogicalProcessorHypervisorRunTimePercent,
hypervisorLogicalProcessorTotalRunTimePercent,
hypervisorLogicalProcessorIdleRunTimePercent,
hypervisorLogicalProcessorContextSwitches,
})
c.perfDataCollectorHypervisorLogicalProcessor, err = pdh.NewCollector[perfDataCounterValuesHypervisorLogicalProcessor](pdh.CounterTypeRaw, "Hyper-V Hypervisor Logical Processor", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Hypervisor Logical Processor collector: %w", err)
}
@@ -82,53 +79,53 @@ func (c *Collector) buildHypervisorLogicalProcessor() error {
}
func (c *Collector) collectHypervisorLogicalProcessor(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorHypervisorLogicalProcessor.Collect()
err := c.perfDataCollectorHypervisorLogicalProcessor.Collect(&c.perfDataObjectHypervisorLogicalProcessor)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Hypervisor Logical Processor metrics: %w", err)
}
for coreName, coreData := range data {
for _, data := range c.perfDataObjectHypervisorLogicalProcessor {
// The name format is Hv LP <core id>
parts := strings.Split(coreName, " ")
parts := strings.Split(data.Name, " ")
if len(parts) != 3 {
return fmt.Errorf("unexpected Hyper-V Hypervisor Logical Processor name format: %s", coreName)
return fmt.Errorf("unexpected Hyper-V Hypervisor Logical Processor name format: %s", data.Name)
}
coreId := parts[2]
coreID := parts[2]
ch <- prometheus.MustNewConstMetric(
c.hypervisorLogicalProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorLogicalProcessorGuestRunTimePercent].FirstValue,
coreId, "guest",
data.HypervisorLogicalProcessorGuestRunTimePercent,
coreID, "guest",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorLogicalProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorLogicalProcessorHypervisorRunTimePercent].FirstValue,
coreId, "hypervisor",
data.HypervisorLogicalProcessorHypervisorRunTimePercent,
coreID, "hypervisor",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorLogicalProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorLogicalProcessorIdleRunTimePercent].FirstValue,
coreId, "idle",
data.HypervisorLogicalProcessorIdleRunTimePercent,
coreID, "idle",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorLogicalProcessorTotalRunTimeTotal,
prometheus.CounterValue,
coreData[hypervisorLogicalProcessorTotalRunTimePercent].FirstValue,
coreId,
data.HypervisorLogicalProcessorTotalRunTimePercent,
coreID,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorLogicalProcessorContextSwitches,
prometheus.CounterValue,
coreData[hypervisorLogicalProcessorContextSwitches].FirstValue,
coreId,
data.HypervisorLogicalProcessorContextSwitches,
coreID,
)
}

View File

@@ -16,17 +16,18 @@
package hyperv
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"
)
// collectorHypervisorRootPartition Hyper-V Hypervisor Root Partition metrics
type collectorHypervisorRootPartition struct {
perfDataCollectorHypervisorRootPartition *perfdata.Collector
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
@@ -50,56 +51,34 @@ type collectorHypervisorRootPartition struct {
hypervisorRootPartitionVirtualTLBPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Virtual TLB Pages
}
const (
hypervisorRootPartitionAddressSpaces = "Address Spaces"
hypervisorRootPartitionAttachedDevices = "Attached Devices"
hypervisorRootPartitionDepositedPages = "Deposited Pages"
hypervisorRootPartitionDeviceDMAErrors = "Device DMA Errors"
hypervisorRootPartitionDeviceInterruptErrors = "Device Interrupt Errors"
hypervisorRootPartitionDeviceInterruptMappings = "Device Interrupt Mappings"
hypervisorRootPartitionDeviceInterruptThrottleEvents = "Device Interrupt Throttle Events"
hypervisorRootPartitionGPAPages = "GPA Pages"
hypervisorRootPartitionGPASpaceModifications = "GPA Space Modifications/sec"
hypervisorRootPartitionIOTLBFlushCost = "I/O TLB Flush Cost"
hypervisorRootPartitionIOTLBFlushes = "I/O TLB Flushes/sec"
hypervisorRootPartitionRecommendedVirtualTLBSize = "Recommended Virtual TLB Size"
hypervisorRootPartitionSkippedTimerTicks = "Skipped Timer Ticks"
hypervisorRootPartition1GDevicePages = "1G device pages"
hypervisorRootPartition1GGPAPages = "1G GPA pages"
hypervisorRootPartition2MDevicePages = "2M device pages"
hypervisorRootPartition2MGPAPages = "2M GPA pages"
hypervisorRootPartition4KDevicePages = "4K device pages"
hypervisorRootPartition4KGPAPages = "4K GPA pages"
hypervisorRootPartitionVirtualTLBFlushEntries = "Virtual TLB Flush Entires/sec"
hypervisorRootPartitionVirtualTLBPages = "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 = perfdata.NewCollector("Hyper-V Hypervisor Root Partition", []string{"Root"}, []string{
hypervisorRootPartitionAddressSpaces,
hypervisorRootPartitionAttachedDevices,
hypervisorRootPartitionDepositedPages,
hypervisorRootPartitionDeviceDMAErrors,
hypervisorRootPartitionDeviceInterruptErrors,
hypervisorRootPartitionDeviceInterruptMappings,
hypervisorRootPartitionDeviceInterruptThrottleEvents,
hypervisorRootPartitionGPAPages,
hypervisorRootPartitionGPASpaceModifications,
hypervisorRootPartitionIOTLBFlushCost,
hypervisorRootPartitionIOTLBFlushes,
hypervisorRootPartitionRecommendedVirtualTLBSize,
hypervisorRootPartitionSkippedTimerTicks,
hypervisorRootPartition1GDevicePages,
hypervisorRootPartition1GGPAPages,
hypervisorRootPartition2MDevicePages,
hypervisorRootPartition2MGPAPages,
hypervisorRootPartition4KDevicePages,
hypervisorRootPartition4KGPAPages,
hypervisorRootPartitionVirtualTLBFlushEntries,
hypervisorRootPartitionVirtualTLBPages,
})
c.perfDataCollectorHypervisorRootPartition, err = pdh.NewCollector[perfDataCounterValuesHypervisorRootPartition](pdh.CounterTypeRaw, "Hyper-V Hypervisor Root Partition", []string{"Root"})
if err != nil {
return fmt.Errorf("failed to create Hyper-V Hypervisor Root Partition collector: %w", err)
}
@@ -235,129 +214,124 @@ func (c *Collector) buildHypervisorRootPartition() error {
}
func (c *Collector) collectHypervisorRootPartition(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorHypervisorRootPartition.Collect()
err := c.perfDataCollectorHypervisorRootPartition.Collect(&c.perfDataObjectHypervisorRootPartition)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Hypervisor Root Partition metrics: %w", err)
}
rootData, ok := data["Root"]
if !ok {
return errors.New("no data returned from Hyper-V Hypervisor Root Partition")
}
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionAddressSpaces,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionAddressSpaces].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionAddressSpaces,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionAttachedDevices,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionAttachedDevices].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionAttachedDevices,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionDepositedPages,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionDepositedPages].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDepositedPages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionDeviceDMAErrors,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionDeviceDMAErrors].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDeviceDMAErrors,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionDeviceInterruptErrors,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionDeviceInterruptErrors].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDeviceInterruptErrors,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionDeviceInterruptThrottleEvents,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionDeviceInterruptThrottleEvents].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDeviceInterruptThrottleEvents,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionGPAPages,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionGPAPages].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionGPAPages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionGPASpaceModifications,
prometheus.CounterValue,
rootData[hypervisorRootPartitionGPASpaceModifications].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionGPASpaceModifications,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionIOTLBFlushCost,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionIOTLBFlushCost].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionIOTLBFlushCost,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionIOTLBFlushes,
prometheus.CounterValue,
rootData[hypervisorRootPartitionIOTLBFlushes].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionIOTLBFlushes,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionRecommendedVirtualTLBSize,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionRecommendedVirtualTLBSize].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionRecommendedVirtualTLBSize,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionSkippedTimerTicks,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionSkippedTimerTicks].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionSkippedTimerTicks,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition1GDevicePages,
prometheus.GaugeValue,
rootData[hypervisorRootPartition1GDevicePages].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition1GDevicePages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition1GGPAPages,
prometheus.GaugeValue,
rootData[hypervisorRootPartition1GGPAPages].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition1GGPAPages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition2MDevicePages,
prometheus.GaugeValue,
rootData[hypervisorRootPartition2MDevicePages].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MDevicePages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition2MGPAPages,
prometheus.GaugeValue,
rootData[hypervisorRootPartition2MGPAPages].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MGPAPages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition4KDevicePages,
prometheus.GaugeValue,
rootData[hypervisorRootPartition4KDevicePages].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KDevicePages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartition4KGPAPages,
prometheus.GaugeValue,
rootData[hypervisorRootPartition4KGPAPages].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KGPAPages,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionVirtualTLBFlushEntries,
prometheus.CounterValue,
rootData[hypervisorRootPartitionVirtualTLBFlushEntries].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionVirtualTLBFlushEntries,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootPartitionVirtualTLBPages,
prometheus.GaugeValue,
rootData[hypervisorRootPartitionVirtualTLBPages].FirstValue,
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionVirtualTLBPages,
)
return nil

View File

@@ -19,16 +19,16 @@ import (
"fmt"
"strings"
"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"
)
// collectorHypervisorRootVirtualProcessor Hyper-V Hypervisor Root Virtual Processor metrics
type collectorHypervisorRootVirtualProcessor struct {
perfDataCollectorHypervisorRootVirtualProcessor *perfdata.Collector
perfDataCollectorHypervisorRootVirtualProcessor *pdh.Collector
perfDataObjectHypervisorRootVirtualProcessor []perfDataCounterValuesHypervisorRootVirtualProcessor
// \Hyper-V Hypervisor Root Virtual Processor(*)\% Guest Idle Time
// \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
@@ -38,26 +38,20 @@ type collectorHypervisorRootVirtualProcessor struct {
hypervisorRootVirtualProcessorCPUWaitTimePerDispatch *prometheus.Desc // \Hyper-V Hypervisor Root Virtual Processor(*)\CPU Wait Time Per Dispatch
}
const (
hypervisorRootVirtualProcessorGuestIdleTimePercent = "% Guest Idle Time"
hypervisorRootVirtualProcessorGuestRunTimePercent = "% Guest Run Time"
hypervisorRootVirtualProcessorHypervisorRunTimePercent = "% Hypervisor Run Time"
hypervisorRootVirtualProcessorTotalRunTimePercent = "% Total Run Time"
hypervisorRootVirtualProcessorRemoteRunTimePercent = "% Remote Run Time"
hypervisorRootVirtualProcessorCPUWaitTimePerDispatch = "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 = perfdata.NewCollector("Hyper-V Hypervisor Root Virtual Processor", perfdata.InstancesAll, []string{
hypervisorRootVirtualProcessorGuestIdleTimePercent,
hypervisorRootVirtualProcessorGuestRunTimePercent,
hypervisorRootVirtualProcessorHypervisorRunTimePercent,
hypervisorRootVirtualProcessorTotalRunTimePercent,
hypervisorRootVirtualProcessorRemoteRunTimePercent,
hypervisorRootVirtualProcessorCPUWaitTimePerDispatch,
})
c.perfDataCollectorHypervisorRootVirtualProcessor, err = pdh.NewCollector[perfDataCounterValuesHypervisorRootVirtualProcessor](pdh.CounterTypeRaw, "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)
}
@@ -87,60 +81,53 @@ func (c *Collector) buildHypervisorRootVirtualProcessor() error {
}
func (c *Collector) collectHypervisorRootVirtualProcessor(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorHypervisorRootVirtualProcessor.Collect()
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 coreName, coreData := range data {
for _, data := range c.perfDataObjectHypervisorRootVirtualProcessor {
// The name format is Hv LP <core id>
parts := strings.Split(coreName, " ")
parts := strings.Split(data.Name, " ")
if len(parts) != 3 {
return fmt.Errorf("unexpected Hyper-V Hypervisor Root Virtual Processor name format: %s", coreName)
return fmt.Errorf("unexpected Hyper-V Hypervisor Root Virtual Processor name format: %s", data.Name)
}
coreId := parts[2]
coreID := parts[2]
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorRootVirtualProcessorGuestRunTimePercent].FirstValue,
coreId, "guest_run",
data.HypervisorRootVirtualProcessorGuestRunTimePercent,
coreID, "guest_run",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorRootVirtualProcessorHypervisorRunTimePercent].FirstValue,
coreId, "hypervisor",
data.HypervisorRootVirtualProcessorHypervisorRunTimePercent,
coreID, "hypervisor",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorRootVirtualProcessorGuestIdleTimePercent].FirstValue,
coreId, "guest_idle",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorRootVirtualProcessorRemoteRunTimePercent].FirstValue,
coreId, "remote",
data.HypervisorRootVirtualProcessorRemoteRunTimePercent,
coreID, "remote",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorTotalRunTimeTotal,
prometheus.CounterValue,
coreData[hypervisorRootVirtualProcessorTotalRunTimePercent].FirstValue,
coreId,
data.HypervisorRootVirtualProcessorTotalRunTimePercent,
coreID,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorRootVirtualProcessorCPUWaitTimePerDispatch,
prometheus.CounterValue,
coreData[hypervisorRootVirtualProcessorCPUWaitTimePerDispatch].FirstValue,
coreId,
data.HypervisorRootVirtualProcessorCPUWaitTimePerDispatch,
coreID,
)
}

View File

@@ -19,16 +19,16 @@ import (
"fmt"
"strings"
"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"
)
// collectorHypervisorVirtualProcessor Hyper-V Hypervisor Virtual Processor metrics
type collectorHypervisorVirtualProcessor struct {
perfDataCollectorHypervisorVirtualProcessor *perfdata.Collector
perfDataCollectorHypervisorVirtualProcessor *pdh.Collector
perfDataObjectHypervisorVirtualProcessor []perfDataCounterValuesHypervisorVirtualProcessor
// \Hyper-V Hypervisor Virtual Processor(*)\% Guest Idle Time
// \Hyper-V Hypervisor Virtual Processor(*)\% Guest Run Time
// \Hyper-V Hypervisor Virtual Processor(*)\% Hypervisor Run Time
// \Hyper-V Hypervisor Virtual Processor(*)\% Remote Run Time
@@ -37,26 +37,20 @@ type collectorHypervisorVirtualProcessor struct {
hypervisorVirtualProcessorContextSwitches *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\CPU Wait Time Per Dispatch
}
const (
hypervisorVirtualProcessorGuestRunTimePercent = "% Guest Run Time"
hypervisorVirtualProcessorGuestIdleTimePercent = "% Guest Idle Time"
hypervisorVirtualProcessorHypervisorRunTimePercent = "% Hypervisor Run Time"
hypervisorVirtualProcessorTotalRunTimePercent = "% Total Run Time"
hypervisorVirtualProcessorRemoteRunTimePercent = "% Remote Run Time"
hypervisorVirtualProcessorCPUWaitTimePerDispatch = "CPU Wait Time Per Dispatch"
)
type perfDataCounterValuesHypervisorVirtualProcessor struct {
Name string
HypervisorVirtualProcessorGuestRunTimePercent float64 `perfdata:"% Guest Run 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 = perfdata.NewCollector("Hyper-V Hypervisor Virtual Processor", perfdata.InstancesAll, []string{
hypervisorVirtualProcessorGuestRunTimePercent,
hypervisorVirtualProcessorGuestIdleTimePercent,
hypervisorVirtualProcessorHypervisorRunTimePercent,
hypervisorVirtualProcessorTotalRunTimePercent,
hypervisorVirtualProcessorRemoteRunTimePercent,
hypervisorVirtualProcessorCPUWaitTimePerDispatch,
})
c.perfDataCollectorHypervisorVirtualProcessor, err = pdh.NewCollector[perfDataCounterValuesHypervisorVirtualProcessor](pdh.CounterTypeRaw, "Hyper-V Hypervisor Virtual Processor", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Hypervisor Virtual Processor collector: %w", err)
}
@@ -84,16 +78,16 @@ func (c *Collector) buildHypervisorVirtualProcessor() error {
}
func (c *Collector) collectHypervisorVirtualProcessor(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorHypervisorVirtualProcessor.Collect()
err := c.perfDataCollectorHypervisorVirtualProcessor.Collect(&c.perfDataObjectHypervisorVirtualProcessor)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Hypervisor Virtual Processor metrics: %w", err)
}
for coreName, coreData := range data {
for _, data := range c.perfDataObjectHypervisorVirtualProcessor {
// The name format is <VM Name>:Hv VP <vcore id>
parts := strings.Split(coreName, ":")
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", coreName, "<VM Name>:Hv VP <vcore id>")
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], " ")
@@ -102,48 +96,41 @@ func (c *Collector) collectHypervisorVirtualProcessor(ch chan<- prometheus.Metri
}
vmName := parts[0]
coreId := coreParts[2]
coreID := coreParts[2]
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorVirtualProcessorGuestRunTimePercent].FirstValue,
vmName, coreId, "guest_run",
data.HypervisorVirtualProcessorHypervisorRunTimePercent,
vmName, coreID, "hypervisor",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorVirtualProcessorHypervisorRunTimePercent].FirstValue,
vmName, coreId, "hypervisor",
data.HypervisorVirtualProcessorGuestRunTimePercent,
vmName, coreID, "guest",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorVirtualProcessorGuestIdleTimePercent].FirstValue,
vmName, coreId, "guest_idle",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorTimeTotal,
prometheus.CounterValue,
coreData[hypervisorVirtualProcessorGuestIdleTimePercent].FirstValue,
vmName, coreId, "guest_idle",
data.HypervisorVirtualProcessorRemoteRunTimePercent,
vmName, coreID, "remote",
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorTotalRunTimeTotal,
prometheus.CounterValue,
coreData[hypervisorVirtualProcessorTotalRunTimePercent].FirstValue,
vmName, coreId,
data.HypervisorVirtualProcessorTotalRunTimePercent,
vmName, coreID,
)
ch <- prometheus.MustNewConstMetric(
c.hypervisorVirtualProcessorContextSwitches,
prometheus.CounterValue,
coreData[hypervisorVirtualProcessorCPUWaitTimePerDispatch].FirstValue,
vmName, coreId,
data.HypervisorVirtualProcessorCPUWaitTimePerDispatch,
vmName, coreID,
)
}

View File

@@ -18,14 +18,15 @@ package hyperv
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"
)
// collectorLegacyNetworkAdapter Hyper-V Legacy Network Adapter metrics
type collectorLegacyNetworkAdapter struct {
perfDataCollectorLegacyNetworkAdapter *perfdata.Collector
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
@@ -35,26 +36,21 @@ type collectorLegacyNetworkAdapter struct {
legacyNetworkAdapterFramesSent *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Frames Sent/sec
}
const (
legacyNetworkAdapterBytesDropped = "Bytes Dropped"
legacyNetworkAdapterBytesReceived = "Bytes Received/sec"
legacyNetworkAdapterBytesSent = "Bytes Sent/sec"
legacyNetworkAdapterFramesDropped = "Frames Dropped"
legacyNetworkAdapterFramesReceived = "Frames Received/sec"
legacyNetworkAdapterFramesSent = "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 = perfdata.NewCollector("Hyper-V Legacy Network Adapter", perfdata.InstancesAll, []string{
legacyNetworkAdapterBytesDropped,
legacyNetworkAdapterBytesReceived,
legacyNetworkAdapterBytesSent,
legacyNetworkAdapterFramesDropped,
legacyNetworkAdapterFramesReceived,
legacyNetworkAdapterFramesSent,
})
c.perfDataCollectorLegacyNetworkAdapter, err = pdh.NewCollector[perfDataCounterValuesLegacyNetworkAdapter](pdh.CounterTypeRaw, "Hyper-V Legacy Network Adapter", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Legacy Network Adapter collector: %w", err)
}
@@ -100,52 +96,52 @@ func (c *Collector) buildLegacyNetworkAdapter() error {
}
func (c *Collector) collectLegacyNetworkAdapter(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorLegacyNetworkAdapter.Collect()
err := c.perfDataCollectorLegacyNetworkAdapter.Collect(&c.perfDataObjectLegacyNetworkAdapter)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Legacy Network Adapter metrics: %w", err)
}
for name, adapter := range data {
for _, data := range c.perfDataObjectLegacyNetworkAdapter {
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterBytesDropped,
prometheus.GaugeValue,
adapter[legacyNetworkAdapterBytesDropped].FirstValue,
name,
data.LegacyNetworkAdapterBytesDropped,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterBytesReceived,
prometheus.CounterValue,
adapter[legacyNetworkAdapterBytesReceived].FirstValue,
name,
data.LegacyNetworkAdapterBytesReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterBytesSent,
prometheus.CounterValue,
adapter[legacyNetworkAdapterBytesSent].FirstValue,
name,
data.LegacyNetworkAdapterBytesSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterFramesReceived,
prometheus.CounterValue,
adapter[legacyNetworkAdapterFramesReceived].FirstValue,
name,
data.LegacyNetworkAdapterFramesReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterFramesDropped,
prometheus.CounterValue,
adapter[legacyNetworkAdapterFramesDropped].FirstValue,
name,
data.LegacyNetworkAdapterFramesDropped,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.legacyNetworkAdapterFramesSent,
prometheus.CounterValue,
adapter[legacyNetworkAdapterFramesSent].FirstValue,
name,
data.LegacyNetworkAdapterFramesSent,
data.Name,
)
}

View File

@@ -25,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

@@ -16,36 +16,33 @@
package hyperv
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"
)
// collectorVirtualMachineHealthSummary Hyper-V Virtual Machine Health Summary metrics
type collectorVirtualMachineHealthSummary struct {
perfDataCollectorVirtualMachineHealthSummary *perfdata.Collector
perfDataCollectorVirtualMachineHealthSummary *pdh.Collector
perfDataObjectVirtualMachineHealthSummary []perfDataCounterValuesVirtualMachineHealthSummary
// \Hyper-V Virtual Machine Health Summary\Health Critical
// \Hyper-V Virtual Machine Health Summary\Health Ok
health *prometheus.Desc
}
const (
type perfDataCounterValuesVirtualMachineHealthSummary struct {
// Hyper-V Virtual Machine Health Summary
healthCritical = "Health Critical"
healthOk = "Health Ok"
)
HealthCritical float64 `perfdata:"Health Critical"`
HealthOk float64 `perfdata:"Health Ok"`
}
func (c *Collector) buildVirtualMachineHealthSummary() error {
var err error
c.perfDataCollectorVirtualMachineHealthSummary, err = perfdata.NewCollector("Hyper-V Virtual Machine Health Summary", nil, []string{
healthCritical,
healthOk,
})
c.perfDataCollectorVirtualMachineHealthSummary, err = pdh.NewCollector[perfDataCounterValuesVirtualMachineHealthSummary](pdh.CounterTypeRaw, "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)
}
@@ -61,27 +58,22 @@ func (c *Collector) buildVirtualMachineHealthSummary() error {
}
func (c *Collector) collectVirtualMachineHealthSummary(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorVirtualMachineHealthSummary.Collect()
err := c.perfDataCollectorVirtualMachineHealthSummary.Collect(&c.perfDataObjectVirtualMachineHealthSummary)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Virtual Machine Health Summary metrics: %w", err)
}
healthData, ok := data[perfdata.InstanceEmpty]
if !ok {
return errors.New("no data returned for Hyper-V Virtual Machine Health Summary")
}
ch <- prometheus.MustNewConstMetric(
c.health,
prometheus.GaugeValue,
healthData[healthCritical].FirstValue,
c.perfDataObjectVirtualMachineHealthSummary[0].HealthCritical,
"critical",
)
ch <- prometheus.MustNewConstMetric(
c.health,
prometheus.GaugeValue,
healthData[healthOk].FirstValue,
c.perfDataObjectVirtualMachineHealthSummary[0].HealthOk,
"ok",
)

View File

@@ -18,33 +18,33 @@ package hyperv
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"
)
// collectorVirtualMachineVidPartition Hyper-V VM Vid Partition metrics
type collectorVirtualMachineVidPartition struct {
perfDataCollectorVirtualMachineVidPartition *perfdata.Collector
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
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
}
const (
physicalPagesAllocated = "Physical Pages Allocated"
preferredNUMANodeIndex = "Preferred NUMA Node Index"
remotePhysicalPages = "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 = perfdata.NewCollector("Hyper-V VM Vid Partition", perfdata.InstancesAll, []string{
physicalPagesAllocated,
preferredNUMANodeIndex,
remotePhysicalPages,
})
c.perfDataCollectorVirtualMachineVidPartition, err = pdh.NewCollector[perfDataCounterValuesVirtualMachineVidPartition](pdh.CounterTypeRaw, "Hyper-V VM Vid Partition", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V VM Vid Partition collector: %w", err)
}
@@ -72,31 +72,31 @@ func (c *Collector) buildVirtualMachineVidPartition() error {
}
func (c *Collector) collectVirtualMachineVidPartition(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorVirtualMachineVidPartition.Collect()
err := c.perfDataCollectorVirtualMachineVidPartition.Collect(&c.perfDataObjectVirtualMachineVidPartition)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V VM Vid Partition metrics: %w", err)
}
for name, page := range data {
for _, data := range c.perfDataObjectVirtualMachineVidPartition {
ch <- prometheus.MustNewConstMetric(
c.physicalPagesAllocated,
prometheus.GaugeValue,
page[physicalPagesAllocated].FirstValue,
name,
data.PhysicalPagesAllocated,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.preferredNUMANodeIndex,
prometheus.GaugeValue,
page[preferredNUMANodeIndex].FirstValue,
name,
data.PreferredNUMANodeIndex,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.remotePhysicalPages,
prometheus.GaugeValue,
page[remotePhysicalPages].FirstValue,
name,
data.RemotePhysicalPages,
data.Name,
)
}

View File

@@ -18,14 +18,15 @@ package hyperv
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"
)
// collectorVirtualNetworkAdapter Hyper-V Virtual Network Adapter metrics
type collectorVirtualNetworkAdapter struct {
perfDataCollectorVirtualNetworkAdapter *perfdata.Collector
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
@@ -35,26 +36,21 @@ type collectorVirtualNetworkAdapter struct {
virtualNetworkAdapterPacketsSent *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Packets Sent/sec
}
const (
virtualNetworkAdapterBytesReceived = "Bytes Received/sec"
virtualNetworkAdapterBytesSent = "Bytes Sent/sec"
virtualNetworkAdapterDroppedPacketsIncoming = "Dropped Packets Incoming/sec"
virtualNetworkAdapterDroppedPacketsOutgoing = "Dropped Packets Outgoing/sec"
virtualNetworkAdapterPacketsReceived = "Packets Received/sec"
virtualNetworkAdapterPacketsSent = "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 = perfdata.NewCollector("Hyper-V Virtual Network Adapter", perfdata.InstancesAll, []string{
virtualNetworkAdapterBytesReceived,
virtualNetworkAdapterBytesSent,
virtualNetworkAdapterDroppedPacketsIncoming,
virtualNetworkAdapterDroppedPacketsOutgoing,
virtualNetworkAdapterPacketsReceived,
virtualNetworkAdapterPacketsSent,
})
c.perfDataCollectorVirtualNetworkAdapter, err = pdh.NewCollector[perfDataCounterValuesVirtualNetworkAdapter](pdh.CounterTypeRaw, "Hyper-V Virtual Network Adapter", pdh.InstancesAll)
if err != nil {
return fmt.Errorf("failed to create Hyper-V Virtual Network Adapter collector: %w", err)
}
@@ -100,52 +96,52 @@ func (c *Collector) buildVirtualNetworkAdapter() error {
}
func (c *Collector) collectVirtualNetworkAdapter(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorVirtualNetworkAdapter.Collect()
err := c.perfDataCollectorVirtualNetworkAdapter.Collect(&c.perfDataObjectVirtualNetworkAdapter)
if err != nil {
return fmt.Errorf("failed to collect Hyper-V Virtual Network Adapter metrics: %w", err)
}
for name, adapterData := range data {
for _, data := range c.perfDataObjectVirtualNetworkAdapter {
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterBytesReceived,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterBytesReceived].FirstValue,
name,
data.VirtualNetworkAdapterBytesReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterBytesSent,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterBytesSent].FirstValue,
name,
data.VirtualNetworkAdapterBytesSent,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDroppedPacketsIncoming,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDroppedPacketsIncoming].FirstValue,
name,
data.VirtualNetworkAdapterDroppedPacketsIncoming,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDroppedPacketsOutgoing,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDroppedPacketsOutgoing].FirstValue,
name,
data.VirtualNetworkAdapterDroppedPacketsOutgoing,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterPacketsReceived,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterPacketsReceived].FirstValue,
name,
data.VirtualNetworkAdapterPacketsReceived,
data.Name,
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterPacketsSent,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterPacketsSent].FirstValue,
name,
data.VirtualNetworkAdapterPacketsSent,
data.Name,
)
}

View File

@@ -18,14 +18,15 @@ package hyperv
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"
)
// collectorVirtualNetworkAdapterDropReasons Hyper-V Virtual Network Adapter Drop Reasons metrics
type collectorVirtualNetworkAdapterDropReasons struct {
perfDataCollectorVirtualNetworkAdapterDropReasons *perfdata.Collector
perfDataCollectorVirtualNetworkAdapterDropReasons *pdh.Collector
perfDataObjectVirtualNetworkAdapterDropReasons []perfDataCounterValuesVirtualNetworkAdapterDropReasons
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing LowPowerPacketFilter
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming LowPowerPacketFilter
@@ -106,114 +107,65 @@ type collectorVirtualNetworkAdapterDropReasons struct {
virtualNetworkAdapterDropReasons *prometheus.Desc
}
const (
virtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq = "Outgoing NativeFwdingReq"
virtualNetworkAdapterDropReasonsIncomingNativeFwdingReq = "Incoming NativeFwdingReq"
virtualNetworkAdapterDropReasonsOutgoingMTUMismatch = "Outgoing MTUMismatch"
virtualNetworkAdapterDropReasonsIncomingMTUMismatch = "Incoming MTUMismatch"
virtualNetworkAdapterDropReasonsOutgoingInvalidConfig = "Outgoing InvalidConfig"
virtualNetworkAdapterDropReasonsIncomingInvalidConfig = "Incoming InvalidConfig"
virtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing = "Outgoing RequiredExtensionMissing"
virtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing = "Incoming RequiredExtensionMissing"
virtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId = "Outgoing VirtualSubnetId"
virtualNetworkAdapterDropReasonsIncomingVirtualSubnetId = "Incoming VirtualSubnetId"
virtualNetworkAdapterDropReasonsOutgoingBridgeReserved = "Outgoing BridgeReserved"
virtualNetworkAdapterDropReasonsIncomingBridgeReserved = "Incoming BridgeReserved"
virtualNetworkAdapterDropReasonsOutgoingRouterGuard = "Outgoing RouterGuard"
virtualNetworkAdapterDropReasonsIncomingRouterGuard = "Incoming RouterGuard"
virtualNetworkAdapterDropReasonsOutgoingDhcpGuard = "Outgoing DhcpGuard"
virtualNetworkAdapterDropReasonsIncomingDhcpGuard = "Incoming DhcpGuard"
virtualNetworkAdapterDropReasonsOutgoingMacSpoofing = "Outgoing MacSpoofing"
virtualNetworkAdapterDropReasonsIncomingMacSpoofing = "Incoming MacSpoofing"
virtualNetworkAdapterDropReasonsOutgoingIpsec = "Outgoing Ipsec"
virtualNetworkAdapterDropReasonsIncomingIpsec = "Incoming Ipsec"
virtualNetworkAdapterDropReasonsOutgoingQos = "Outgoing Qos"
virtualNetworkAdapterDropReasonsIncomingQos = "Incoming Qos"
virtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting = "Outgoing FailedPvlanSetting"
virtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting = "Incoming FailedPvlanSetting"
virtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy = "Outgoing FailedSecurityPolicy"
virtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy = "Incoming FailedSecurityPolicy"
virtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC = "Outgoing UnauthorizedMAC"
virtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC = "Incoming UnauthorizedMAC"
virtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN = "Outgoing UnauthorizedVLAN"
virtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN = "Incoming UnauthorizedVLAN"
virtualNetworkAdapterDropReasonsOutgoingFilteredVLAN = "Outgoing FilteredVLAN"
virtualNetworkAdapterDropReasonsIncomingFilteredVLAN = "Incoming FilteredVLAN"
virtualNetworkAdapterDropReasonsOutgoingFiltered = "Outgoing Filtered"
virtualNetworkAdapterDropReasonsIncomingFiltered = "Incoming Filtered"
virtualNetworkAdapterDropReasonsOutgoingBusy = "Outgoing Busy"
virtualNetworkAdapterDropReasonsIncomingBusy = "Incoming Busy"
virtualNetworkAdapterDropReasonsOutgoingNotAccepted = "Outgoing NotAccepted"
virtualNetworkAdapterDropReasonsIncomingNotAccepted = "Incoming NotAccepted"
virtualNetworkAdapterDropReasonsOutgoingDisconnected = "Outgoing Disconnected"
virtualNetworkAdapterDropReasonsIncomingDisconnected = "Incoming Disconnected"
virtualNetworkAdapterDropReasonsOutgoingNotReady = "Outgoing NotReady"
virtualNetworkAdapterDropReasonsIncomingNotReady = "Incoming NotReady"
virtualNetworkAdapterDropReasonsOutgoingResources = "Outgoing Resources"
virtualNetworkAdapterDropReasonsIncomingResources = "Incoming Resources"
virtualNetworkAdapterDropReasonsOutgoingInvalidPacket = "Outgoing InvalidPacket"
virtualNetworkAdapterDropReasonsIncomingInvalidPacket = "Incoming InvalidPacket"
virtualNetworkAdapterDropReasonsOutgoingInvalidData = "Outgoing InvalidData"
virtualNetworkAdapterDropReasonsIncomingInvalidData = "Incoming InvalidData"
virtualNetworkAdapterDropReasonsOutgoingUnknown = "Outgoing Unknown"
virtualNetworkAdapterDropReasonsIncomingUnknown = "Incoming Unknown"
)
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 = perfdata.NewCollector("Hyper-V Virtual Network Adapter Drop Reasons", perfdata.InstancesAll, []string{
virtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq,
virtualNetworkAdapterDropReasonsIncomingNativeFwdingReq,
virtualNetworkAdapterDropReasonsOutgoingMTUMismatch,
virtualNetworkAdapterDropReasonsIncomingMTUMismatch,
virtualNetworkAdapterDropReasonsOutgoingInvalidConfig,
virtualNetworkAdapterDropReasonsIncomingInvalidConfig,
virtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing,
virtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing,
virtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId,
virtualNetworkAdapterDropReasonsIncomingVirtualSubnetId,
virtualNetworkAdapterDropReasonsOutgoingBridgeReserved,
virtualNetworkAdapterDropReasonsIncomingBridgeReserved,
virtualNetworkAdapterDropReasonsOutgoingRouterGuard,
virtualNetworkAdapterDropReasonsIncomingRouterGuard,
virtualNetworkAdapterDropReasonsOutgoingDhcpGuard,
virtualNetworkAdapterDropReasonsIncomingDhcpGuard,
virtualNetworkAdapterDropReasonsOutgoingMacSpoofing,
virtualNetworkAdapterDropReasonsIncomingMacSpoofing,
virtualNetworkAdapterDropReasonsOutgoingIpsec,
virtualNetworkAdapterDropReasonsIncomingIpsec,
virtualNetworkAdapterDropReasonsOutgoingQos,
virtualNetworkAdapterDropReasonsIncomingQos,
virtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting,
virtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting,
virtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy,
virtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy,
virtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC,
virtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC,
virtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN,
virtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN,
virtualNetworkAdapterDropReasonsOutgoingFilteredVLAN,
virtualNetworkAdapterDropReasonsIncomingFilteredVLAN,
virtualNetworkAdapterDropReasonsOutgoingFiltered,
virtualNetworkAdapterDropReasonsIncomingFiltered,
virtualNetworkAdapterDropReasonsOutgoingBusy,
virtualNetworkAdapterDropReasonsIncomingBusy,
virtualNetworkAdapterDropReasonsOutgoingNotAccepted,
virtualNetworkAdapterDropReasonsIncomingNotAccepted,
virtualNetworkAdapterDropReasonsOutgoingDisconnected,
virtualNetworkAdapterDropReasonsIncomingDisconnected,
virtualNetworkAdapterDropReasonsOutgoingNotReady,
virtualNetworkAdapterDropReasonsIncomingNotReady,
virtualNetworkAdapterDropReasonsOutgoingResources,
virtualNetworkAdapterDropReasonsIncomingResources,
virtualNetworkAdapterDropReasonsOutgoingInvalidPacket,
virtualNetworkAdapterDropReasonsIncomingInvalidPacket,
virtualNetworkAdapterDropReasonsOutgoingInvalidData,
virtualNetworkAdapterDropReasonsIncomingInvalidData,
virtualNetworkAdapterDropReasonsOutgoingUnknown,
virtualNetworkAdapterDropReasonsIncomingUnknown,
})
c.perfDataCollectorVirtualNetworkAdapterDropReasons, err = pdh.NewCollector[perfDataCounterValuesVirtualNetworkAdapterDropReasons](pdh.CounterTypeRaw, "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)
}
@@ -229,311 +181,311 @@ func (c *Collector) buildVirtualNetworkAdapterDropReasons() error {
}
func (c *Collector) collectVirtualNetworkAdapterDropReasons(ch chan<- prometheus.Metric) error {
data, err := c.perfDataCollectorVirtualNetworkAdapterDropReasons.Collect()
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 name, adapterData := range data {
for _, data := range c.perfDataObjectVirtualNetworkAdapterDropReasons {
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq].FirstValue,
name, "NativeFwdingReq", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq,
data.Name, "NativeFwdingReq", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingNativeFwdingReq].FirstValue,
name, "NativeFwdingReq", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingNativeFwdingReq,
data.Name, "NativeFwdingReq", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingMTUMismatch].FirstValue,
name, "MTUMismatch", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingMTUMismatch,
data.Name, "MTUMismatch", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingMTUMismatch].FirstValue,
name, "MTUMismatch", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingMTUMismatch,
data.Name, "MTUMismatch", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingInvalidConfig].FirstValue,
name, "InvalidConfig", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidConfig,
data.Name, "InvalidConfig", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingInvalidConfig].FirstValue,
name, "InvalidConfig", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingInvalidConfig,
data.Name, "InvalidConfig", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing].FirstValue,
name, "RequiredExtensionMissing", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing,
data.Name, "RequiredExtensionMissing", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing].FirstValue,
name, "RequiredExtensionMissing", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing,
data.Name, "RequiredExtensionMissing", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId].FirstValue,
name, "VirtualSubnetId", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId,
data.Name, "VirtualSubnetId", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingVirtualSubnetId].FirstValue,
name, "VirtualSubnetId", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingVirtualSubnetId,
data.Name, "VirtualSubnetId", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingBridgeReserved].FirstValue,
name, "BridgeReserved", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingBridgeReserved,
data.Name, "BridgeReserved", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingBridgeReserved].FirstValue,
name, "BridgeReserved", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingBridgeReserved,
data.Name, "BridgeReserved", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingRouterGuard].FirstValue,
name, "RouterGuard", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingRouterGuard,
data.Name, "RouterGuard", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingRouterGuard].FirstValue,
name, "RouterGuard", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingRouterGuard,
data.Name, "RouterGuard", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingDhcpGuard].FirstValue,
name, "DhcpGuard", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingDhcpGuard,
data.Name, "DhcpGuard", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingDhcpGuard].FirstValue,
name, "DhcpGuard", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingDhcpGuard,
data.Name, "DhcpGuard", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingMacSpoofing].FirstValue,
name, "MacSpoofing", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingMacSpoofing,
data.Name, "MacSpoofing", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingMacSpoofing].FirstValue,
name, "MacSpoofing", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingMacSpoofing,
data.Name, "MacSpoofing", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingIpsec].FirstValue,
name, "Ipsec", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingIpsec,
data.Name, "Ipsec", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingIpsec].FirstValue,
name, "Ipsec", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingIpsec,
data.Name, "Ipsec", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingQos].FirstValue,
name, "Qos", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingQos,
data.Name, "Qos", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingQos].FirstValue,
name, "Qos", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingQos,
data.Name, "Qos", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting].FirstValue,
name, "FailedPvlanSetting", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting,
data.Name, "FailedPvlanSetting", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting].FirstValue,
name, "FailedPvlanSetting", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting,
data.Name, "FailedPvlanSetting", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy].FirstValue,
name, "FailedSecurityPolicy", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy,
data.Name, "FailedSecurityPolicy", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy].FirstValue,
name, "FailedSecurityPolicy", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy,
data.Name, "FailedSecurityPolicy", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC].FirstValue,
name, "UnauthorizedMAC", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC,
data.Name, "UnauthorizedMAC", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC].FirstValue,
name, "UnauthorizedMAC", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC,
data.Name, "UnauthorizedMAC", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN].FirstValue,
name, "UnauthorizedVLAN", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN,
data.Name, "UnauthorizedVLAN", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN].FirstValue,
name, "UnauthorizedVLAN", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN,
data.Name, "UnauthorizedVLAN", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingFilteredVLAN].FirstValue,
name, "FilteredVLAN", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingFilteredVLAN,
data.Name, "FilteredVLAN", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingFilteredVLAN].FirstValue,
name, "FilteredVLAN", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingFilteredVLAN,
data.Name, "FilteredVLAN", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingFiltered].FirstValue,
name, "Filtered", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingFiltered,
data.Name, "Filtered", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingFiltered].FirstValue,
name, "Filtered", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingFiltered,
data.Name, "Filtered", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingBusy].FirstValue,
name, "Busy", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingBusy,
data.Name, "Busy", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingBusy].FirstValue,
name, "Busy", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingBusy,
data.Name, "Busy", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingNotAccepted].FirstValue,
name, "NotAccepted", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingNotAccepted,
data.Name, "NotAccepted", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingNotAccepted].FirstValue,
name, "NotAccepted", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingNotAccepted,
data.Name, "NotAccepted", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingDisconnected].FirstValue,
name, "Disconnected", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingDisconnected,
data.Name, "Disconnected", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingDisconnected].FirstValue,
name, "Disconnected", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingDisconnected,
data.Name, "Disconnected", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingNotReady].FirstValue,
name, "NotReady", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingNotReady,
data.Name, "NotReady", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingNotReady].FirstValue,
name, "NotReady", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingNotReady,
data.Name, "NotReady", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingResources].FirstValue,
name, "Resources", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingResources,
data.Name, "Resources", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingResources].FirstValue,
name, "Resources", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingResources,
data.Name, "Resources", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingInvalidPacket].FirstValue,
name, "InvalidPacket", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidPacket,
data.Name, "InvalidPacket", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingInvalidPacket].FirstValue,
name, "InvalidPacket", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingInvalidPacket,
data.Name, "InvalidPacket", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingInvalidData].FirstValue,
name, "InvalidData", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidData,
data.Name, "InvalidData", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingInvalidData].FirstValue,
name, "InvalidData", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingInvalidData,
data.Name, "InvalidData", "incoming",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsOutgoingUnknown].FirstValue,
name, "Unknown", "outgoing",
data.VirtualNetworkAdapterDropReasonsOutgoingUnknown,
data.Name, "Unknown", "outgoing",
)
ch <- prometheus.MustNewConstMetric(
c.virtualNetworkAdapterDropReasons,
prometheus.CounterValue,
adapterData[virtualNetworkAdapterDropReasonsIncomingUnknown].FirstValue,
name, "Unknown", "incoming",
data.VirtualNetworkAdapterDropReasonsIncomingUnknown,
data.Name, "Unknown", "incoming",
)
}

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