mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-08 22:16:38 +00:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65d19f433e | ||
|
|
2d334e4df0 | ||
|
|
f442d6e22a | ||
|
|
d43f6ffdec | ||
|
|
9bea340c44 | ||
|
|
2635e5d8eb | ||
|
|
41ff5729df | ||
|
|
6097432d87 | ||
|
|
5f36a81613 | ||
|
|
2e4ba9984d | ||
|
|
fb275a06fe | ||
|
|
064ea74b6f | ||
|
|
25b642b584 | ||
|
|
f712c07c38 | ||
|
|
83b0aa8f62 | ||
|
|
9780a6aec6 | ||
|
|
b3c0c58c17 | ||
|
|
50687655bf | ||
|
|
26556950d0 | ||
|
|
f72147c4df | ||
|
|
2008dc5b23 | ||
|
|
37664cb19a | ||
|
|
e6b74b690a | ||
|
|
7d2fc83abe |
@@ -1,6 +1,16 @@
|
||||
root = true
|
||||
|
||||
[*.wxs]
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
tab_width = 4
|
||||
|
||||
[*.{json,wxs,xml}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
22
.github/workflows/container_description.yml
vendored
22
.github/workflows/container_description.yml
vendored
@@ -33,25 +33,3 @@ jobs:
|
||||
# Empty string results in README-containers.md being pushed if it
|
||||
# exists. Otherwise, README.md is pushed.
|
||||
readme_file: ''
|
||||
|
||||
PushQuayIoReadme:
|
||||
runs-on: ubuntu-latest
|
||||
name: Push README to quay.io
|
||||
if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks.
|
||||
steps:
|
||||
- name: git checkout
|
||||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
|
||||
- name: Set quay.io org name
|
||||
run: echo "DOCKER_REPO=$(echo quay.io/${GITHUB_REPOSITORY_OWNER} | tr -d '-')" >> $GITHUB_ENV
|
||||
- name: Set quay.io repo name
|
||||
run: echo "DOCKER_REPO_NAME=$(make docker-repo-name)" >> $GITHUB_ENV
|
||||
- name: Push README to quay.io
|
||||
uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1
|
||||
env:
|
||||
DOCKER_APIKEY: ${{ secrets.QUAY_IO_API_TOKEN }}
|
||||
with:
|
||||
destination_container_repo: ${{ env.DOCKER_REPO_NAME }}
|
||||
provider: quay
|
||||
# Empty string results in README-containers.md being pushed if it
|
||||
# exists. Otherwise, README.md is pushed.
|
||||
readme_file: ''
|
||||
|
||||
20
.github/workflows/lint.yml
vendored
20
.github/workflows/lint.yml
vendored
@@ -12,6 +12,8 @@ on:
|
||||
- "tools/e2e-output.txt"
|
||||
branches:
|
||||
- master
|
||||
- next
|
||||
- main
|
||||
pull_request:
|
||||
paths:
|
||||
- "go.mod"
|
||||
@@ -21,9 +23,11 @@ on:
|
||||
- "tools/e2e-output.txt"
|
||||
branches:
|
||||
- master
|
||||
- next
|
||||
- main
|
||||
|
||||
env:
|
||||
PROMU_VER: '0.14.0'
|
||||
VERSION_PROMU: '0.14.0'
|
||||
PROMTOOL_VER: '2.43.0'
|
||||
|
||||
jobs:
|
||||
@@ -40,9 +44,9 @@ jobs:
|
||||
|
||||
- name: Install e2e deps
|
||||
run: |
|
||||
Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:PROMU_VER)/promu-$($Env:PROMU_VER).windows-amd64.zip -OutFile promu-$($Env:PROMU_VER).windows-amd64.zip
|
||||
Expand-Archive -Path promu-$($Env:PROMU_VER).windows-amd64.zip -DestinationPath .
|
||||
Copy-Item -Path promu-$($Env:PROMU_VER).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"
|
||||
Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:VERSION_PROMU)/promu-$($Env:VERSION_PROMU).windows-amd64.zip -OutFile promu-$($Env:VERSION_PROMU).windows-amd64.zip
|
||||
Expand-Archive -Path promu-$($Env:VERSION_PROMU).windows-amd64.zip -DestinationPath .
|
||||
Copy-Item -Path promu-$($Env:VERSION_PROMU).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"
|
||||
|
||||
# GOPATH\bin dir must be appended to PATH else the `promu` command won't be found
|
||||
echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
@@ -64,9 +68,9 @@ jobs:
|
||||
Expand-Archive -Path prometheus-$($Env:PROMTOOL_VER).windows-amd64.zip -DestinationPath .
|
||||
Copy-Item -Path prometheus-$($Env:PROMTOOL_VER).windows-amd64\promtool.exe -Destination "$(go env GOPATH)\bin"
|
||||
|
||||
Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:PROMU_VER)/promu-$($Env:PROMU_VER).windows-amd64.zip -OutFile promu-$($Env:PROMU_VER).windows-amd64.zip
|
||||
Expand-Archive -Path promu-$($Env:PROMU_VER).windows-amd64.zip -DestinationPath .
|
||||
Copy-Item -Path promu-$($Env:PROMU_VER).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"
|
||||
Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:VERSION_PROMU)/promu-$($Env:VERSION_PROMU).windows-amd64.zip -OutFile promu-$($Env:VERSION_PROMU).windows-amd64.zip
|
||||
Expand-Archive -Path promu-$($Env:VERSION_PROMU).windows-amd64.zip -DestinationPath .
|
||||
Copy-Item -Path promu-$($Env:VERSION_PROMU).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"
|
||||
|
||||
# GOPATH\bin dir must be appended to PATH else the `promu` command won't be found
|
||||
echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
@@ -101,4 +105,4 @@ jobs:
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: v1.60
|
||||
args: "--timeout=5m --max-same-issues=0"
|
||||
args: "--max-same-issues=0"
|
||||
2
.github/workflows/pr-check.yaml
vendored
2
.github/workflows/pr-check.yaml
vendored
@@ -37,7 +37,7 @@ jobs:
|
||||
- name: check
|
||||
run: |
|
||||
PR_TITLE_PREFIX=$(echo "$PR_TITLE" | cut -d':' -f1)
|
||||
if [[ -d "pkg/collector/$PR_TITLE_PREFIX" ]] || [[ -d "$PR_TITLE_PREFIX" ]] || [[ "$PR_TITLE_PREFIX" == "chore" ]] || [[ "$PR_TITLE_PREFIX" == "chore(deps)" ]] || [[ "$PR_TITLE_PREFIX" == "*" ]] || [[ "$PR_TITLE_PREFIX" == "Synchronize common files from prometheus/prometheus" ]]; then
|
||||
if [[ -d "pkg/collector/$PR_TITLE_PREFIX" ]] ||[[ -d "pkg/$PR_TITLE_PREFIX" ]] || [[ -d "$PR_TITLE_PREFIX" ]] || [[ "$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
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
39
.github/workflows/release.yml
vendored
39
.github/workflows/release.yml
vendored
@@ -16,7 +16,10 @@ permissions:
|
||||
packages: write
|
||||
|
||||
env:
|
||||
PROMU_VER: '0.14.0'
|
||||
VERSION_PROMU: '0.14.0'
|
||||
VERSION_CONTAINERD: '1.7.21'
|
||||
VERSION_BUILDKIT: '0.15.2'
|
||||
VERSION_BUILDX: '0.16.2'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -24,8 +27,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
# fetch-depth required for gitversion in `Build` step
|
||||
fetch-depth: 0
|
||||
fetch-depth: '0'
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
@@ -34,41 +36,38 @@ jobs:
|
||||
# https://github.com/pl4nty/Windows-Containers/blob/Main/helpful_tools/Install-BuildKit-GitHubActions/workflow.yaml
|
||||
- name: Setup containerd
|
||||
run: |
|
||||
$version = "1.7.20"
|
||||
curl.exe -L https://github.com/containerd/containerd/releases/download/v$version/containerd-$version-windows-amd64.tar.gz -o containerd.tar.gz
|
||||
curl.exe -L https://github.com/containerd/containerd/releases/download/v${{ env.VERSION_CONTAINERD }}/containerd-${{ env.VERSION_CONTAINERD }}-windows-amd64.tar.gz -o containerd.tar.gz
|
||||
tar.exe xvf containerd.tar.gz
|
||||
.\bin\containerd.exe --register-service
|
||||
Start-Service containerd
|
||||
- name: Setup BuildKit
|
||||
run: |
|
||||
$version = "v0.15.0"
|
||||
curl.exe -L https://github.com/moby/buildkit/releases/download/$version/buildkit-$version.windows-amd64.tar.gz -o buildkit.tar.gz
|
||||
curl.exe -L https://github.com/moby/buildkit/releases/download/v${{ env.VERSION_BUILDKIT }}/buildkit-v${{ env.VERSION_BUILDKIT }}.windows-amd64.tar.gz -o buildkit.tar.gz
|
||||
tar.exe xvf buildkit.tar.gz
|
||||
|
||||
.\bin\buildkitd.exe --register-service
|
||||
Start-Service buildkitd
|
||||
- name: Setup Docker Buildx
|
||||
run: |
|
||||
$version = "v0.16.1"
|
||||
curl.exe -L https://github.com/docker/buildx/releases/download/$version/buildx-$version.windows-amd64.exe -o $env:ProgramData\Docker\cli-plugins\docker-buildx.exe
|
||||
curl.exe -L https://github.com/docker/buildx/releases/download/v${{ env.VERSION_BUILDX }}/buildx-v${{ env.VERSION_BUILDX }}.windows-amd64.exe -o $env:ProgramData\Docker\cli-plugins\docker-buildx.exe
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver: remote
|
||||
endpoint: npipe:////./pipe/buildkitd
|
||||
|
||||
- name: Install WiX
|
||||
run: dotnet tool install --global wix
|
||||
|
||||
- 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
|
||||
|
||||
- name: Install Build deps
|
||||
run: |
|
||||
Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:PROMU_VER)/promu-$($Env:PROMU_VER).windows-amd64.zip -OutFile promu-$($Env:PROMU_VER).windows-amd64.zip
|
||||
Expand-Archive -Path promu-$($Env:PROMU_VER).windows-amd64.zip -DestinationPath .
|
||||
Copy-Item -Path promu-$($Env:PROMU_VER).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"
|
||||
Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:VERSION_PROMU)/promu-$($Env:VERSION_PROMU).windows-amd64.zip -OutFile promu-$($Env:VERSION_PROMU).windows-amd64.zip
|
||||
Expand-Archive -Path promu-$($Env:VERSION_PROMU).windows-amd64.zip -DestinationPath .
|
||||
Copy-Item -Path promu-$($Env:VERSION_PROMU).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"
|
||||
|
||||
# GOPATH\bin dir must be added to PATH else the `promu` commands won't be found
|
||||
echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
@@ -92,12 +91,6 @@ jobs:
|
||||
|
||||
Get-ChildItem -Path output
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows_exporter_binaries
|
||||
path: output\windows_exporter-*.exe
|
||||
|
||||
- name: Build Release Artifacts
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -113,6 +106,14 @@ jobs:
|
||||
|
||||
promu checksum output\
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows_exporter_binaries
|
||||
path: |
|
||||
output\windows_exporter-*.exe
|
||||
output\windows_exporter-*.msi
|
||||
|
||||
- name: Build Docker Artifacts
|
||||
run: make build-all
|
||||
env:
|
||||
|
||||
2
.github/workflows/spelling.yml
vendored
2
.github/workflows/spelling.yml
vendored
@@ -10,7 +10,7 @@ on:
|
||||
- master
|
||||
|
||||
env:
|
||||
PROMU_VER: 'v0.14.0'
|
||||
VERSION_PROMU: 'v0.14.0'
|
||||
|
||||
jobs:
|
||||
codespell:
|
||||
|
||||
29
.github/workflows/stale-close.yml
vendored
Normal file
29
.github/workflows/stale-close.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: 'Close stale issues and PRs'
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
schedule:
|
||||
- cron: '30 1 * * *'
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
jobs:
|
||||
stale:
|
||||
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
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# opt out of defaults to avoid marking issues as stale and closing them
|
||||
# https://github.com/actions/stale#days-before-close
|
||||
# https://github.com/actions/stale#days-before-stale
|
||||
days-before-stale: -1
|
||||
days-before-close: -1
|
||||
stale-pr-message: ''
|
||||
stale-issue-message: 'This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.'
|
||||
operations-per-run: 30
|
||||
# override days-before-stale, for only marking the pull requests as stale
|
||||
days-before-issue-stale: 90
|
||||
days-before-issue-close: 30
|
||||
stale-pr-label: stale
|
||||
exempt-pr-labels: keepalive
|
||||
32
.github/workflows/stale.yml
vendored
32
.github/workflows/stale.yml
vendored
@@ -1,21 +1,31 @@
|
||||
name: 'Close stale issues and PRs'
|
||||
name: Stale Check
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
schedule:
|
||||
- cron: '30 1 * * *'
|
||||
|
||||
- cron: '16 22 * * *'
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
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@v9
|
||||
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
|
||||
with:
|
||||
stale-issue-message: 'This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.'
|
||||
exempt-issue-labels: 'lifecycle/frozen'
|
||||
days-before-stale: 90
|
||||
days-before-close: 30
|
||||
enable-statistics: false
|
||||
operations-per-run: 500
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# opt out of defaults to avoid marking issues as stale and closing them
|
||||
# https://github.com/actions/stale#days-before-close
|
||||
# https://github.com/actions/stale#days-before-stale
|
||||
days-before-stale: -1
|
||||
days-before-close: -1
|
||||
# Setting it to empty string to skip comments.
|
||||
# https://github.com/actions/stale#stale-pr-message
|
||||
# https://github.com/actions/stale#stale-issue-message
|
||||
stale-pr-message: ''
|
||||
stale-issue-message: ''
|
||||
operations-per-run: 30
|
||||
# override days-before-stale, for only marking the pull requests as stale
|
||||
days-before-pr-stale: 60
|
||||
stale-pr-label: stale
|
||||
exempt-pr-labels: keepalive
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- containedctx
|
||||
- contextcheck
|
||||
- cyclop
|
||||
- depguard
|
||||
- dogsled
|
||||
- dupl
|
||||
- err113
|
||||
- execinquery
|
||||
- exhaustive
|
||||
- exhaustruct
|
||||
- exportloopref
|
||||
@@ -17,21 +15,16 @@ linters:
|
||||
- gocognit
|
||||
- goconst
|
||||
- gocyclo
|
||||
- godox
|
||||
- inamedparam
|
||||
- ireturn
|
||||
- gomnd
|
||||
- lll
|
||||
- maintidx
|
||||
- mnd
|
||||
- nlreturn
|
||||
- noctx
|
||||
- testpackage
|
||||
- varnamelen
|
||||
- wrapcheck
|
||||
- wsl
|
||||
- execinquery
|
||||
- gomnd
|
||||
- stylecheck
|
||||
- maintidx
|
||||
|
||||
run:
|
||||
timeout: 5m
|
||||
|
||||
linters-settings:
|
||||
gosec:
|
||||
@@ -52,7 +45,30 @@ linters-settings:
|
||||
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `upperSnake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header`
|
||||
json: camel
|
||||
yaml: snake
|
||||
|
||||
forbidigo:
|
||||
forbid:
|
||||
- "^(fmt\\.Print(|f|ln)|print|println)$"
|
||||
- p: "^syscall\\..*$"
|
||||
msg: use golang.org/x/sys/windows instead of syscall
|
||||
- p: "^windows\\.NewLazyDLL$"
|
||||
msg: use NewLazySystemDLL instead NewLazyDLL
|
||||
sloglint:
|
||||
no-mixed-args: true
|
||||
kv-only: false
|
||||
attr-only: true
|
||||
no-global: "all"
|
||||
context: "scope"
|
||||
static-msg: false
|
||||
no-raw-keys: false
|
||||
key-naming-case: snake
|
||||
forbidden-keys:
|
||||
- time
|
||||
- level
|
||||
- msg
|
||||
- source
|
||||
args-on-sep-lines: true
|
||||
stylecheck:
|
||||
checks: ["all", "-ST1003"]
|
||||
issues:
|
||||
exclude:
|
||||
- don't use underscores in Go names
|
||||
@@ -66,3 +82,7 @@ issues:
|
||||
- text: "don't use ALL_CAPS in Go names; use CamelCase"
|
||||
linters:
|
||||
- revive
|
||||
- path: pkg/perflib/
|
||||
linters:
|
||||
- godox
|
||||
- stylecheck
|
||||
|
||||
33
.promu.yml
33
.promu.yml
@@ -1,19 +1,24 @@
|
||||
go:
|
||||
version: 1.20
|
||||
# Whenever the Go version is updated here,
|
||||
# .github/workflows should also be updated.
|
||||
version: 1.23
|
||||
repository:
|
||||
path: github.com/prometheus-community/windows_exporter
|
||||
path: github.com/prometheus-community/windows_exporter
|
||||
build:
|
||||
binaries:
|
||||
- name: windows_exporter
|
||||
ldflags: |
|
||||
-X github.com/prometheus/common/version.Version={{.Version}}
|
||||
-X github.com/prometheus/common/version.Revision={{.Revision}}
|
||||
-X github.com/prometheus/common/version.Branch={{.Branch}}
|
||||
-X github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
|
||||
-X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
|
||||
binaries:
|
||||
- name: windows_exporter
|
||||
tags:
|
||||
all:
|
||||
- trimpath
|
||||
ldflags: |
|
||||
-X github.com/prometheus/common/version.Version={{.Version}}
|
||||
-X github.com/prometheus/common/version.Revision={{.Revision}}
|
||||
-X github.com/prometheus/common/version.Branch={{.Branch}}
|
||||
-X github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
|
||||
-X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
|
||||
tarball:
|
||||
files:
|
||||
- LICENSE
|
||||
files:
|
||||
- LICENSE
|
||||
crossbuild:
|
||||
platforms:
|
||||
- windows
|
||||
platforms:
|
||||
- windows
|
||||
|
||||
2
Makefile
2
Makefile
@@ -7,7 +7,7 @@ DOCKER_REPO ?= prometheuscommunity
|
||||
DOCKER_IMAGE_NAME ?= windows-exporter
|
||||
|
||||
# ALL_DOCKER_REPOS is the list of repositories to push the image to. ghcr.io requires that org name be the same as the image repo name.
|
||||
ALL_DOCKER_REPOS ?= docker.io/$(DOCKER_REPO) ghcr.io/prometheus-community # quay.io/$(DOCKER_REPO)
|
||||
ALL_DOCKER_REPOS ?= docker.io/$(DOCKER_REPO) ghcr.io/prometheus-community # quay.io/$(DOCKER_REPO)
|
||||
|
||||
# Image Variables for host process Container
|
||||
# Windows image build is heavily influenced by https://github.com/kubernetes/kubernetes/blob/master/cluster/images/etcd/Makefile
|
||||
|
||||
90
README.md
90
README.md
@@ -14,35 +14,29 @@ Name | Description | Enabled by default
|
||||
[cache](docs/collector.cache.md) | Cache metrics |
|
||||
[cpu](docs/collector.cpu.md) | CPU usage | ✓
|
||||
[cpu_info](docs/collector.cpu_info.md) | CPU Information |
|
||||
[cs](docs/collector.cs.md) | "Computer System" metrics (system properties, num cpus/total memory) |
|
||||
[cs](docs/collector.cs.md) | "Computer System" metrics (system properties, num cpus/total memory) |
|
||||
[container](docs/collector.container.md) | Container metrics |
|
||||
[diskdrive](docs/collector.diskdrive.md) | Diskdrive metrics |
|
||||
[dfsr](docs/collector.dfsr.md) | DFSR metrics |
|
||||
[dhcp](docs/collector.dhcp.md) | DHCP Server |
|
||||
[dns](docs/collector.dns.md) | DNS Server |
|
||||
[exchange](docs/collector.exchange.md) | Exchange metrics |
|
||||
[filetime](docs/collector.filetime.md) | FileTime metrics |
|
||||
[fsrmquota](docs/collector.fsrmquota.md) | Microsoft File Server Resource Manager (FSRM) Quotas collector |
|
||||
[hyperv](docs/collector.hyperv.md) | Hyper-V hosts |
|
||||
[iis](docs/collector.iis.md) | IIS sites and applications |
|
||||
[license](docs/collector.license.md) | Windows license status |
|
||||
[license](docs/collector.license.md) | Windows license status |
|
||||
[logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | ✓
|
||||
[logon](docs/collector.logon.md) | User logon sessions |
|
||||
[memory](docs/collector.memory.md) | Memory usage metrics |
|
||||
[memory](docs/collector.memory.md) | Memory usage metrics | ✓
|
||||
[mscluster](docs/collector.mscluster.md) | MSCluster metrics |
|
||||
[msmq](docs/collector.msmq.md) | MSMQ queues |
|
||||
[mssql](docs/collector.mssql.md) | [SQL Server Performance Objects](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/use-sql-server-objects#SQLServerPOs) metrics |
|
||||
[netframework_clrexceptions](docs/collector.netframework_clrexceptions.md) | .NET Framework CLR Exceptions |
|
||||
[netframework_clrinterop](docs/collector.netframework_clrinterop.md) | .NET Framework Interop Metrics |
|
||||
[netframework_clrjit](docs/collector.netframework_clrjit.md) | .NET Framework JIT metrics |
|
||||
[netframework_clrloading](docs/collector.netframework_clrloading.md) | .NET Framework CLR Loading metrics |
|
||||
[netframework_clrlocksandthreads](docs/collector.netframework_clrlocksandthreads.md) | .NET Framework locks and metrics threads |
|
||||
[netframework_clrmemory](docs/collector.netframework_clrmemory.md) | .NET Framework Memory metrics |
|
||||
[netframework_clrremoting](docs/collector.netframework_clrremoting.md) | .NET Framework Remoting metrics |
|
||||
[netframework_clrsecurity](docs/collector.netframework_clrsecurity.md) | .NET Framework Security Check metrics |
|
||||
[netframework](docs/collector.netframework.md) | .NET Framework metrics |
|
||||
[net](docs/collector.net.md) | Network interface I/O | ✓
|
||||
[os](docs/collector.os.md) | OS metrics (memory, processes, users) | ✓
|
||||
[physical_disk](docs/collector.physical_disk.md) | physical disk metrics | ✓
|
||||
[printer](docs/collector.printer.md) | Printer metrics |
|
||||
[printer](docs/collector.printer.md) | Printer metrics |
|
||||
[process](docs/collector.process.md) | Per-process metrics |
|
||||
[remote_fx](docs/collector.remote_fx.md) | RemoteFX protocol (RDP) metrics |
|
||||
[scheduled_task](docs/collector.scheduled_task.md) | Scheduled Tasks metrics |
|
||||
@@ -94,64 +88,76 @@ windows_exporter accepts flags to configure certain behaviours. The ones configu
|
||||
| `--config.file.insecure-skip-verify` | Skip TLS when loading config file from URL | false |
|
||||
|
||||
## Installation
|
||||
|
||||
The latest release can be downloaded from the [releases page](https://github.com/prometheus-community/windows_exporter/releases).
|
||||
|
||||
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. The following parameters are available:
|
||||
If the installer is run without any parameters, the exporter will run with default settings for enabled collectors, ports, etc.
|
||||
|
||||
| Name | Description |
|
||||
|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `ENABLED_COLLECTORS` | As the `--collectors.enabled` flag, provide a comma-separated list of enabled collectors |
|
||||
| `LISTEN_ADDR` | The IP address to bind to. Defaults to an empty string. (any local address) |
|
||||
| `LISTEN_PORT` | The port to bind to. Defaults to `9182`. |
|
||||
| `METRICS_PATH` | The path at which to serve metrics. Defaults to `/metrics` |
|
||||
| `TEXTFILE_DIRS` | Use the `--collector.textfile.directories` flag to specify one or more directories, separated by commas, where the collector should read text files containing metrics |
|
||||
| `REMOTE_ADDR` | Allows setting comma separated remote IP addresses for the Windows Firewall exception (allow list). Defaults to an empty string (any remote address). |
|
||||
| `EXTRA_FLAGS` | Allows passing full CLI flags. Defaults to an empty string. |
|
||||
| `ADD_FIREWALL_EXCEPTION` | Setup an firewall exception for windows_exporter. Defaults to `yes`. |
|
||||
| `ENABLE_V1_PERFORMANCE_COUNTERS` | Enables V1 performance counter on modern systems. Defaults to `yes`. |
|
||||
The installer provides a configuration file to customize the exporter.
|
||||
|
||||
Parameters are sent to the installer via `msiexec`. Example invocations:
|
||||
The configuration file
|
||||
* is located in the same directory as the exporter executable.
|
||||
* has the YAML format and is provided with the `--config.file` parameter.
|
||||
* can be used to enable or disable collectors, set collector-specific parameters, and set global parameters.
|
||||
|
||||
The following parameters are available:
|
||||
|
||||
| Name | Description |
|
||||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `ENABLED_COLLECTORS` | As the `--collectors.enabled` flag, provide a comma-separated list of enabled collectors |
|
||||
| `CONFIG_FILE` | Use the `--config.file` flag to specify a config file. If empty, no config file will be set. The special value `config.yaml` set the path to the config.yaml at install dir | |
|
||||
| `LISTEN_ADDR` | The IP address to bind to. Defaults to an empty string. (any local address) |
|
||||
| `LISTEN_PORT` | The port to bind to. Defaults to `9182`. |
|
||||
| `METRICS_PATH` | The path at which to serve metrics. Defaults to `/metrics` |
|
||||
| `TEXTFILE_DIRS` | Use the `--collector.textfile.directories` flag to specify one or more directories, separated by commas, where the collector should read text files containing metrics |
|
||||
| `REMOTE_ADDR` | Allows setting comma separated remote IP addresses for the Windows Firewall exception (allow list). Defaults to an empty string (any remote address). |
|
||||
| `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` |
|
||||
|
||||
Parameters are sent to the installer via `msiexec`.
|
||||
On PowerShell, the `--%` should be passed before defining properties.
|
||||
|
||||
Example invocations:
|
||||
|
||||
```powershell
|
||||
msiexec /i <path-to-msi-file> ENABLED_COLLECTORS=os,iis LISTEN_PORT=5000
|
||||
msiexec /i <path-to-msi-file> --% ENABLED_COLLECTORS=os,iis LISTEN_PORT=5000
|
||||
```
|
||||
|
||||
Example service collector with a custom query.
|
||||
```powershell
|
||||
msiexec /i <path-to-msi-file> ENABLED_COLLECTORS=os,service --% EXTRA_FLAGS="--collector.service.services-where ""Name LIKE 'sql%'"""
|
||||
msiexec /i <path-to-msi-file> --% ENABLED_COLLECTORS=os,service EXTRA_FLAGS="--collectors.exchange.enabled=""ADAccessProcesses"""
|
||||
```
|
||||
|
||||
Define a config file.
|
||||
```powershell
|
||||
msiexec /i <path-to-msi-file> --% CONFIG_FILE="D:\config.yaml"
|
||||
```
|
||||
|
||||
On some older versions of Windows,
|
||||
you may need to surround parameter values with double quotes to get the installation command parsing properly:
|
||||
```powershell
|
||||
msiexec /i C:\Users\Administrator\Downloads\windows_exporter.msi ENABLED_COLLECTORS="ad,iis,logon,memory,process,tcp,textfile,thermalzone" TEXTFILE_DIRS="C:\custom_metrics\"
|
||||
msiexec /i C:\Users\Administrator\Downloads\windows_exporter.msi --% ENABLED_COLLECTORS="ad,iis,logon,memory,process,tcp,textfile,thermalzone" TEXTFILE_DIRS="C:\custom_metrics\"
|
||||
```
|
||||
|
||||
To install the exporter with creating a firewall exception, use the following command:
|
||||
|
||||
```powershell
|
||||
msiexec /i <path-to-msi-file> ADD_FIREWALL_EXCEPTION=yes
|
||||
msiexec /i <path-to-msi-file> --% ADDLOCAL=FirewallException
|
||||
```
|
||||
|
||||
To repair an installation, e.g force re-creating Windows service:
|
||||
|
||||
```powershell
|
||||
msiexec /fa <path-to-msi-file>
|
||||
```
|
||||
|
||||
|
||||
Powershell versions 7.3 and above require [PSNativeCommandArgumentPassing](https://learn.microsoft.com/en-us/powershell/scripting/learn/experimental-features?view=powershell-7.3) to be set to `Legacy` when using `--% EXTRA_FLAGS`:
|
||||
PowerShell versions 7.3 and above require [PSNativeCommandArgumentPassing](https://learn.microsoft.com/en-us/powershell/scripting/learn/experimental-features?view=powershell-7.3) to be set to `Legacy` when using `--% EXTRA_FLAGS`:
|
||||
|
||||
```powershell
|
||||
$PSNativeCommandArgumentPassing = 'Legacy'
|
||||
msiexec /i <path-to-msi-file> ENABLED_COLLECTORS=os,service --% EXTRA_FLAGS="--collector.service.services-where ""Name LIKE 'sql%'"""
|
||||
msiexec /i <path-to-msi-file> ENABLED_COLLECTORS=os,service --% EXTRA_FLAGS="--collectors.exchange.enabled=""ADAccessProcesses"""
|
||||
```
|
||||
|
||||
## Docker Implementation
|
||||
|
||||
The windows_exporter can be run as a Docker container. The Docker image is available on
|
||||
The windows_exporter can be run as a Docker container. The Docker image is available on
|
||||
|
||||
* [Docker Hub](https://hub.docker.com/r/prometheuscommunity/windows-exporter): `docker.io/prometheuscommunity/windows-exporter`
|
||||
* [GitHub Container Registry](https://github.com/prometheus-community/windows_exporter/pkgs/container/windows-exporter): `ghcr.io/prometheus-community/windows-exporter`
|
||||
@@ -188,7 +194,7 @@ The prometheus metrics will be exposed on [localhost:9182](http://localhost:9182
|
||||
|
||||
### Enable only service collector and specify a custom query
|
||||
|
||||
.\windows_exporter.exe --collectors.enabled "service" --collector.service.services-where "Name='windows_exporter'"
|
||||
.\windows_exporter.exe --collectors.enabled "service" --collector.service.include="windows_exporter"
|
||||
|
||||
### Enable only process collector and specify a custom query
|
||||
|
||||
@@ -214,10 +220,10 @@ If you need to skip TLS verification, you can use the `--config.file.insecure-sk
|
||||
|
||||
```yaml
|
||||
collectors:
|
||||
enabled: cpu,cs,net,service
|
||||
enabled: cpu,net,service
|
||||
collector:
|
||||
service:
|
||||
services-where: "Name='windows_exporter'"
|
||||
include: windows_exporter
|
||||
log:
|
||||
level: warn
|
||||
```
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
collectors:
|
||||
enabled: cpu,cpu_info,cs,exchange,iis,logical_disk,logon,memory,net,os,process,remote_fx,service,system,tcp,time,terminal_services,textfile
|
||||
enabled: cpu,cpu_info,exchange,iis,logical_disk,logon,memory,net,os,process,remote_fx,service,system,tcp,time,terminal_services,textfile
|
||||
collector:
|
||||
service:
|
||||
services-where: "Name='windows_exporter'"
|
||||
include: "windows_exporter"
|
||||
log:
|
||||
level: warn
|
||||
level: warn
|
||||
|
||||
@@ -25,14 +25,7 @@ This directory contains documentation of the collectors in the windows_exporter,
|
||||
- [`msmq`](collector.msmq.md)
|
||||
- [`mssql`](collector.mssql.md)
|
||||
- [`net`](collector.net.md)
|
||||
- [`netframework_clrexceptions`](collector.netframework_clrexceptions.md)
|
||||
- [`netframework_clrinterop`](collector.netframework_clrinterop.md)
|
||||
- [`netframework_clrjit`](collector.netframework_clrjit.md)
|
||||
- [`netframework_clrloading`](collector.netframework_clrloading.md)
|
||||
- [`netframework_clrlocksandthreads`](collector.netframework_clrlocksandthreads.md)
|
||||
- [`netframework_clrmemory`](collector.netframework_clrmemory.md)
|
||||
- [`netframework_clrremoting`](collector.netframework_clrremoting.md)
|
||||
- [`netframework_clrsecurity`](collector.netframework_clrsecurity.md)
|
||||
- [`netframework`](collector.netframework.md)
|
||||
- [`nps`](collector.nps.md)
|
||||
- [`os`](collector.os.md)
|
||||
- [`physical_disk`](collector.physical_disk.md)
|
||||
|
||||
@@ -16,26 +16,22 @@ None
|
||||
## Metrics
|
||||
These metrics are available on all versions of Windows:
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_cpu_cstate_seconds_total` | Time spent in low-power idle states | counter | `core`, `state`
|
||||
`windows_cpu_time_total` | Time that processor spent in different modes (dpc, idle, interrupt, privileged, user) | counter | `core`, `mode`
|
||||
`windows_cpu_interrupts_total` | Total number of received and serviced hardware interrupts | counter | `core`
|
||||
`windows_cpu_dpcs_total` | Total number of received and serviced deferred procedure calls (DPCs) | counter | `core`
|
||||
|
||||
These metrics are only exposed on Windows Server 2008R2 and later:
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_cpu_clock_interrupts_total` | Total number of received and serviced clock tick interrupts | counter | `core`
|
||||
`windows_cpu_idle_break_events_total` | Total number of time processor was woken from idle | counter | `core`
|
||||
`windows_cpu_parking_status` | Parking Status represents whether a processor is parked or not | gauge | `core`
|
||||
`windows_cpu_core_frequency_mhz` | Core frequency in megahertz | gauge | `core`
|
||||
`windows_cpu_processor_performance_total` | Processor Performance is the number of CPU cycles executing instructions by each core; it is believed to be similar to the value that the APERF MSR would show, were it exposed | counter | `core`
|
||||
`windows_cpu_processor_mperf_total` | Processor MPerf Total is proportioanl to the number of TSC ticks each core has accumulated while executing instructions. Due to the manner in which it is presented, it should be scaled by 1e2 to properly line up with Processor Performance Total. As above, it is believed to be closely related to the MPERF MSR. | counter | `core`
|
||||
`windows_cpu_processor_rtc_total` | RTC total is assumed to represent the 64Hz tick rate in Windows. It is not by itself useful, but can be used with `windows_cpu_processor_utility_total` to more accurately measure CPU utilisation than with `windows_cpu_time_total` | counter | `core`
|
||||
`windows_cpu_processor_utility_total` | Processor Utility Total is a newer, more accurate measure of CPU utilization, in particular handling modern CPUs with variant CPU frequencies. The rate of this counter divided by the rate of `windows_cpu_processor_rtc_total` should provide an accurate view of CPU utilisation on modern systems, as observed in Task Manager. | counter | `core`
|
||||
`windows_cpu_processor_privileged_utility_total` | Processor Privileged Utility Total, when used in a similar fashion to `windows_cpu_processor_utility_total` will show the portion of CPU utilization which is happening in privileged mode. | counter | `core`
|
||||
| Name | Description | Type | Labels |
|
||||
|--------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-----------------|
|
||||
| `windows_cpu_logical_processor` | Number of installed logical processors | counter | `core`, `state` |
|
||||
| `windows_cpu_cstate_seconds_total` | Time spent in low-power idle states | counter | `core`, `state` |
|
||||
| `windows_cpu_time_total` | Time that processor spent in different modes (dpc, idle, interrupt, privileged, user) | counter | `core`, `mode` |
|
||||
| `windows_cpu_interrupts_total` | Total number of received and serviced hardware interrupts | counter | `core` |
|
||||
| `windows_cpu_dpcs_total` | Total number of received and serviced deferred procedure calls (DPCs) | counter | `core` |
|
||||
| `windows_cpu_clock_interrupts_total` | Total number of received and serviced clock tick interrupts | counter | `core` |
|
||||
| `windows_cpu_idle_break_events_total` | Total number of time processor was woken from idle | counter | `core` |
|
||||
| `windows_cpu_parking_status` | Parking Status represents whether a processor is parked or not | gauge | `core` |
|
||||
| `windows_cpu_core_frequency_mhz` | Core frequency in megahertz | gauge | `core` |
|
||||
| `windows_cpu_processor_performance_total` | Processor Performance is the number of CPU cycles executing instructions by each core; it is believed to be similar to the value that the APERF MSR would show, were it exposed | counter | `core` |
|
||||
| `windows_cpu_processor_mperf_total` | Processor MPerf Total is proportioanl to the number of TSC ticks each core has accumulated while executing instructions. Due to the manner in which it is presented, it should be scaled by 1e2 to properly line up with Processor Performance Total. As above, it is believed to be closely related to the MPERF MSR. | counter | `core` |
|
||||
| `windows_cpu_processor_rtc_total` | RTC total is assumed to represent the 64Hz tick rate in Windows. It is not by itself useful, but can be used with `windows_cpu_processor_utility_total` to more accurately measure CPU utilisation than with `windows_cpu_time_total` | counter | `core` |
|
||||
| `windows_cpu_processor_utility_total` | Processor Utility Total is a newer, more accurate measure of CPU utilization, in particular handling modern CPUs with variant CPU frequencies. The rate of this counter divided by the rate of `windows_cpu_processor_rtc_total` should provide an accurate view of CPU utilisation on modern systems, as observed in Task Manager. | counter | `core` |
|
||||
| `windows_cpu_processor_privileged_utility_total` | Processor Privileged Utility Total, when used in a similar fashion to `windows_cpu_processor_utility_total` will show the portion of CPU utilization which is happening in privileged mode. | counter | `core` |
|
||||
|
||||
### Example metric
|
||||
Show frequency of host CPU cores
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# cs collector
|
||||
|
||||
> [!CAUTION]
|
||||
> This collector is deprecated and will be removed in a future release.
|
||||
> See https://github.com/prometheus-community/windows_exporter/pull/1596 for more information.
|
||||
|
||||
The cs collector exposes metrics detailing the hardware of the computer system
|
||||
|
||||
|||
|
||||
|
||||
36
docs/collector.filetime.md
Normal file
36
docs/collector.filetime.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# filetime collector
|
||||
|
||||
The filetime collector exposes modified timestamps of files in the filesystem.
|
||||
|
||||
The collector
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `filetime`
|
||||
Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
|
||||
### `--collectors.filetime.file-patterns`
|
||||
Comma-separated list of file patterns. Each pattern is a glob pattern that can contain `*`, `?`, and `**` (recursive).
|
||||
See https://github.com/bmatcuk/doublestar#patterns for an extended description of the pattern syntax.
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_filetime_mtime_timestamp_seconds` | File modification time | gauge | `file`
|
||||
|
||||
### Example metric
|
||||
|
||||
```
|
||||
# HELP windows_filetime_mtime_timestamp_seconds File modification time
|
||||
# TYPE windows_filetime_mtime_timestamp_seconds gauge
|
||||
windows_filetime_mtime_timestamp_seconds{file="C:\\Users\\admin\\Desktop\\Dashboard.lnk"} 1.726434517e+09
|
||||
```
|
||||
|
||||
## 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!_
|
||||
@@ -5,9 +5,9 @@ The memory collector exposes metrics about system memory usage
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `memory`
|
||||
Data source | Perflib
|
||||
Classes | `Win32_PerfRawData_PerfOS_Memory`
|
||||
Enabled by default? | No
|
||||
Data source | Performance Counters
|
||||
Classes | -
|
||||
Enabled by default? | Yes
|
||||
|
||||
## Flags
|
||||
|
||||
@@ -15,46 +15,73 @@ None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_memory_available_bytes` | The amount of physical memory immediately available for allocation to a process or for system use. It is equal to the sum of memory assigned to the standby (cached), free and zero page lists | gauge | None
|
||||
`windows_memory_cache_bytes` | Number of bytes currently being used by the file system cache | gauge | None
|
||||
`windows_memory_cache_bytes_peak` | Maximum number of CacheBytes after the system was last restarted | gauge | None
|
||||
`windows_memory_cache_faults_total` | Number of faults which occur when a page sought in the file system cache is not found there and must be retrieved from elsewhere in memory (soft fault) or from disk (hard fault) | counter | None
|
||||
`windows_memory_commit_limit` | Amount of virtual memory, in bytes, that can be committed without having to extend the paging file(s) | gauge | None
|
||||
`windows_memory_committed_bytes` | Amount of committed virtual memory, in bytes | gauge | None
|
||||
`windows_memory_demand_zero_faults_total` | The number of zeroed pages required to satisfy faults. Zeroed pages, pages emptied of previously stored data and filled with zeros, are a security feature of Windows that prevent processes from seeing data stored by earlier processes that used the memory space | counter | None
|
||||
`windows_memory_free_and_zero_page_list_bytes` | The amount of physical memory, in bytes, that is assigned to the free and zero page lists. This memory does not contain cached data. It is immediately available for allocation to a process or for system use | gauge | None
|
||||
`windows_memory_free_system_page_table_entries` | Number of page table entries not being used by the system | gauge | None
|
||||
`windows_memory_modified_page_list_bytes` | The amount of physical memory, in bytes, that is assigned to the modified page list. This memory contains cached data and code that is not actively in use by processes, the system and the system cache. This memory needs to be written out before it will be available for allocation to a process or for system use | gauge | None
|
||||
`windows_memory_page_faults_total` | Overall rate at which faulted pages are handled by the processor | counter | None
|
||||
`windows_memory_swap_page_reads_total` | Number of disk page reads (a single read operation reading several pages is still only counted once) | counter | None
|
||||
`windows_memory_swap_pages_read_total` | Number of pages read across all page reads (ie counting all pages read even if they are read in a single operation) | counter | None
|
||||
`windows_memory_swap_pages_written_total` | Number of pages written across all page writes (ie counting all pages written even if they are written in a single operation) | counter | None
|
||||
`windows_memory_swap_page_operations_total` | Total number of swap page read and writes (PagesPersec) | counter | None
|
||||
`windows_memory_swap_page_writes_total` | Number of disk page writes (a single write operation writing several pages is still only counted once) | counter | None
|
||||
`windows_memory_pool_nonpaged_allocs_total` | The number of calls to allocate space in the nonpaged pool. The nonpaged pool is an area of system memory area for objects that cannot be written to disk, and must remain in physical memory as long as they are allocated | counter | None
|
||||
`windows_memory_pool_nonpaged_bytes` | Number of bytes in the non-paged pool, an area of the system virtual memory that is used for objects that cannot be written to disk, but must remain in physical memory as long as they are allocated | gauge | None
|
||||
`windows_memory_pool_paged_allocs_total` | Number of calls to allocate space in the paged pool, regardless of the amount of space allocated in each call | counter | None
|
||||
`windows_memory_pool_paged_bytes` | Number of bytes in the paged pool | gauge | None
|
||||
`windows_memory_pool_paged_resident_bytes` | The size, in bytes, of the portion of the paged pool that is currently resident and active in physical memory. The paged pool is an area of the system virtual memory that is used for objects that can be written to disk when they are not being used | gauge | None
|
||||
`windows_memory_standby_cache_core_bytes` | The amount of physical memory, in bytes, that is assigned to the core standby cache page lists. This memory contains cached data and code that is not actively in use by processes, the system and the system cache. It is immediately available for allocation to a process or for system use. If the system runs out of available free and zero memory, memory on lower priority standby cache page lists will be repurposed before memory on higher priority standby cache page lists | gauge | None
|
||||
`windows_memory_standby_cache_normal_priority_bytes` | The amount of physical memory, in bytes, that is assigned to the normal priority standby cache page lists. This memory contains cached data and code that is not actively in use by processes, the system and the system cache. It is immediately available for allocation to a process or for system use. If the system runs out of available free and zero memory, memory on lower priority standby cache page lists will be repurposed before memory on higher priority standby cache page lists | gauge | None
|
||||
`windows_memory_standby_cache_reserve_bytes` | The amount of physical memory, in bytes, that is assigned to the reserve standby cache page lists. This memory contains cached data and code that is not actively in use by processes, the system and the system cache. It is immediately available for allocation to a process or for system use. If the system runs out of available free and zero memory, memory on lower priority standby cache page lists will be repurposed before memory on higher priority standby cache page lists | gauge | None
|
||||
`windows_memory_system_cache_resident_bytes` | The size, in bytes, of the portion of the system file cache which is currently resident and active in physical memory | gauge | None
|
||||
`windows_memory_system_code_resident_bytes` | The size, in bytes, of the pageable operating system code that is currently resident and active in physical memory. This value is a component of Memory\\System Code Total Bytes. Memory\\System Code Resident Bytes (and Memory\\System Code Total Bytes) does not include code that must remain in physical memory and cannot be written to disk | gauge | None
|
||||
`windows_memory_system_code_total_bytes` | The size, in bytes, of the pageable operating system code currently mapped into the system virtual address space. This value is calculated by summing the bytes in Ntoskrnl.exe, Hal.dll, the boot drivers, and file systems loaded by Ntldr/osloader. This counter does not include code that must remain in physical memory and cannot be written to disk | gauge | None
|
||||
`windows_memory_system_driver_resident_bytes` | The size, in bytes, of the pageable physical memory being used by device drivers. It is the working set (physical memory area) of the drivers. This value is a component of Memory\\System Driver Total Bytes, which also includes driver memory that has been written to disk. Neither Memory\\System Driver Resident Bytes nor Memory\\System Driver Total Bytes includes memory that cannot be written to disk | gauge | None
|
||||
`windows_memory_system_driver_total_bytes` | The size, in bytes, of the pageable virtual memory currently being used by device drivers. Pageable memory can be written to disk when it is not being used. It includes both physical memory (Memory\\System Driver Resident Bytes) and code and data paged to disk. It is a component of Memory\\System Code Total Bytes | gauge | None
|
||||
`windows_memory_transition_faults_total` | Number of faults rate at which page faults are resolved by recovering pages that were being used by another process sharing the page, or were on the modified page list or the standby list, or were being written to disk at the time of the page fault. The pages were recovered without additional disk activity. Transition faults are counted in numbers of faults; because only one page is faulted in each operation, it is also equal to the number of pages faulted | counter | None
|
||||
`windows_memory_transition_pages_repurposed_total` | Transition Pages RePurposed is the rate at which the number of transition cache pages were reused for a different purpose. These pages would have otherwise remained in the page cache to provide a (fast) soft fault (instead of retrieving it from backing store) in the event the page was accessed in the future | counter | None
|
||||
`windows_memory_write_copies_total` | The number of page faults caused by attempting to write that were satisfied by copying the page from elsewhere in physical memory | counter | None
|
||||
| Name | Description | Type | Labels |
|
||||
|------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|--------|
|
||||
| `windows_memory_available_bytes` | The amount of physical memory immediately available for allocation to a process or for system use. It is equal to the sum of memory assigned to the standby (cached), free and zero page lists | gauge | None |
|
||||
| `windows_memory_cache_bytes` | Number of bytes currently being used by the file system cache | gauge | None |
|
||||
| `windows_memory_cache_bytes_peak` | Maximum number of CacheBytes after the system was last restarted | gauge | None |
|
||||
| `windows_memory_cache_faults_total` | Number of faults which occur when a page sought in the file system cache is not found there and must be retrieved from elsewhere in memory (soft fault) or from disk (hard fault) | counter | None |
|
||||
| `windows_memory_commit_limit` | Amount of virtual memory, in bytes, that can be committed without having to extend the paging file(s) | gauge | None |
|
||||
| `windows_memory_committed_bytes` | Amount of committed virtual memory, in bytes | gauge | None |
|
||||
| `windows_memory_demand_zero_faults_total` | The number of zeroed pages required to satisfy faults. Zeroed pages, pages emptied of previously stored data and filled with zeros, are a security feature of Windows that prevent processes from seeing data stored by earlier processes that used the memory space | counter | None |
|
||||
| `windows_memory_free_and_zero_page_list_bytes` | The amount of physical memory, in bytes, that is assigned to the free and zero page lists. This memory does not contain cached data. It is immediately available for allocation to a process or for system use | gauge | None |
|
||||
| `windows_memory_free_system_page_table_entries` | Number of page table entries not being used by the system | gauge | None |
|
||||
| `windows_memory_modified_page_list_bytes` | The amount of physical memory, in bytes, that is assigned to the modified page list. This memory contains cached data and code that is not actively in use by processes, the system and the system cache. This memory needs to be written out before it will be available for allocation to a process or for system use | gauge | None |
|
||||
| `windows_memory_page_faults_total` | Overall rate at which faulted pages are handled by the processor | counter | None |
|
||||
| `windows_memory_swap_page_reads_total` | Number of disk page reads (a single read operation reading several pages is still only counted once) | counter | None |
|
||||
| `windows_memory_swap_pages_read_total` | Number of pages read across all page reads (ie counting all pages read even if they are read in a single operation) | counter | None |
|
||||
| `windows_memory_swap_pages_written_total` | Number of pages written across all page writes (ie counting all pages written even if they are written in a single operation) | counter | None |
|
||||
| `windows_memory_swap_page_operations_total` | Total number of swap page read and writes (PagesPersec) | counter | None |
|
||||
| `windows_memory_swap_page_writes_total` | Number of disk page writes (a single write operation writing several pages is still only counted once) | counter | None |
|
||||
| `windows_memory_physical_free_bytes` | Bytes of physical memory currently unused and available | gauge | None |
|
||||
| `windows_memory_physical_total_bytes` | Total bytes of physical memory available to the operating system. This value does not necessarily indicate the true amount of physical memory, but what is reported to the operating system as available to it | gauge | None |
|
||||
| `windows_memory_pool_nonpaged_allocs_total` | The number of calls to allocate space in the nonpaged pool. The nonpaged pool is an area of system memory area for objects that cannot be written to disk, and must remain in physical memory as long as they are allocated | counter | None |
|
||||
| `windows_memory_pool_nonpaged_bytes` | Number of bytes in the non-paged pool, an area of the system virtual memory that is used for objects that cannot be written to disk, but must remain in physical memory as long as they are allocated | gauge | None |
|
||||
| `windows_memory_pool_paged_allocs_total` | Number of calls to allocate space in the paged pool, regardless of the amount of space allocated in each call | counter | None |
|
||||
| `windows_memory_pool_paged_bytes` | Number of bytes in the paged pool | gauge | None |
|
||||
| `windows_memory_pool_paged_resident_bytes` | The size, in bytes, of the portion of the paged pool that is currently resident and active in physical memory. The paged pool is an area of the system virtual memory that is used for objects that can be written to disk when they are not being used | gauge | None |
|
||||
| `windows_memory_process_memory_limit_bytes` | Maximum number of bytes of memory that can be allocated to a process | gauge | None |
|
||||
| `windows_memory_standby_cache_core_bytes` | The amount of physical memory, in bytes, that is assigned to the core standby cache page lists. This memory contains cached data and code that is not actively in use by processes, the system and the system cache. It is immediately available for allocation to a process or for system use. If the system runs out of available free and zero memory, memory on lower priority standby cache page lists will be repurposed before memory on higher priority standby cache page lists | gauge | None |
|
||||
| `windows_memory_standby_cache_normal_priority_bytes` | The amount of physical memory, in bytes, that is assigned to the normal priority standby cache page lists. This memory contains cached data and code that is not actively in use by processes, the system and the system cache. It is immediately available for allocation to a process or for system use. If the system runs out of available free and zero memory, memory on lower priority standby cache page lists will be repurposed before memory on higher priority standby cache page lists | gauge | None |
|
||||
| `windows_memory_standby_cache_reserve_bytes` | The amount of physical memory, in bytes, that is assigned to the reserve standby cache page lists. This memory contains cached data and code that is not actively in use by processes, the system and the system cache. It is immediately available for allocation to a process or for system use. If the system runs out of available free and zero memory, memory on lower priority standby cache page lists will be repurposed before memory on higher priority standby cache page lists | gauge | None |
|
||||
| `windows_memory_system_cache_resident_bytes` | The size, in bytes, of the portion of the system file cache which is currently resident and active in physical memory | gauge | None |
|
||||
| `windows_memory_system_code_resident_bytes` | The size, in bytes, of the pageable operating system code that is currently resident and active in physical memory. This value is a component of Memory\\System Code Total Bytes. Memory\\System Code Resident Bytes (and Memory\\System Code Total Bytes) does not include code that must remain in physical memory and cannot be written to disk | gauge | None |
|
||||
| `windows_memory_system_code_total_bytes` | The size, in bytes, of the pageable operating system code currently mapped into the system virtual address space. This value is calculated by summing the bytes in Ntoskrnl.exe, Hal.dll, the boot drivers, and file systems loaded by Ntldr/osloader. This counter does not include code that must remain in physical memory and cannot be written to disk | gauge | None |
|
||||
| `windows_memory_system_driver_resident_bytes` | The size, in bytes, of the pageable physical memory being used by device drivers. It is the working set (physical memory area) of the drivers. This value is a component of Memory\\System Driver Total Bytes, which also includes driver memory that has been written to disk. Neither Memory\\System Driver Resident Bytes nor Memory\\System Driver Total Bytes includes memory that cannot be written to disk | gauge | None |
|
||||
| `windows_memory_system_driver_total_bytes` | The size, in bytes, of the pageable virtual memory currently being used by device drivers. Pageable memory can be written to disk when it is not being used. It includes both physical memory (Memory\\System Driver Resident Bytes) and code and data paged to disk. It is a component of Memory\\System Code Total Bytes | gauge | None |
|
||||
| `windows_memory_transition_faults_total` | Number of faults rate at which page faults are resolved by recovering pages that were being used by another process sharing the page, or were on the modified page list or the standby list, or were being written to disk at the time of the page fault. The pages were recovered without additional disk activity. Transition faults are counted in numbers of faults; because only one page is faulted in each operation, it is also equal to the number of pages faulted | counter | None |
|
||||
| `windows_memory_transition_pages_repurposed_total` | Transition Pages RePurposed is the rate at which the number of transition cache pages were reused for a different purpose. These pages would have otherwise remained in the page cache to provide a (fast) soft fault (instead of retrieving it from backing store) in the event the page was accessed in the future | counter | None |
|
||||
| `windows_memory_write_copies_total` | The number of page faults caused by attempting to write that were satisfied by copying the page from elsewhere in physical memory | counter | None |
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
## Useful queries
|
||||
_This collector does not yet have any useful queries added, we would appreciate your help adding them!_
|
||||
|
||||
Show memory usage for instance (%)
|
||||
```
|
||||
100 - 100 * windows_memory_physical_free_bytes{instance="localhost"} / windows_memory_physical_total_bytes
|
||||
```
|
||||
## Alerting examples
|
||||
_This collector does not yet have alerting examples, we would appreciate your help adding them!_
|
||||
|
||||
**prometheus.rules**
|
||||
```yaml
|
||||
# Alert on hosts that have exhausted all available physical memory
|
||||
- alert: MemoryExhausted
|
||||
expr: windows_os_physical_memory_free_bytes == 0
|
||||
for: 10m
|
||||
labels:
|
||||
severity: high
|
||||
annotations:
|
||||
summary: "Host {{ $labels.instance }} is out of memory"
|
||||
description: "{{ $labels.instance }} has exhausted all available physical memory"
|
||||
|
||||
# Alert on hosts with greater than 90% memory usage
|
||||
- alert: MemoryLow
|
||||
expr: 100 - 100 * windows_memory_physical_free_bytes{instance="localhost"} / windows_memory_physical_total_bytes > 90
|
||||
for: 10m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: "Memory usage for host {{ $labels.instance }} is greater than 90%"
|
||||
```
|
||||
|
||||
113
docs/collector.netframework.md
Normal file
113
docs/collector.netframework.md
Normal file
@@ -0,0 +1,113 @@
|
||||
# netframework collector
|
||||
|
||||
The netframework collector exposes metrics about dotnet framework.
|
||||
|
||||
| | |
|
||||
|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **Metric name prefix** | `netframework_clrexceptions` |
|
||||
| **Classes** | `Win32_PerfRawData_NETFramework_NETCLRExceptions`, `Win32_PerfRawData_NETFramework_NETCLRInterop`, `Win32_PerfRawData_NETFramework_NETCLRJit`, `Win32_PerfRawData_NETFramework_NETCLRLoading`, `Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads`, `Win32_PerfRawData_NETFramework_NETCLRMemory`, `Win32_PerfRawData_NETFramework_NETCLRRemoting`, `Win32_PerfRawData_NETFramework_NETCLRSecurity` |
|
||||
| **Enabled by default?** | No |
|
||||
|
||||
## Flags
|
||||
|
||||
None
|
||||
|
||||
## Metrics
|
||||
|
||||
### CLR Exceptions
|
||||
|
||||
| Name | Description | Type | Labels |
|
||||
|-----------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-----------|
|
||||
| `windows_netframework_clrexceptions_exceptions_thrown_total` | Displays the total number of exceptions thrown since the application started. This includes both .NET exceptions and unmanaged exceptions that are converted into .NET exceptions. | counter | `process` |
|
||||
| `windows_netframework_clrexceptions_exceptions_filters_total` | Displays the total number of .NET exception filters executed. An exception filter evaluates regardless of whether an exception is handled. | counter | `process` |
|
||||
| `windows_netframework_clrexceptions_exceptions_finallys_total` | Displays the total number of finally blocks executed. Only the finally blocks executed for an exception are counted; finally blocks on normal code paths are not counted by this counter. | counter | `process` |
|
||||
| `windows_netframework_clrexceptions_throw_to_catch_depth_total` | Displays the total number of stack frames traversed, from the frame that threw the exception to the frame that handled the exception. | counter | `process` |
|
||||
|
||||
### CLR Interop
|
||||
|
||||
| Name | Description | Type | Labels |
|
||||
|---------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-----------|
|
||||
| `windows_netframework_clrinterop_com_callable_wrappers_total` | Displays the current number of COM callable wrappers (CCWs). A CCW is a proxy for a managed object being referenced from an unmanaged COM client. | counter | `process` |
|
||||
| `windows_netframework_clrinterop_interop_marshalling_total` | Displays the total number of times arguments and return values have been marshaled from managed to unmanaged code, and vice versa, since the application started. | counter | `process` |
|
||||
| `windows_netframework_clrinterop_interop_stubs_created_total` | Displays the current number of stubs created by the common language runtime. Stubs are responsible for marshaling arguments and return values from managed to unmanaged code, and vice versa, during a COM interop call or a platform invoke call. | counter | `process` |
|
||||
|
||||
### CLR JIT
|
||||
|
||||
| Name | Description | Type | Labels |
|
||||
|-----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-----------|
|
||||
| `windows_netframework_clrjit_jit_methods_total` | Displays the total number of methods JIT-compiled since the application started. This counter does not include pre-JIT-compiled methods. | counter | `process` |
|
||||
| `windows_netframework_clrjit_jit_time_percent` | Displays the percentage of time spent in JIT compilation. This counter is updated at the end of every JIT compilation phase. A JIT compilation phase occurs when a method and its dependencies are compiled. | gauge | `process` |
|
||||
| `windows_netframework_clrjit_jit_standard_failures_total` | Displays the peak number of methods the JIT compiler has failed to compile since the application started. This failure can occur if the MSIL cannot be verified or if there is an internal error in the JIT compiler. | counter | `process` |
|
||||
| `windows_netframework_clrjit_jit_il_bytes_total` | Displays the total number of Microsoft intermediate language (MSIL) bytes compiled by the just-in-time (JIT) compiler since the application started | counter | `process` |
|
||||
|
||||
### CLR Loading
|
||||
|
||||
| Name | Description | Type | Labels |
|
||||
|-------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-----------|
|
||||
| `windows_netframework_clrloading_loader_heap_size_bytes` | Displays the current size, in bytes, of the memory committed by the class loader across all application domains. Committed memory is the physical space reserved in the disk paging file. | gauge | `process` |
|
||||
| `windows_netframework_clrloading_appdomains_loaded_current` | Displays the current number of application domains loaded in this application. | gauge | `process` |
|
||||
| `windows_netframework_clrloading_assemblies_loaded_current` | Displays the current number of assemblies loaded across all application domains in the currently running application. If the assembly is loaded as domain-neutral from multiple application domains, this counter is incremented only once. | gauge | `process` |
|
||||
| `windows_netframework_clrloading_classes_loaded_current` | Displays the current number of classes loaded in all assemblies. | gauge | `process` |
|
||||
| `windows_netframework_clrloading_appdomains_loaded_total` | Displays the peak number of application domains loaded since the application started. | counter | `process` |
|
||||
| `windows_netframework_clrloading_appdomains_unloaded_total` | Displays the total number of application domains unloaded since the application started. If an application domain is loaded and unloaded multiple times, this counter increments each time the application domain is unloaded. | counter | `process` |
|
||||
| `windows_netframework_clrloading_assemblies_loaded_total` | Displays the total number of assemblies loaded since the application started. If the assembly is loaded as domain-neutral from multiple application domains, this counter is incremented only once. | counter | `process` |
|
||||
| `windows_netframework_clrloading_classes_loaded_total` | Displays the cumulative number of classes loaded in all assemblies since the application started. | counter | `process` |
|
||||
| `windows_netframework_clrloading_class_load_failures_total` | Displays the peak number of classes that have failed to load since the application started. | counter | `process` |
|
||||
|
||||
### CLR Locks and Threads
|
||||
|
||||
| Name | Description | Type | Labels |
|
||||
|----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-----------|
|
||||
| `windows_netframework_clrlocksandthreads_current_queue_length` | Displays the total number of threads that are currently waiting to acquire a managed lock in the application. | gauge | `process` |
|
||||
| `windows_netframework_clrlocksandthreads_current_logical_threads` | Displays the number of current managed thread objects in the application. This counter maintains the count of both running and stopped threads. | gauge | `process` |
|
||||
| `windows_netframework_clrlocksandthreads_physical_threads_current` | Displays the number of native operating system threads created and owned by the common language runtime to act as underlying threads for managed thread objects. This counter's value does not include the threads used by the runtime in its internal operations; it is a subset of the threads in the operating system process. | gauge | `process` |
|
||||
| `windows_netframework_clrlocksandthreads_recognized_threads_current` | Displays the number of threads that are currently recognized by the runtime. These threads are associated with a corresponding managed thread object. The runtime does not create these threads, but they have run inside the runtime at least once. | gauge | `process` |
|
||||
| `windows_netframework_clrlocksandthreads_recognized_threads_total` | Displays the total number of threads that have been recognized by the runtime since the application started. These threads are associated with a corresponding managed thread object. The runtime does not create these threads, but they have run inside the runtime at least once. | counter | `process` |
|
||||
| `windows_netframework_clrlocksandthreads_queue_length_total` | Displays the total number of threads that waited to acquire a managed lock since the application started. | counter | `process` |
|
||||
| `windows_netframework_clrlocksandthreads_contentions_total` | Displays the total number of times that threads in the runtime have attempted to acquire a managed lock unsuccessfully. | counter | `process` |
|
||||
|
||||
### CLR Memory
|
||||
|
||||
| Name | Description | Type | Labels |
|
||||
|----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-----------|
|
||||
| `windows_netframework_clrmemory_allocated_bytes_total` | Displays the total number of bytes allocated on the garbage collection heap. | counter | `process` |
|
||||
| `windows_netframework_clrmemory_finalization_survivors` | Displays the number of garbage-collected objects that survive a collection because they are waiting to be finalized. | gauge | `process` |
|
||||
| `windows_netframework_clrmemory_heap_size_bytes` | Displays the maximum bytes that can be allocated; it does not indicate the current number of bytes allocated. | gauge | `process` |
|
||||
| `windows_netframework_clrmemory_promoted_bytes` | Displays the bytes that were promoted from the generation to the next one during the last GC. Memory is promoted when it survives a garbage collection. | gauge | `process` |
|
||||
| `windows_netframework_clrmemory_number_gc_handles` | Displays the current number of garbage collection handles in use. Garbage collection handles are handles to resources external to the common language runtime and the managed environment. | gauge | `process` |
|
||||
| `windows_netframework_clrmemory_collections_total` | Displays the number of times the generation objects are garbage collected since the application started. | counter | `process` |
|
||||
| `windows_netframework_clrmemory_induced_gc_total` | Displays the peak number of times garbage collection was performed because of an explicit call to GC.Collect. | counter | `process` |
|
||||
| `windows_netframework_clrmemory_number_pinned_objects` | Displays the number of pinned objects encountered in the last garbage collection. | gauge | `process` |
|
||||
| `windows_netframework_clrmemory_number_sink_blocksinuse` | Displays the current number of synchronization blocks in use. Synchronization blocks are per-object data structures allocated for storing synchronization information. They hold weak references to managed objects and must be scanned by the garbage collector. | gauge | `process` |
|
||||
| `windows_netframework_clrmemory_committed_bytes` | Displays the amount of virtual memory, in bytes, currently committed by the garbage collector. Committed memory is the physical memory for which space has been reserved in the disk paging file. | gauge | `process` |
|
||||
| `windows_netframework_clrmemory_reserved_bytes` | Displays the amount of virtual memory, in bytes, currently reserved by the garbage collector. Reserved memory is the virtual memory space reserved for the application when no disk or main memory pages have been used. | gauge | `process` |
|
||||
| `windows_netframework_clrmemory_gc_time_percent` | Displays the percentage of time that was spent performing a garbage collection in the last sample. | gauge | `process` |
|
||||
|
||||
### CLR Remoting
|
||||
|
||||
| Name | Description | Type | Labels |
|
||||
|-----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|---------|-----------|
|
||||
| `windows_netframework_clrremoting_channels_total` | Displays the total number of remoting channels registered across all application domains since application started. | counter | `process` |
|
||||
| `windows_netframework_clrremoting_context_bound_classes_loaded` | Displays the current number of context-bound classes that are loaded. | gauge | `process` |
|
||||
| `windows_netframework_clrremoting_context_bound_objects_total` | Displays the total number of context-bound objects allocated. | counter | `process` |
|
||||
| `windows_netframework_clrremoting_context_proxies_total` | Displays the total number of remoting proxy objects in this process since it started. | counter | `process` |
|
||||
| `windows_netframework_clrremoting_contexts` | Displays the current number of remoting contexts in the application. | gauge | `process` |
|
||||
| `windows_netframework_clrremoting_remote_calls_total` | Displays the total number of remote procedure calls invoked since the application started. | counter | `process` |
|
||||
|
||||
### CLR Security
|
||||
|
||||
| Name | Description | Type | Labels |
|
||||
|-----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|---------|-----------|
|
||||
| `windows_netframework_clrsecurity_link_time_checks_total` | Displays the total number of link-time code access security checks since the application started. | counter | `process` |
|
||||
| `windows_netframework_clrsecurity_rt_checks_time_percent` | Displays the percentage of time spent performing runtime code access security checks in the last sample. | gauge | `process` |
|
||||
| `windows_netframework_clrsecurity_stack_walk_depth` | Displays the depth of the stack during that last runtime code access security check. | gauge | `process` |
|
||||
| `windows_netframework_clrsecurity_runtime_checks_total` | Displays the total number of runtime code access security checks performed since the application started. | counter | `process` |
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
## 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!_
|
||||
@@ -1,31 +0,0 @@
|
||||
# netframework_clrexceptions collector
|
||||
|
||||
The netframework_clrexceptions collector exposes metrics about CLR exceptions in the dotnet framework.
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `netframework_clrexceptions`
|
||||
Classes | `Win32_PerfRawData_NETFramework_NETCLRExceptions`
|
||||
Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
|
||||
None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_netframework_clrexceptions_exceptions_thrown_total` | Displays the total number of exceptions thrown since the application started. This includes both .NET exceptions and unmanaged exceptions that are converted into .NET exceptions. | counter | `process`
|
||||
`windows_netframework_clrexceptions_exceptions_filters_total` | Displays the total number of .NET exception filters executed. An exception filter evaluates regardless of whether an exception is handled. | counter | `process`
|
||||
`windows_netframework_clrexceptions_exceptions_finallys_total` | Displays the total number of finally blocks executed. Only the finally blocks executed for an exception are counted; finally blocks on normal code paths are not counted by this counter. | counter | `process`
|
||||
`windows_netframework_clrexceptions_throw_to_catch_depth_total` | Displays the total number of stack frames traversed, from the frame that threw the exception to the frame that handled the exception. | counter | `process`
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
## 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!_
|
||||
@@ -1,30 +0,0 @@
|
||||
# netframework_clrinterop collector
|
||||
|
||||
The netframework_clrinterop collector exposes metrics about interop between the dotnet framework and outside components.
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `netframework_clrinterop`
|
||||
Classes | `Win32_PerfRawData_NETFramework_NETCLRInterop`
|
||||
Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
|
||||
None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_netframework_clrinterop_com_callable_wrappers_total` | Displays the current number of COM callable wrappers (CCWs). A CCW is a proxy for a managed object being referenced from an unmanaged COM client. | counter | `process`
|
||||
`windows_netframework_clrinterop_interop_marshalling_total` | Displays the total number of times arguments and return values have been marshaled from managed to unmanaged code, and vice versa, since the application started. | counter | `process`
|
||||
`windows_netframework_clrinterop_interop_stubs_created_total` | Displays the current number of stubs created by the common language runtime. Stubs are responsible for marshaling arguments and return values from managed to unmanaged code, and vice versa, during a COM interop call or a platform invoke call. | counter | `process`
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
## 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!_
|
||||
@@ -1,31 +0,0 @@
|
||||
# netframework_clrjit collector
|
||||
|
||||
The netframework_clrjit collector exposes metrics about the dotnet Just-in-Time compiler.
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `netframework_clrjit`
|
||||
Classes | `Win32_PerfRawData_NETFramework_NETCLRJit`
|
||||
Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
|
||||
None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_netframework_clrjit_jit_methods_total` | Displays the total number of methods JIT-compiled since the application started. This counter does not include pre-JIT-compiled methods. | counter | `process`
|
||||
`windows_netframework_clrjit_jit_time_percent` | Displays the percentage of time spent in JIT compilation. This counter is updated at the end of every JIT compilation phase. A JIT compilation phase occurs when a method and its dependencies are compiled. | gauge | `process`
|
||||
`windows_netframework_clrjit_jit_standard_failures_total` | Displays the peak number of methods the JIT compiler has failed to compile since the application started. This failure can occur if the MSIL cannot be verified or if there is an internal error in the JIT compiler. | counter | `process`
|
||||
`windows_netframework_clrjit_jit_il_bytes_total` | Displays the total number of Microsoft intermediate language (MSIL) bytes compiled by the just-in-time (JIT) compiler since the application started | counter | `process`
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
## 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!_
|
||||
@@ -1,36 +0,0 @@
|
||||
# netframework_clrloading collector
|
||||
|
||||
The netframework_clrloading collector exposes metrics about the dotnet loader.
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `netframework_clrloading`
|
||||
Classes | `Win32_PerfRawData_NETFramework_NETCLRLoading`
|
||||
Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
|
||||
None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_netframework_clrloading_loader_heap_size_bytes` | Displays the current size, in bytes, of the memory committed by the class loader across all application domains. Committed memory is the physical space reserved in the disk paging file. | gauge | `process`
|
||||
`windows_netframework_clrloading_appdomains_loaded_current` | Displays the current number of application domains loaded in this application. | gauge | `process`
|
||||
`windows_netframework_clrloading_assemblies_loaded_current` | Displays the current number of assemblies loaded across all application domains in the currently running application. If the assembly is loaded as domain-neutral from multiple application domains, this counter is incremented only once. | gauge | `process`
|
||||
`windows_netframework_clrloading_classes_loaded_current` | Displays the current number of classes loaded in all assemblies. | gauge | `process`
|
||||
`windows_netframework_clrloading_appdomains_loaded_total` | Displays the peak number of application domains loaded since the application started. | counter | `process`
|
||||
`windows_netframework_clrloading_appdomains_unloaded_total` | Displays the total number of application domains unloaded since the application started. If an application domain is loaded and unloaded multiple times, this counter increments each time the application domain is unloaded. | counter | `process`
|
||||
`windows_netframework_clrloading_assemblies_loaded_total` | Displays the total number of assemblies loaded since the application started. If the assembly is loaded as domain-neutral from multiple application domains, this counter is incremented only once. | counter | `process`
|
||||
`windows_netframework_clrloading_classes_loaded_total` | Displays the cumulative number of classes loaded in all assemblies since the application started. | counter | `process`
|
||||
`windows_netframework_clrloading_class_load_failures_total` | Displays the peak number of classes that have failed to load since the application started. | counter | `process`
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
## 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!_
|
||||
@@ -1,34 +0,0 @@
|
||||
# netframework_clrlocksandthreads collector
|
||||
|
||||
The netframework_clrlocksandthreads collector exposes metrics about locks and threads in dotnet applications.
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `netframework_clrlocksandthreads`
|
||||
Classes | `Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads`
|
||||
Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
|
||||
None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_netframework_clrlocksandthreads_current_queue_length` | Displays the total number of threads that are currently waiting to acquire a managed lock in the application. | gauge | `process`
|
||||
`windows_netframework_clrlocksandthreads_current_logical_threads` | Displays the number of current managed thread objects in the application. This counter maintains the count of both running and stopped threads. | gauge | `process`
|
||||
`windows_netframework_clrlocksandthreads_physical_threads_current` | Displays the number of native operating system threads created and owned by the common language runtime to act as underlying threads for managed thread objects. This counter's value does not include the threads used by the runtime in its internal operations; it is a subset of the threads in the operating system process. | gauge | `process`
|
||||
`windows_netframework_clrlocksandthreads_recognized_threads_current` | Displays the number of threads that are currently recognized by the runtime. These threads are associated with a corresponding managed thread object. The runtime does not create these threads, but they have run inside the runtime at least once. | gauge | `process`
|
||||
`windows_netframework_clrlocksandthreads_recognized_threads_total` | Displays the total number of threads that have been recognized by the runtime since the application started. These threads are associated with a corresponding managed thread object. The runtime does not create these threads, but they have run inside the runtime at least once. | counter | `process`
|
||||
`windows_netframework_clrlocksandthreads_queue_length_total` | Displays the total number of threads that waited to acquire a managed lock since the application started. | counter | `process`
|
||||
`windows_netframework_clrlocksandthreads_contentions_total` | Displays the total number of times that threads in the runtime have attempted to acquire a managed lock unsuccessfully. | counter | `process`
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
## 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!_
|
||||
@@ -1,39 +0,0 @@
|
||||
# netframework_clrmemory collector
|
||||
|
||||
The netframework_clrmemory collector exposes metrics about memory in dotnet applications.
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `netframework_clrmemory`
|
||||
Classes | `Win32_PerfRawData_NETFramework_NETCLRMemory`
|
||||
Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
|
||||
None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_netframework_clrmemory_allocated_bytes_total` | Displays the total number of bytes allocated on the garbage collection heap. | counter | `process`
|
||||
`windows_netframework_clrmemory_finalization_survivors` | Displays the number of garbage-collected objects that survive a collection because they are waiting to be finalized. | gauge | `process`
|
||||
`windows_netframework_clrmemory_heap_size_bytes` | Displays the maximum bytes that can be allocated; it does not indicate the current number of bytes allocated. | gauge | `process`
|
||||
`windows_netframework_clrmemory_promoted_bytes` | Displays the bytes that were promoted from the generation to the next one during the last GC. Memory is promoted when it survives a garbage collection. | gauge | `process`
|
||||
`windows_netframework_clrmemory_number_gc_handles` | Displays the current number of garbage collection handles in use. Garbage collection handles are handles to resources external to the common language runtime and the managed environment. | gauge | `process`
|
||||
`windows_netframework_clrmemory_collections_total` | Displays the number of times the generation objects are garbage collected since the application started. | counter | `process`
|
||||
`windows_netframework_clrmemory_induced_gc_total` | Displays the peak number of times garbage collection was performed because of an explicit call to GC.Collect. | counter | `process`
|
||||
`windows_netframework_clrmemory_number_pinned_objects` | Displays the number of pinned objects encountered in the last garbage collection. | gauge | `process`
|
||||
`windows_netframework_clrmemory_number_sink_blocksinuse` | Displays the current number of synchronization blocks in use. Synchronization blocks are per-object data structures allocated for storing synchronization information. They hold weak references to managed objects and must be scanned by the garbage collector. | gauge | `process`
|
||||
`windows_netframework_clrmemory_committed_bytes` | Displays the amount of virtual memory, in bytes, currently committed by the garbage collector. Committed memory is the physical memory for which space has been reserved in the disk paging file. | gauge | `process`
|
||||
`windows_netframework_clrmemory_reserved_bytes` | Displays the amount of virtual memory, in bytes, currently reserved by the garbage collector. Reserved memory is the virtual memory space reserved for the application when no disk or main memory pages have been used. | gauge | `process`
|
||||
`windows_netframework_clrmemory_gc_time_percent` | Displays the percentage of time that was spent performing a garbage collection in the last sample. | gauge | `process`
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
## 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!_
|
||||
@@ -1,33 +0,0 @@
|
||||
# netframework_clrremoting collector
|
||||
|
||||
The netframework_clrremoting collector exposes metrics about dotnet remoting.
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `netframework_clrremoting`
|
||||
Classes | `Win32_PerfRawData_NETFramework_NETCLRRemoting`
|
||||
Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
|
||||
None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_netframework_clrremoting_channels_total` | Displays the total number of remoting channels registered across all application domains since application started. | counter | `process`
|
||||
`windows_netframework_clrremoting_context_bound_classes_loaded` | Displays the current number of context-bound classes that are loaded. | gauge | `process`
|
||||
`windows_netframework_clrremoting_context_bound_objects_total` | Displays the total number of context-bound objects allocated. | counter | `process`
|
||||
`windows_netframework_clrremoting_context_proxies_total` | Displays the total number of remoting proxy objects in this process since it started. | counter | `process`
|
||||
`windows_netframework_clrremoting_contexts` | Displays the current number of remoting contexts in the application. | gauge | `process`
|
||||
`windows_netframework_clrremoting_remote_calls_total` | Displays the total number of remote procedure calls invoked since the application started. | counter | `process`
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
## 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!_
|
||||
@@ -1,31 +0,0 @@
|
||||
# netframework_clrsecurity collector
|
||||
|
||||
The netframework_clrsecurity collector exposes metrics about security checks in dotnet applications
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `netframework_clrsecurity`
|
||||
Classes | `Win32_PerfRawData_NETFramework_NETCLRSecurity`
|
||||
Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
|
||||
None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_netframework_clrsecurity_link_time_checks_total` | Displays the total number of link-time code access security checks since the application started. | counter | `process`
|
||||
`windows_netframework_clrsecurity_rt_checks_time_percent` | Displays the percentage of time spent performing runtime code access security checks in the last sample. | gauge | `process`
|
||||
`windows_netframework_clrsecurity_stack_walk_depth` | Displays the depth of the stack during that last runtime code access security check. | gauge | `process`
|
||||
`windows_netframework_clrsecurity_runtime_checks_total` | Displays the total number of runtime code access security checks performed since the application started. | counter | `process`
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
## 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!_
|
||||
@@ -14,58 +14,26 @@ None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_os_info` | Contains full product name & version in labels. Note that the `major_version` for Windows 11 is "10"; a build number greater than 22000 represents Windows 11. | gauge | `product`, `version`, `major_version`, `minor_version`, `build_number`
|
||||
`windows_os_paging_limit_bytes` | Total number of bytes that can be stored in the operating system paging files. 0 (zero) indicates that there are no paging files | gauge | None
|
||||
`windows_os_paging_free_bytes` | Number of bytes that can be mapped into the operating system paging files without causing any other pages to be swapped out | gauge | None
|
||||
`windows_os_physical_memory_free_bytes` | Bytes of physical memory currently unused and available | gauge | None
|
||||
`windows_os_time` | 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_os_timezone` | Current timezone as reported by the operating system. See [time.Zone()](https://golang.org/pkg/time/#Time.Zone) for details | gauge | `timezone`
|
||||
`windows_os_processes` | Number of process contexts currently loaded or running on the operating system | gauge | None
|
||||
`windows_os_processes_limit` | Maximum number of process contexts the operating system can support. The default value set by the provider is 4294967295 (0xFFFFFFFF) | gauge | None
|
||||
`windows_os_process_memory_limit_bytes` | Maximum number of bytes of memory that can be allocated to a process | gauge | None
|
||||
`windows_os_users` | Number of user sessions for which the operating system is storing state information currently. For a list of current active logon sessions, see [`logon`](collector.logon.md) | gauge | None
|
||||
`windows_os_virtual_memory_bytes` | Bytes of virtual memory | gauge | None
|
||||
`windows_os_visible_memory_bytes` | Total bytes of physical memory available to the operating system. This value does not necessarily indicate the true amount of physical memory, but what is reported to the operating system as available to it | gauge | None
|
||||
`windows_os_virtual_memory_free_bytes` | Bytes of virtual memory currently unused and available | gauge | None
|
||||
| Name | Description | Type | Labels |
|
||||
|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|------------------------------------------------------------------------|
|
||||
| `windows_os_info` | Contains full product name & version in labels. Note that the `major_version` for Windows 11 is "10"; a build number greater than 22000 represents Windows 11. | gauge | `product`, `version`, `major_version`, `minor_version`, `build_number` |
|
||||
| `windows_os_paging_limit_bytes` | Total number of bytes that can be stored in the operating system paging files. 0 (zero) indicates that there are no paging files | gauge | None |
|
||||
| `windows_os_paging_free_bytes` | Number of bytes that can be mapped into the operating system paging files without causing any other pages to be swapped out | gauge | None |
|
||||
|
||||
|
||||
### Example metric
|
||||
Show current number of processes
|
||||
|
||||
```
|
||||
windows_os_processes{instance="localhost"}
|
||||
# HELP windows_os_hostname Labelled system hostname information as provided by ComputerSystem.DNSHostName and ComputerSystem.Domain
|
||||
# TYPE windows_os_hostname gauge
|
||||
windows_os_hostname{domain="",fqdn="PC",hostname="PC"} 1
|
||||
# HELP windows_os_info Contains full product name & version in labels. Note that the "major_version" for Windows 11 is \\"10\\"; a build number greater than 22000 represents Windows 11.
|
||||
# TYPE windows_os_info gauge
|
||||
windows_os_info{build_number="19045",major_version="10",minor_version="0",product="Windows 10 Pro",revision="4842",version="10.0.19045"} 1
|
||||
```
|
||||
|
||||
## Useful queries
|
||||
Find all devices not set to UTC timezone
|
||||
```
|
||||
windows_os_timezone{timezone != "UTC"}
|
||||
```
|
||||
|
||||
Show memory usage for instance (%)
|
||||
```
|
||||
100 - 100 * windows_os_physical_memory_free_bytes{instance="localhost"} / windows_cs_physical_memory_bytes{instance="localhost"}
|
||||
```
|
||||
_This collector does not yet have useful queries, we would appreciate your help adding them!_
|
||||
|
||||
## Alerting examples
|
||||
**prometheus.rules**
|
||||
```yaml
|
||||
# Alert on hosts that have exhausted all available physical memory
|
||||
- alert: MemoryExhausted
|
||||
expr: windows_os_physical_memory_free_bytes == 0
|
||||
for: 10m
|
||||
labels:
|
||||
severity: high
|
||||
annotations:
|
||||
summary: "Host {{ $labels.instance }} is out of memory"
|
||||
description: "{{ $labels.instance }} has exhausted all available physical memory"
|
||||
|
||||
# Alert on hosts with greater than 90% memory usage
|
||||
- alert: MemoryLow
|
||||
expr: 100 - 100 * windows_os_physical_memory_free_bytes / windows_cs_physical_memory_bytes > 90
|
||||
for: 10m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: "Memory usage for host {{ $labels.instance }} is greater than 90%"
|
||||
```
|
||||
_This collector does not yet have alerting examples, we would appreciate your help adding them!_
|
||||
114
docs/collector.perfdata.md
Normal file
114
docs/collector.perfdata.md
Normal file
@@ -0,0 +1,114 @@
|
||||
# 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.
|
||||
@@ -2,47 +2,24 @@
|
||||
|
||||
The service collector exposes metrics about Windows Services
|
||||
|
||||
The collector exists in 2 different version. Version 1 is using WMI to query all services and is able to provide additional
|
||||
information. Version 2 is a more efficient solution by directly connecting to the service manager, but is not able to
|
||||
provide additional information like `run_as` or start configuration
|
||||
|
||||
## Flags
|
||||
|
||||
### `--collector.service.services-where`
|
||||
|
||||
A WMI filter on which services to include. Recommended to keep down number of returned metrics.
|
||||
|
||||
Example: `--collector.service.services-where="Name='windows_exporter'"`
|
||||
|
||||
Example config win_exporter.yml for multiple services: `services-where: Name='SQLServer' OR Name='Couchbase' OR Name='Spooler' OR Name='ActiveMQ'`
|
||||
|
||||
### `--collector.service.use-api`
|
||||
|
||||
Uses API calls instead of WMI for performance optimization. **Note** the previous flag (`--collector.service.services-where`) won't have any effect on this mode.
|
||||
|
||||
### `--collector.service.v2`
|
||||
|
||||
Version 2 of the service collector. Is using API calls for performance optimization. **Note** the previous flag (`--collector.service.services-where`) won't have any effect on this mode.
|
||||
For additional performance reasons, it doesn't provide any additional information like `run_as` or start configuration.
|
||||
|
||||
# collector V1
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `service`
|
||||
Classes | [`Win32_Service`](https://msdn.microsoft.com/en-us/library/aa394418(v=vs.85).aspx)
|
||||
Classes | none
|
||||
Enabled by default? | Yes
|
||||
|
||||
## Flags
|
||||
|
||||
None
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_service_info` | Contains service information in labels, constant 1 | gauge | name, display_name, process_id, run_as
|
||||
`windows_service_state` | The state of the service, 1 if the current state, 0 otherwise | gauge | name, state
|
||||
`windows_service_start_mode` | The start mode of the service, 1 if the current start mode, 0 otherwise | gauge | name, start_mode
|
||||
`windows_service_status` | The status of the service, 1 if the current status, 0 otherwise | gauge | name, status
|
||||
|
||||
For the values of the `state`, `start_mode`, `status` and `run_as` labels, see below.
|
||||
| Name | Description | Type | Labels |
|
||||
|------------------------------|-----------------------------------------------------------------------------------------------|-------|---------------------------------------|
|
||||
| `windows_service_info` | Contains service information run as user in labels, constant 1 | gauge | name, display_name, path_name, run_as |
|
||||
| `windows_service_start_mode` | The start mode of the service, 1 if the current start mode, 0 otherwise | gauge | name, start_mode |
|
||||
| `windows_service_state` | The state of the service, 1 if the current state, 0 otherwise | gauge | name, state |
|
||||
| `windows_service_process` | Process of started service. The value is the creation time of the process as a unix timestamp | gauge | name, process_id |
|
||||
|
||||
### States
|
||||
|
||||
@@ -65,81 +42,50 @@ A service can have the following start modes:
|
||||
- `manual`
|
||||
- `disabled`
|
||||
|
||||
### Status (not available in API mode)
|
||||
|
||||
A service can have any of the following statuses:
|
||||
- `ok`
|
||||
- `error`
|
||||
- `degraded`
|
||||
- `unknown`
|
||||
- `pred fail`
|
||||
- `starting`
|
||||
- `stopping`
|
||||
- `service`
|
||||
- `stressed`
|
||||
- `nonrecover`
|
||||
- `no contact`
|
||||
- `lost comm`
|
||||
|
||||
Note that there is some overlap with service state.
|
||||
|
||||
### Run As
|
||||
|
||||
Account name under which a service runs. Depending on the service type, the account name may be in the form of "DomainName\Username" or UPN format ("Username@DomainName").
|
||||
|
||||
It corresponds to the `StartName` attribute of the `Win32_Service` class.
|
||||
`StartName` attribute can be NULL and in such case the label is reported as an empty string. Notice that if the attribute is NULL the service is logged on as the `LocalSystem` account or, for kernel or system-level drive, it runs with a default object name created by the I/O system based on the service name, for example, DWDOM\Admin.
|
||||
|
||||
### Example metric
|
||||
Lists the services that have a 'disabled' start mode.
|
||||
```
|
||||
windows_service_start_mode{exported_name=~"(mssqlserver|sqlserveragent)",start_mode="disabled"}
|
||||
```
|
||||
|
||||
## Useful queries
|
||||
Counts the number of Microsoft SQL Server/Agent Processes
|
||||
```
|
||||
count(windows_service_state{exported_name=~"(sqlserveragent|mssqlserver)",state="running"})
|
||||
```
|
||||
|
||||
# collector V2
|
||||
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `service`
|
||||
Classes | none
|
||||
Enabled by default? | No
|
||||
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_service_state` | The state of the service, 1 if the current state, 0 otherwise | gauge | name, display_name, state
|
||||
|
||||
### States
|
||||
|
||||
A service can be in the following states:
|
||||
- `stopped`
|
||||
- `start pending`
|
||||
- `stop pending`
|
||||
- `running`
|
||||
- `continue pending`
|
||||
- `pause pending`
|
||||
- `paused`
|
||||
- `unknown`
|
||||
|
||||
### Example metric
|
||||
|
||||
```
|
||||
windows_service_state{display_name="Declared Configuration(DC) service",name="dcsvc",status="continue pending"} 0
|
||||
windows_service_state{display_name="Declared Configuration(DC) service",name="dcsvc",status="pause pending"} 0
|
||||
windows_service_state{display_name="Declared Configuration(DC) service",name="dcsvc",status="paused"} 0
|
||||
windows_service_state{display_name="Declared Configuration(DC) service",name="dcsvc",status="running"} 0
|
||||
windows_service_state{display_name="Declared Configuration(DC) service",name="dcsvc",status="start pending"} 0
|
||||
windows_service_state{display_name="Declared Configuration(DC) service",name="dcsvc",status="stop pending"} 0
|
||||
windows_service_state{display_name="Declared Configuration(DC) service",name="dcsvc",status="stopped"} 1
|
||||
# HELP windows_service_info A metric with a constant '1' value labeled with service information
|
||||
# TYPE windows_service_info gauge
|
||||
windows_service_info{display_name="Declared Configuration(DC) service",name="dcsvc",path_name="C:\\WINDOWS\\system32\\svchost.exe -k netsvcs -p",run_as="LocalSystem"} 1
|
||||
windows_service_info{display_name="Designs",name="Themes",path_name="C:\\WINDOWS\\System32\\svchost.exe -k netsvcs -p",run_as="LocalSystem"} 1
|
||||
# HELP windows_service_process Process of started service. The value is the creation time of the process as a unix timestamp.
|
||||
# TYPE windows_service_process gauge
|
||||
windows_service_process{name="Themes",process_id="2856"} 1.7244891e+09
|
||||
# HELP windows_service_start_mode The start mode of the service (StartMode)
|
||||
# TYPE windows_service_start_mode gauge
|
||||
windows_service_start_mode{name="Themes",start_mode="auto"} 1
|
||||
windows_service_start_mode{name="Themes",start_mode="boot"} 0
|
||||
windows_service_start_mode{name="Themes",start_mode="disabled"} 0
|
||||
windows_service_start_mode{name="Themes",start_mode="manual"} 0
|
||||
windows_service_start_mode{name="Themes",start_mode="system"} 0
|
||||
windows_service_start_mode{name="dcsvc",start_mode="auto"} 0
|
||||
windows_service_start_mode{name="dcsvc",start_mode="boot"} 0
|
||||
windows_service_start_mode{name="dcsvc",start_mode="disabled"} 0
|
||||
windows_service_start_mode{name="dcsvc",start_mode="manual"} 1
|
||||
windows_service_start_mode{name="dcsvc",start_mode="system"} 0
|
||||
# HELP windows_service_state The state of the service (State)
|
||||
# TYPE windows_service_state gauge
|
||||
windows_service_state{name="Themes",state="continue pending"} 0
|
||||
windows_service_state{name="Themes",state="pause pending"} 0
|
||||
windows_service_state{name="Themes",state="paused"} 0
|
||||
windows_service_state{name="Themes",state="running"} 1
|
||||
windows_service_state{name="Themes",state="start pending"} 0
|
||||
windows_service_state{name="Themes",state="stop pending"} 0
|
||||
windows_service_state{name="Themes",state="stopped"} 0
|
||||
windows_service_state{name="dcsvc",state="continue pending"} 0
|
||||
windows_service_state{name="dcsvc",state="pause pending"} 0
|
||||
windows_service_state{name="dcsvc",state="paused"} 0
|
||||
windows_service_state{name="dcsvc",state="running"} 0
|
||||
windows_service_state{name="dcsvc",state="start pending"} 0
|
||||
windows_service_state{name="dcsvc",state="stop pending"} 0
|
||||
windows_service_state{name="dcsvc",state="stopped"} 1
|
||||
```
|
||||
|
||||
## Useful queries
|
||||
@@ -163,8 +109,8 @@ groups:
|
||||
labels:
|
||||
severity: high
|
||||
annotations:
|
||||
summary: "Service {{ $labels.exported_name }} down"
|
||||
description: "Service {{ $labels.exported_name }} on instance {{ $labels.instance }} has been down for more than 3 minutes."
|
||||
summary: "Service {{ $labels.name }} down"
|
||||
description: "Service {{ $labels.name }} on instance {{ $labels.instance }} has been down for more than 3 minutes."
|
||||
|
||||
# Sends an alert when the 'mssqlserver' service is not in the running state for 3 minutes.
|
||||
- alert: SQL Server DOWN
|
||||
@@ -173,7 +119,7 @@ groups:
|
||||
labels:
|
||||
severity: high
|
||||
annotations:
|
||||
summary: "Service {{ $labels.exported_name }} down"
|
||||
description: "Service {{ $labels.exported_name }} on instance {{ $labels.instance }} has been down for more than 3 minutes."
|
||||
summary: "Service {{ $labels.name }} down"
|
||||
description: "Service {{ $labels.name }} on instance {{ $labels.instance }} has been down for more than 3 minutes."
|
||||
```
|
||||
In this example, `instance` is the target label of the host. So each alert will be processed per host, which is then used in the alert description.
|
||||
|
||||
@@ -5,8 +5,7 @@ The system collector exposes metrics about ...
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `system`
|
||||
Data source | Perflib
|
||||
Classes | [`Win32_PerfRawData_PerfOS_System`](https://web.archive.org/web/20050830140516/http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_perfrawdata_perfos_system.asp)
|
||||
Data source | Performance Counters
|
||||
Enabled by default? | Yes
|
||||
|
||||
## Flags
|
||||
@@ -15,14 +14,18 @@ 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_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_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 |
|
||||
|
||||
|
||||
|
||||
### Example metric
|
||||
Show current number of system threads
|
||||
@@ -30,6 +33,11 @@ Show current number of system threads
|
||||
windows_system_threads{instance="localhost"}
|
||||
```
|
||||
|
||||
Show current number of processes
|
||||
```
|
||||
windows_system_processes{instance="localhost"}
|
||||
```
|
||||
|
||||
## Useful queries
|
||||
Find hosts that have rebooted in the last 24 hours
|
||||
```
|
||||
|
||||
@@ -17,14 +17,16 @@ None
|
||||
|
||||
## 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 |
|
||||
| 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` |
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
@@ -4,7 +4,7 @@ collectors:
|
||||
enabled: cpu,cs,logical_disk,net,os,service,system
|
||||
collector:
|
||||
service:
|
||||
services-where: Name='windows_exporter'
|
||||
include: "windows_exporter"
|
||||
scheduled_task:
|
||||
include: /Microsoft/.+
|
||||
log:
|
||||
|
||||
288
exporter.go
288
exporter.go
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/prometheus-community/windows_exporter/pkg/initiate"
|
||||
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
"os"
|
||||
@@ -25,9 +25,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/config"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/httphandler"
|
||||
winlog "github.com/prometheus-community/windows_exporter/pkg/log"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/log/flag"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
@@ -38,17 +38,6 @@ import (
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
// Same struct prometheus uses for their /version endpoint.
|
||||
// Separate copy to avoid pulling all of prometheus as a dependency.
|
||||
type prometheusVersion struct {
|
||||
Version string `json:"version"`
|
||||
Revision string `json:"revision"`
|
||||
Branch string `json:"branch"`
|
||||
BuildUser string `json:"buildUser"`
|
||||
BuildDate string `json:"buildDate"`
|
||||
GoVersion string `json:"goVersion"`
|
||||
}
|
||||
|
||||
// Mapping of priority names to uin32 values required by windows.SetPriorityClass.
|
||||
var priorityStringToInt = map[string]uint32{
|
||||
"realtime": windows.REALTIME_PRIORITY_CLASS,
|
||||
@@ -59,29 +48,13 @@ var priorityStringToInt = map[string]uint32{
|
||||
"low": windows.IDLE_PRIORITY_CLASS,
|
||||
}
|
||||
|
||||
func setPriorityWindows(pid int, priority uint32) error {
|
||||
// https://learn.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights
|
||||
handle, err := windows.OpenProcess(
|
||||
windows.STANDARD_RIGHTS_REQUIRED|windows.SYNCHRONIZE|windows.SPECIFIC_RIGHTS_ALL,
|
||||
false, uint32(pid),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = windows.SetPriorityClass(handle, priority); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = windows.CloseHandle(handle); err != nil {
|
||||
return fmt.Errorf("failed to close handle: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
func main() {
|
||||
os.Exit(run())
|
||||
}
|
||||
|
||||
func main() {
|
||||
func run() int {
|
||||
app := kingpin.New("windows_exporter", "A metrics collector for Windows.")
|
||||
|
||||
var (
|
||||
configFile = app.Flag(
|
||||
"config.file",
|
||||
@@ -137,25 +110,41 @@ func main() {
|
||||
|
||||
// Load values from configuration file(s). Executable flags must first be parsed, in order
|
||||
// to load the specified file(s).
|
||||
kingpin.MustParse(app.Parse(os.Args[1:]))
|
||||
logger, err := winlog.New(winlogConfig)
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("err", err)
|
||||
os.Exit(1)
|
||||
if _, err := app.Parse(os.Args[1:]); err != nil {
|
||||
//nolint:sloglint // we do not have an logger yet
|
||||
slog.Error("Failed to parse CLI args",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
_ = level.Debug(logger).Log("msg", "Logging has Started")
|
||||
logger, err := winlog.New(winlogConfig)
|
||||
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 != "" {
|
||||
resolver, err := config.NewResolver(*configFile, logger, *insecureSkipVerify)
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("msg", "could not load config file", "err", err)
|
||||
os.Exit(1)
|
||||
logger.Error("could not load config file",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return 1
|
||||
}
|
||||
err = resolver.Bind(app, os.Args[1:])
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("err", err)
|
||||
os.Exit(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
|
||||
@@ -164,34 +153,43 @@ func main() {
|
||||
*webConfig.WebListenAddresses = (*webConfig.WebListenAddresses)[1:]
|
||||
|
||||
// Parse flags once more to include those discovered in configuration file(s).
|
||||
kingpin.MustParse(app.Parse(os.Args[1:]))
|
||||
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 = winlog.New(winlogConfig)
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("err", err)
|
||||
os.Exit(1)
|
||||
//nolint:sloglint // we do not have an logger yet
|
||||
slog.Error("failed to create logger",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
logger.Debug("Logging has Started")
|
||||
|
||||
if *printCollectors {
|
||||
collectorNames := collector.Available()
|
||||
sort.Strings(collectorNames)
|
||||
printCollectorsToStdout()
|
||||
|
||||
fmt.Printf("Available collectors:\n") //nolint:forbidigo
|
||||
for _, n := range collectorNames {
|
||||
fmt.Printf(" - %s\n", n) //nolint:forbidigo
|
||||
}
|
||||
|
||||
return
|
||||
return 0
|
||||
}
|
||||
|
||||
// Only set process priority if a non-default and valid value has been set
|
||||
if *processPriority != "normal" && priorityStringToInt[*processPriority] != 0 {
|
||||
_ = level.Debug(logger).Log("msg", "setting process priority to "+*processPriority)
|
||||
err = setPriorityWindows(os.Getpid(), priorityStringToInt[*processPriority])
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed to set process priority", "err", err)
|
||||
os.Exit(1)
|
||||
if priority, ok := priorityStringToInt[*processPriority]; ok && priority != windows.NORMAL_PRIORITY_CLASS {
|
||||
logger.Debug("setting process priority to " + *processPriority)
|
||||
|
||||
if err = setPriorityWindows(os.Getpid(), priority); err != nil {
|
||||
logger.Error("failed to set process priority",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,79 +197,72 @@ func main() {
|
||||
collectors.Enable(enabledCollectorList)
|
||||
|
||||
// Initialize collectors before loading
|
||||
err = collectors.Build(logger)
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("msg", "Couldn't load collectors", "err", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = collectors.SetPerfCounterQuery(logger)
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("msg", "Couldn't set performance counter query", "err", err)
|
||||
os.Exit(1)
|
||||
if err = collectors.Build(logger); err != nil {
|
||||
logger.Error("Couldn't load collectors",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
if u, err := user.Current(); err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Unable to determine which user is running this exporter. More info: https://github.com/golang/go/issues/37348")
|
||||
} else {
|
||||
_ = level.Info(logger).Log("msg", fmt.Sprintf("Running as %v", u.Username))
|
||||
if err = collectors.SetPerfCounterQuery(logger); err != nil {
|
||||
logger.Error("Couldn't set performance counter query",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
if strings.Contains(u.Username, "ContainerAdministrator") || strings.Contains(u.Username, "ContainerUser") {
|
||||
_ = level.Warn(logger).Log("msg", "Running as a preconfigured Windows Container user. This may mean you do not have Windows HostProcess containers configured correctly and some functionality will not work as expected.")
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
_ = level.Info(logger).Log("msg", fmt.Sprintf("Enabled collectors: %v", strings.Join(enabledCollectorList, ", ")))
|
||||
logCurrentUser(logger)
|
||||
|
||||
logger.Info("Enabled collectors: " + strings.Join(enabledCollectorList, ", "))
|
||||
|
||||
if utils.PDHEnabled() {
|
||||
logger.Info("Using performance data helper from PHD.dll for performance counter collection. This is in experimental state.")
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc(*metricsPath, withConcurrencyLimit(*maxRequests, collectors.BuildServeHTTP(logger, *disableExporterMetrics, *timeoutMargin)))
|
||||
mux.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, err := fmt.Fprintln(w, `{"status":"ok"}`)
|
||||
if err != nil {
|
||||
_ = level.Debug(logger).Log("msg", "Failed to write to stream", "err", err)
|
||||
}
|
||||
})
|
||||
mux.HandleFunc("/version", func(w http.ResponseWriter, _ *http.Request) {
|
||||
// we can't use "version" directly as it is a package, and not an object that
|
||||
// can be serialized.
|
||||
err := json.NewEncoder(w).Encode(prometheusVersion{
|
||||
Version: version.Version,
|
||||
Revision: version.Revision,
|
||||
Branch: version.Branch,
|
||||
BuildUser: version.BuildUser,
|
||||
BuildDate: version.BuildDate,
|
||||
GoVersion: version.GoVersion,
|
||||
})
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("error encoding JSON: %s", err), http.StatusInternalServerError)
|
||||
}
|
||||
})
|
||||
mux.Handle("GET /health", httphandler.NewHealthHandler())
|
||||
mux.Handle("GET /version", httphandler.NewVersionHandler())
|
||||
mux.Handle("GET "+*metricsPath, httphandler.New(logger, collectors, &httphandler.Options{
|
||||
DisableExporterMetrics: *disableExporterMetrics,
|
||||
TimeoutMargin: *timeoutMargin,
|
||||
MaxRequests: *maxRequests,
|
||||
}))
|
||||
|
||||
if *debugEnabled {
|
||||
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
||||
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
||||
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
||||
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||
mux.HandleFunc("GET /debug/pprof/", pprof.Index)
|
||||
mux.HandleFunc("GET /debug/pprof/cmdline", pprof.Cmdline)
|
||||
mux.HandleFunc("GET /debug/pprof/profile", pprof.Profile)
|
||||
mux.HandleFunc("GET /debug/pprof/symbol", pprof.Symbol)
|
||||
mux.HandleFunc("GET /debug/pprof/trace", pprof.Trace)
|
||||
}
|
||||
|
||||
_ = level.Info(logger).Log("msg", "Starting windows_exporter", "version", version.Info())
|
||||
_ = level.Info(logger).Log("msg", "Build context", "build_context", version.BuildContext())
|
||||
_ = level.Debug(logger).Log("msg", "Go MAXPROCS", "procs", runtime.GOMAXPROCS(0))
|
||||
logger.Info("Starting windows_exporter",
|
||||
slog.String("version", version.Version),
|
||||
slog.String("branch", version.Branch),
|
||||
slog.String("revision", version.GetRevision()),
|
||||
slog.String("goversion", version.GoVersion),
|
||||
slog.String("builddate", version.BuildDate),
|
||||
slog.Int("maxprocs", runtime.GOMAXPROCS(0)),
|
||||
)
|
||||
|
||||
server := &http.Server{
|
||||
ReadHeaderTimeout: 5 * time.Second,
|
||||
IdleTimeout: 60 * time.Second,
|
||||
ReadTimeout: 5 * time.Second,
|
||||
WriteTimeout: 10 * time.Minute,
|
||||
WriteTimeout: 5 * time.Minute,
|
||||
Handler: mux,
|
||||
}
|
||||
|
||||
errCh := make(chan error, 1)
|
||||
|
||||
go func() {
|
||||
if err := web.ListenAndServe(server, webConfig, logger); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
_ = level.Error(logger).Log("msg", "cannot start windows_exporter", "err", err)
|
||||
os.Exit(1)
|
||||
errCh <- err
|
||||
}
|
||||
|
||||
errCh <- nil
|
||||
}()
|
||||
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
|
||||
@@ -279,9 +270,17 @@ func main() {
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
_ = level.Info(logger).Log("msg", "Shutting down windows_exporter via kill signal")
|
||||
logger.Info("Shutting down windows_exporter via kill signal")
|
||||
case <-initiate.StopCh:
|
||||
_ = level.Info(logger).Log("msg", "Shutting down windows_exporter via service control")
|
||||
logger.Info("Shutting down windows_exporter via service control")
|
||||
case err := <-errCh:
|
||||
if err != nil {
|
||||
logger.Error("Failed to start windows_exporter",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
@@ -289,24 +288,53 @@ func main() {
|
||||
|
||||
_ = server.Shutdown(ctx)
|
||||
|
||||
_ = level.Info(logger).Log("msg", "windows_exporter has shut down")
|
||||
logger.Info("windows_exporter has shut down")
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func withConcurrencyLimit(n int, next http.HandlerFunc) http.HandlerFunc {
|
||||
if n <= 0 {
|
||||
return next
|
||||
}
|
||||
func printCollectorsToStdout() {
|
||||
collectorNames := collector.Available()
|
||||
sort.Strings(collectorNames)
|
||||
|
||||
sem := make(chan struct{}, n)
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
select {
|
||||
case sem <- struct{}{}:
|
||||
defer func() { <-sem }()
|
||||
default:
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
_, _ = w.Write([]byte("Too many concurrent requests"))
|
||||
return
|
||||
fmt.Println("Available collectors:") //nolint:forbidigo
|
||||
|
||||
for _, n := range collectorNames {
|
||||
fmt.Printf(" - %s\n", n) //nolint:forbidigo
|
||||
}
|
||||
}
|
||||
|
||||
func logCurrentUser(logger *slog.Logger) {
|
||||
if u, err := user.Current(); err == nil {
|
||||
logger.Info("Running as " + u.Username)
|
||||
|
||||
if strings.Contains(u.Username, "ContainerAdministrator") || strings.Contains(u.Username, "ContainerUser") {
|
||||
logger.Warn("Running as a preconfigured Windows Container user. This may mean you do not have Windows HostProcess containers configured correctly and some functionality will not work as expected.")
|
||||
}
|
||||
next(w, r)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
logger.Warn("Unable to determine which user is running this exporter. More info: https://github.com/golang/go/issues/37348")
|
||||
}
|
||||
|
||||
func setPriorityWindows(pid int, priority uint32) error {
|
||||
// https://learn.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights
|
||||
handle, err := windows.OpenProcess(
|
||||
windows.STANDARD_RIGHTS_REQUIRED|windows.SYNCHRONIZE|windows.SPECIFIC_RIGHTS_ALL,
|
||||
false, uint32(pid),
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open own process: %w", err)
|
||||
}
|
||||
|
||||
if err = windows.SetPriorityClass(handle, priority); err != nil {
|
||||
return fmt.Errorf("failed to set priority class: %w", err)
|
||||
}
|
||||
|
||||
if err = windows.CloseHandle(handle); err != nil {
|
||||
return fmt.Errorf("failed to close handle: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
47
go.mod
47
go.mod
@@ -1,56 +1,53 @@
|
||||
module github.com/prometheus-community/windows_exporter
|
||||
|
||||
go 1.22
|
||||
go 1.23
|
||||
|
||||
require (
|
||||
github.com/Microsoft/hcsshim v0.12.6
|
||||
github.com/Microsoft/hcsshim v0.12.7
|
||||
github.com/alecthomas/kingpin/v2 v2.4.0
|
||||
github.com/bmatcuk/doublestar/v4 v4.6.1
|
||||
github.com/dimchansky/utfbom v1.1.1
|
||||
github.com/go-kit/log v0.2.1
|
||||
github.com/go-ole/go-ole v1.3.0
|
||||
github.com/prometheus/client_golang v1.20.2
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/prometheus/client_golang v1.20.4
|
||||
github.com/prometheus/client_model v0.6.1
|
||||
github.com/prometheus/common v0.55.0
|
||||
github.com/prometheus/exporter-toolkit v0.11.0
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/prometheus/common v0.59.2-0.20240918152650-14bac55a992f
|
||||
github.com/prometheus/exporter-toolkit v0.13.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/yusufpapurcu/wmi v1.2.4
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
|
||||
golang.org/x/sys v0.24.0
|
||||
golang.org/x/sys v0.25.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30 // 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.1.0 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.5.1 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/jpillora/backoff v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.17.9 // indirect
|
||||
github.com/klauspost/compress v1.17.10 // 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
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
|
||||
golang.org/x/crypto v0.25.0 // indirect
|
||||
golang.org/x/net v0.27.0 // indirect
|
||||
golang.org/x/oauth2 v0.21.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
|
||||
google.golang.org/grpc v1.65.0 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
golang.org/x/crypto v0.27.0 // indirect
|
||||
golang.org/x/net v0.29.0 // indirect
|
||||
golang.org/x/oauth2 v0.23.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
golang.org/x/text v0.18.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 // indirect
|
||||
google.golang.org/grpc v1.67.0 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
||||
72
go.sum
72
go.sum
@@ -2,14 +2,16 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/Microsoft/hcsshim v0.12.6 h1:qEnZjoHXv+4/s0LmKZWE0/AiZmMWEIkFfWBSf1a0wlU=
|
||||
github.com/Microsoft/hcsshim v0.12.6/go.mod h1:ZABCLVcvLMjIkzr9rUGcQ1QA0p0P3Ps+d3N1g2DsFfk=
|
||||
github.com/Microsoft/hcsshim v0.12.7 h1:MP6R1spmjxTE4EU4J3YsrTxn8CjvN9qwjTKJXldFaRg=
|
||||
github.com/Microsoft/hcsshim v0.12.7/go.mod h1:HPbAuJ9BvQYYZbB4yEQcyGIsTP5L4yHKeO9XO149AEM=
|
||||
github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY=
|
||||
github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
|
||||
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30 h1:t3eaIm0rUkzbrIewtiFmMK5RXHej2XnoXNhxVsAYUfg=
|
||||
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30/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.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
|
||||
github.com/bmatcuk/doublestar/v4 v4.6.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=
|
||||
@@ -30,10 +32,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
|
||||
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
|
||||
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
|
||||
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||
@@ -65,14 +63,18 @@ 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/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0=
|
||||
github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||
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=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos=
|
||||
github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ=
|
||||
github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ=
|
||||
github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
|
||||
@@ -81,15 +83,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.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg=
|
||||
github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||
github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
|
||||
github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||
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.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
|
||||
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
|
||||
github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g=
|
||||
github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q=
|
||||
github.com/prometheus/common v0.59.2-0.20240918152650-14bac55a992f h1:3okwxT2ame6iNnOMGt2bH7JISqpwGn2KoMZ2bVFBQ6I=
|
||||
github.com/prometheus/common v0.59.2-0.20240918152650-14bac55a992f/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0=
|
||||
github.com/prometheus/exporter-toolkit v0.13.0 h1:lmA0Q+8IaXgmFRKw09RldZmZdnvu9wwcDLIXGmTPw1c=
|
||||
github.com/prometheus/exporter-toolkit v0.13.0/go.mod h1:2uop99EZl80KdXhv/MxVI2181fMcwlsumFOqBecGkG0=
|
||||
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=
|
||||
@@ -99,11 +101,12 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
|
||||
@@ -114,11 +117,9 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||
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-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
||||
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
|
||||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
|
||||
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=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
@@ -128,16 +129,16 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
|
||||
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
|
||||
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -145,12 +146,12 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
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.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
|
||||
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
|
||||
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
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=
|
||||
@@ -162,15 +163,15 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 h1:N9BgCIAUvn/M+p4NJccWPWb3BWh88+zyL0ll9HgbEeM=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
|
||||
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.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
|
||||
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
|
||||
google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw=
|
||||
google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
||||
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=
|
||||
@@ -185,7 +186,6 @@ google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWn
|
||||
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=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -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 .\windows_exporter.wxs -d Version=$($MsiVersion) -ext WixToolset.Firewall.wixext -ext WixToolset.Util.wixext"
|
||||
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"
|
||||
|
||||
Write-Verbose "Done!"
|
||||
Pop-Location
|
||||
|
||||
38
installer/files.wxs
Normal file
38
installer/files.wxs
Normal file
@@ -0,0 +1,38 @@
|
||||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:netfx="http://wixtoolset.org/schemas/v4/wxs/netfx"
|
||||
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
|
||||
<Fragment>
|
||||
<DirectoryRef Id="APPLICATIONFOLDER">
|
||||
<Component Transitive="yes">
|
||||
<File Id="windows_exporter.exe" Name="windows_exporter.exe" Source="Work\windows_exporter.exe" KeyPath="yes" Vital="yes" Checksum="yes"/>
|
||||
<ServiceInstall
|
||||
Id="InstallExporterService"
|
||||
Name="windows_exporter"
|
||||
DisplayName="windows_exporter"
|
||||
Description="Exports Prometheus metrics about the system"
|
||||
ErrorControl="normal"
|
||||
Start="auto"
|
||||
Type="ownProcess"
|
||||
Vital="yes"
|
||||
Arguments="--log.file eventlog [ConfigFileFlag] [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirsFlag] [ExtraFlags]">
|
||||
<util:ServiceConfig
|
||||
ResetPeriodInDays="1"
|
||||
FirstFailureActionType="restart"
|
||||
SecondFailureActionType="restart"
|
||||
ThirdFailureActionType="restart"
|
||||
RestartServiceDelayInSeconds="60"
|
||||
/>
|
||||
<ServiceDependency Id="wmiApSrv" />
|
||||
</ServiceInstall>
|
||||
<ServiceControl Id="ServiceStateControl" Name="windows_exporter" Remove="uninstall" Start="install" Stop="both"/>
|
||||
</Component>
|
||||
<Component Id="CreateTextfileDirectory" Directory="textfile_inputs" Guid="d03ef58a-9cbf-4165-ad39-d143e9b27e14">
|
||||
<CreateFolder />
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
<ComponentGroup Id="CG_Files">
|
||||
<ComponentRef Id="windows_exporter.exe" />
|
||||
<ComponentRef Id="CreateTextfileDirectory" />
|
||||
</ComponentGroup>
|
||||
</Fragment>
|
||||
</Wix>
|
||||
221
installer/main.wxs
Normal file
221
installer/main.wxs
Normal file
@@ -0,0 +1,221 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<?ifndef Version?>
|
||||
<?error Version must be defined?>
|
||||
<?endif?>
|
||||
<?if $(sys.BUILDARCH) = x64 or $(sys.BUILDARCH) = arm64 ?>
|
||||
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
|
||||
<?else ?>
|
||||
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
|
||||
<?endif?>
|
||||
|
||||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
|
||||
xmlns:fw="http://wixtoolset.org/schemas/v4/wxs/firewall"
|
||||
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
|
||||
<Package UpgradeCode="66a6eb5b-1fc2-4b14-a362-5ceec6413308" Name="$(var.ProductName)" Version="$(var.Version)"
|
||||
Manufacturer="prometheus-community" Language="1033" Scope="perMachine">
|
||||
<SummaryInformation Manufacturer="prometheus-community" Description="$(var.ProductName) $(var.Version) installer" />
|
||||
|
||||
<Upgrade Id="66a6eb5b-1fc2-4b14-a362-5ceec6413308">
|
||||
<UpgradeVersion IncludeMinimum="no"
|
||||
Minimum="$(var.Version)"
|
||||
OnlyDetect="no"
|
||||
Property="NEWERVERSIONDETECTED" />
|
||||
<UpgradeVersion IncludeMaximum="yes"
|
||||
IncludeMinimum="yes"
|
||||
Maximum="$(var.Version)"
|
||||
Minimum="0.0.0.0"
|
||||
Property="OLDERVERSIONBEINGUPGRADED" />
|
||||
</Upgrade>
|
||||
|
||||
<CustomAction Id="set_maintenance" Property="MAINTENANCE" Value="true" />
|
||||
|
||||
<!-- Set to reinstall all features. -->
|
||||
<CustomAction Id="set_reinstall_all_property"
|
||||
Property="REINSTALL"
|
||||
Value="ALL" />
|
||||
<!-- "amus" will force reinstall all files.
|
||||
See https://docs.microsoft.com/en-us/windows/desktop/Msi/reinstallmode -->
|
||||
<CustomAction Id="set_reinstallmode_property"
|
||||
Property="REINSTALLMODE"
|
||||
Value="amus" />
|
||||
<SetProperty
|
||||
Id="CreateConfigFile"
|
||||
Value=""[%ComSpec]" /c TYPE NUL >>"[ConfigFile_NonDefault][ConfigFile_Default]""
|
||||
Before="CreateConfigFile"
|
||||
Sequence="execute"
|
||||
Condition="ConfigFile_NonDefault OR ConfigFile_Default"
|
||||
/>
|
||||
<CustomAction
|
||||
Id="CreateConfigFile"
|
||||
BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)"
|
||||
DllEntry="WixQuietExec"
|
||||
Execute="deferred"
|
||||
Return="check"
|
||||
Impersonate="no"
|
||||
/>
|
||||
|
||||
<InstallExecuteSequence>
|
||||
<!-- Set REINSTALL=all and REINSTALLMODE=amus if the user reruns the
|
||||
MSI, which will force reinstalling all files and services. -->
|
||||
<Custom Action="set_maintenance" Before="set_reinstall_all_property"
|
||||
Condition="Installed AND (NOT REMOVE) AND (NOT UPGRADINGPRODUCTCODE)"/>
|
||||
<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" />
|
||||
</InstallExecuteSequence>
|
||||
|
||||
<Media Id="1" Cabinet="windows_exporter.cab" EmbedCab="yes" />
|
||||
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." AllowSameVersionUpgrades="yes" />
|
||||
|
||||
<Property Id="ENABLED_COLLECTORS" Secure="yes" />
|
||||
<SetProperty Id="CollectorsFlag" After="InstallFiles" Sequence="execute" Value="--collectors.enabled [ENABLED_COLLECTORS]" Condition="ENABLED_COLLECTORS" />
|
||||
|
||||
<Property Id="EXTRA_FLAGS" Secure="yes" />
|
||||
<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<>"config.yaml"" />
|
||||
<SetProperty Id="ConfigFile_Default" After="InstallFiles" Sequence="execute" Value="[APPLICATIONFOLDER]config.yaml" Condition="CONFIG_FILE="config.yaml"" />
|
||||
<SetProperty Id="ConfigFileFlag" After="InstallFiles" Sequence="execute" Value="--config.file="[ConfigFile_NonDefault][ConfigFile_Default]"" Condition="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<>"" OR LISTEN_PORT<>9182" />
|
||||
|
||||
<Property Id="METRICS_PATH" Secure="yes" />
|
||||
<SetProperty Id="MetricsPathFlag" After="InstallFiles" Sequence="execute" Value="--telemetry.path [METRICS_PATH]" Condition="METRICS_PATH" />
|
||||
|
||||
<Property Id="REMOTE_ADDR" Secure="yes" />
|
||||
<SetProperty Id="RemoteAddressFlag" After="InstallFiles" Sequence="execute" Value="[REMOTE_ADDR]" Condition="REMOTE_ADDR" />
|
||||
|
||||
<Property Id="TEXTFILE_DIRS" Secure="yes" />
|
||||
<SetProperty Id="TextfileDirsFlag" After="InstallFiles" Sequence="execute" Value="--collector.textfile.directories [TEXTFILE_DIRS]" Condition="TEXTFILE_DIRS" />
|
||||
|
||||
<Property Id="ARPHELPLINK" Value="https://github.com/prometheus-community/windows_exporter/issues" />
|
||||
<Property Id="ARPSIZE" Value="9000" />
|
||||
<Property Id="ARPURLINFOABOUT" Value="https://github.com/prometheus-community/windows_exporter" />
|
||||
<!--<Property Id="ARPNOMODIFY" Value="0" />-->
|
||||
<!--<Property Id="ARPNOREPAIR" Value="1" />-->
|
||||
<Property Id="START_MENU_FOLDER" Value="0" />
|
||||
<Property Id="NOSTART" Value="0" />
|
||||
|
||||
<Feature
|
||||
Id="DefaultFeature"
|
||||
Level="1"
|
||||
Title="$(var.ProductName) $(var.Version)"
|
||||
Description="The binary and configuration files for $(var.ProductName)"
|
||||
Display="expand"
|
||||
ConfigurableDirectory="APPLICATIONFOLDER"
|
||||
AllowAdvertise="no"
|
||||
InstallDefault="local"
|
||||
AllowAbsent="no"
|
||||
>
|
||||
<ComponentGroupRef Id="CG_Files" />
|
||||
|
||||
<Feature
|
||||
Id="FirewallException"
|
||||
Level="2"
|
||||
Title="Firewall Exception"
|
||||
Description="Allow $(var.ProductName) to listen on a port"
|
||||
Display="expand"
|
||||
AllowAdvertise="no"
|
||||
AllowAbsent="yes">
|
||||
<ComponentGroupRef Id="CG_FirewallException" />
|
||||
</Feature>
|
||||
</Feature>
|
||||
|
||||
<UI Id="FeatureTree">
|
||||
<ui:WixUI Id="WixUI_FeatureTree" />
|
||||
<UIRef Id="WixUI_ErrorProgressText" />
|
||||
<Dialog Id="CustomPropertiesDlg" Width="370" Height="270" Title="windows_exporter configuration">
|
||||
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.CustomizeDlgBannerBitmap)" />
|
||||
<!--<Control Id="Text" Type="Text" X="25" Y="55" Width="320" Height="20" Text="Text" />-->
|
||||
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
|
||||
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
|
||||
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="This pages contains configuration related to windows_exporter" />
|
||||
<Control Id="Title" Type="Text" X="15" Y="6" Width="210" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}windows_exporter configuration" />
|
||||
|
||||
<!-- Edit box for property input -->
|
||||
<!-- cpu,cs,logical_disk,physical_disk,net,os,service,system -->
|
||||
<Control Id="PropertyEdit_ENABLED_COLLECTORS_Title1" Type="Text" X="25" Y="55" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Text="Comma-separated list of collectors to use. Use '[\[]defaults[\]]' as a placeholder for all" />
|
||||
<Control Id="PropertyEdit_ENABLED_COLLECTORS_Title2" Type="Text" X="25" Y="65" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Text="the collectors enabled by default. If value is empty, the exporter default will be used." />
|
||||
<Control Id="PropertyEdit_ENABLED_COLLECTORS" Type="Edit" X="24" Y="77" Width="300" Height="18" Property="ENABLED_COLLECTORS" Text="[ENABLED_COLLECTORS]" Indirect="no" />
|
||||
|
||||
<Control Id="PropertyEdit_EXTRA_FLAGS_Title" Type="Text" X="25" Y="100" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Text="Additional command line flags" />
|
||||
<Control Id="PropertyEdit_EXTRA_FLAGS" Type="Edit" X="24" Y="112" Width="300" Height="18" Property="EXTRA_FLAGS" Text="[EXTRA_FLAGS]" Indirect="no" />
|
||||
|
||||
<Control Id="PropertyEdit_LISTEN_PORT_Title" Type="Text" X="25" Y="135" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Text="Port to listen" />
|
||||
<Control Id="PropertyEdit_LISTEN_PORT" Type="Edit" X="24" Y="147" Width="300" Height="18" Property="LISTEN_PORT" Text="[LISTEN_PORT]" Indirect="no" />
|
||||
|
||||
<Control Id="PropertyEdit_CONFIG_FILE_Title1" Type="Text" X="25" Y="170" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Text="Path to config file. If empty, no config will be used. If set to 'config.yaml', " />
|
||||
<Control Id="PropertyEdit_CONFIG_FILE_Title2" Type="Text" X="25" Y="180" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Text="then the config.yaml at the install path will be used." />
|
||||
<Control Id="PropertyEdit_CONFIG_FILE" Type="Edit" X="24" Y="192" Width="300" Height="18" Property="CONFIG_FILE" Text="[CONFIG_FILE]" Indirect="no" />
|
||||
|
||||
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
|
||||
<Publish Event="NewDialog" Value="VerifyReadyDlg" />
|
||||
</Control>
|
||||
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)">
|
||||
<Publish Event="NewDialog" Value="CustomizeDlg" />
|
||||
</Control>
|
||||
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
|
||||
<Publish Event="SpawnDialog" Value="CancelDlg" />
|
||||
</Control>
|
||||
</Dialog>
|
||||
|
||||
<!-- skip the license agreement dialog; higher Order takes priority (weird) -->
|
||||
|
||||
<Publish
|
||||
Condition="NOT Installed"
|
||||
Dialog="WelcomeDlg"
|
||||
Control="Next"
|
||||
Event="NewDialog"
|
||||
Value="CustomizeDlg"
|
||||
Order="10"/>
|
||||
<Publish
|
||||
Condition="NOT Installed"
|
||||
Dialog="CustomizeDlg"
|
||||
Control="Back"
|
||||
Event="NewDialog"
|
||||
Value="WelcomeDlg"
|
||||
Order="10"/>
|
||||
<Publish
|
||||
Dialog="CustomizeDlg"
|
||||
Control="Next"
|
||||
Event="NewDialog"
|
||||
Value="CustomPropertiesDlg"
|
||||
Order="10"/>
|
||||
<Publish
|
||||
Dialog="VerifyReadyDlg"
|
||||
Control="Back"
|
||||
Event="NewDialog"
|
||||
Value="CustomPropertiesDlg"
|
||||
Order="10"/>
|
||||
|
||||
|
||||
<!--CustomPropertyDlg-->
|
||||
</UI>
|
||||
|
||||
<!-- InstallLocation key -->
|
||||
<CustomAction Id="SetInstallLocation" Property="ARPINSTALLLOCATION" Value="[APPLICATIONFOLDER]" />
|
||||
|
||||
<StandardDirectory Id="ProgramFiles64Folder">
|
||||
<Directory Id="APPLICATIONFOLDER" Name="windows_exporter">
|
||||
<Directory Id="textfile_inputs" Name="textfile_inputs" />
|
||||
</Directory>
|
||||
</StandardDirectory>
|
||||
|
||||
<ComponentGroup Id="CG_FirewallException">
|
||||
<Component Directory="APPLICATIONFOLDER" Id="C_FirewallException" Guid="9f522655-ac0e-42d2-a512-a7b19ebec7f7">
|
||||
<fw:FirewallException
|
||||
Id="MetricsEndpoint"
|
||||
Name="$(var.ProductName)"
|
||||
Description="$(var.ProductName) HTTP endpoint"
|
||||
Program="[#windows_exporter.exe]"
|
||||
Port="[LISTEN_PORT]"
|
||||
Protocol="tcp">
|
||||
<fw:RemoteAddress Value="[REMOTE_ADDR]" />
|
||||
</fw:FirewallException>
|
||||
</Component>
|
||||
</ComponentGroup>
|
||||
</Package>
|
||||
</Wix>
|
||||
@@ -1,110 +0,0 @@
|
||||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:fw="http://wixtoolset.org/schemas/v4/wxs/firewall" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
|
||||
<?if $(sys.BUILDARCH)=x64 ?>
|
||||
<?define PlatformProgramFiles = "ProgramFiles64Folder" ?>
|
||||
<?else?>
|
||||
<?define PlatformProgramFiles = "ProgramFilesFolder" ?>
|
||||
<?endif?>
|
||||
|
||||
<Package UpgradeCode="66a6eb5b-1fc2-4b14-a362-5ceec6413308" Name="windows_exporter" Version="$(var.Version)" Manufacturer="prometheus-community" Language="1033" Codepage="1252">
|
||||
<SummaryInformation Manufacturer="prometheus-community" Description="windows_exporter $(var.Version) installer" />
|
||||
|
||||
<Media Id="1" Cabinet="windows_exporter.cab" EmbedCab="yes" />
|
||||
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
|
||||
|
||||
<Property Id="ENABLED_COLLECTORS" Secure="yes" />
|
||||
<SetProperty Id="CollectorsFlag" After="InstallFiles" Sequence="execute" Value="--collectors.enabled [ENABLED_COLLECTORS]" Condition="ENABLED_COLLECTORS" />
|
||||
|
||||
<Property Id="EXTRA_FLAGS" Secure="yes" />
|
||||
<SetProperty Id="ExtraFlags" After="InstallFiles" Sequence="execute" Value="[EXTRA_FLAGS]" Condition="EXTRA_FLAGS" />
|
||||
|
||||
<Property Id="ADD_FIREWALL_EXCEPTION" Secure="yes" />
|
||||
|
||||
<Property Id="ENABLE_V1_PERFORMANCE_COUNTERS" Secure="yes" />
|
||||
|
||||
<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<>"" OR LISTEN_PORT<>9182" />
|
||||
|
||||
<Property Id="METRICS_PATH" Secure="yes" />
|
||||
<SetProperty Id="MetricsPathFlag" After="InstallFiles" Sequence="execute" Value="--telemetry.path [METRICS_PATH]" Condition="METRICS_PATH" />
|
||||
|
||||
<Property Id="REMOTE_ADDR" Secure="yes" />
|
||||
<SetProperty Id="RemoteAddressFlag" After="InstallFiles" Sequence="execute" Value="[REMOTE_ADDR]" Condition="REMOTE_ADDR" />
|
||||
|
||||
<!-- https://github.com/prometheus-community/windows_exporter/issues/1318 -->
|
||||
<!-- https://wixtoolset.org/docs/tools/wixext/quietexec/ -->
|
||||
<SetProperty
|
||||
Id="WixQuietExecCmdLine"
|
||||
Value=""[%ComSpec]" /c reg delete HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Application\windows_exporter /f"
|
||||
Before="RemoveEventSource"
|
||||
Sequence="execute"
|
||||
/>
|
||||
<CustomAction
|
||||
Id="RemoveEventSource"
|
||||
BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)"
|
||||
DllEntry="WixSilentExec"
|
||||
Execute="deferred"
|
||||
Impersonate="no"
|
||||
Return="ignore"
|
||||
/>
|
||||
<InstallExecuteSequence>
|
||||
<Custom Action="RemoveEventSource" After="InstallInitialize" />
|
||||
</InstallExecuteSequence>
|
||||
|
||||
<SetProperty
|
||||
Id="EnableV1PerformanceCounters"
|
||||
Value=""[%ComSpec]" /c lodctr.exe /E:Lsa & lodctr.exe /E:PerfProc & lodctr.exe /R"
|
||||
Before="EnableV1PerformanceCounters"
|
||||
Sequence="execute"
|
||||
/>
|
||||
<CustomAction
|
||||
Id="EnableV1PerformanceCounters"
|
||||
BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)"
|
||||
DllEntry="WixSilentExec"
|
||||
Execute="deferred"
|
||||
Impersonate="no"
|
||||
Return="check"
|
||||
/>
|
||||
|
||||
<InstallExecuteSequence>
|
||||
<Custom Action="EnableV1PerformanceCounters" Before="InstallFinalize" Condition="ENABLE_V1_PERFORMANCE_COUNTERS="yes""/>
|
||||
</InstallExecuteSequence>
|
||||
|
||||
<Property Id="TEXTFILE_DIRS" Secure="yes" />
|
||||
<SetProperty Id="TextfileDirsFlag" After="InstallFiles" Sequence="execute" Value="--collector.textfile.directories [TEXTFILE_DIRS]" Condition="TEXTFILE_DIRS" />
|
||||
|
||||
<ComponentGroup Id="Files">
|
||||
<Component Directory="APPLICATIONROOTDIRECTORY">
|
||||
<File Id="windows_exporter.exe" Name="windows_exporter.exe" Source="Work\windows_exporter.exe" KeyPath="yes" />
|
||||
<ServiceInstall Id="InstallExporterService" Name="windows_exporter" DisplayName="windows_exporter" Description="Exports Prometheus metrics about the system" ErrorControl="normal" Start="auto" Type="ownProcess" Arguments="--log.file eventlog [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirsFlag] [ExtraFlags]">
|
||||
<util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="restart" RestartServiceDelayInSeconds="60" />
|
||||
<ServiceDependency Id="wmiApSrv" />
|
||||
</ServiceInstall>
|
||||
<ServiceControl Id="ServiceStateControl" Name="windows_exporter" Remove="uninstall" Start="install" Stop="both" />
|
||||
</Component>
|
||||
<Component Id="CreateTextfileDirectory" Directory="textfile_inputs" Guid="d03ef58a-9cbf-4165-ad39-d143e9b27e14">
|
||||
<CreateFolder />
|
||||
</Component>
|
||||
</ComponentGroup>
|
||||
<ComponentGroup Id="CG_FirewallException">
|
||||
<Component Condition="ADD_FIREWALL_EXCEPTION="yes"" Directory="APPLICATIONROOTDIRECTORY" Id="C_FirewallException" Guid="9f522655-ac0e-42d2-a512-a7b19ebec7f7">
|
||||
<fw:FirewallException Id="MetricsEndpoint" Name="windows_exporter (HTTP [LISTEN_PORT])" Description="windows_exporter HTTP endpoint" Port="[LISTEN_PORT]" Protocol="tcp" IgnoreFailure="yes">
|
||||
<fw:RemoteAddress Value="[REMOTE_ADDR]" />
|
||||
</fw:FirewallException>
|
||||
</Component>
|
||||
</ComponentGroup>
|
||||
|
||||
<Feature Id="DefaultFeature" Level="1">
|
||||
<ComponentGroupRef Id="Files" />
|
||||
</Feature>
|
||||
|
||||
<Feature Id="FirewallException" Level="1">
|
||||
<ComponentGroupRef Id="CG_FirewallException" />
|
||||
</Feature>
|
||||
|
||||
<StandardDirectory Id="ProgramFiles64Folder">
|
||||
<Directory Id="APPLICATIONROOTDIRECTORY" Name="windows_exporter">
|
||||
<Directory Id="textfile_inputs" Name="textfile_inputs" />
|
||||
</Directory>
|
||||
</StandardDirectory>
|
||||
</Package>
|
||||
</Wix>
|
||||
@@ -32,7 +32,7 @@ spec:
|
||||
command: ["powershell"]
|
||||
args: ["New-NetFirewallRule", "-DisplayName", "'windows-exporter'", "-Direction", "inbound", "-Profile", "Any", "-Action", "Allow", "-LocalPort", "9182", "-Protocol", "TCP"]
|
||||
containers:
|
||||
- args:
|
||||
- args:
|
||||
- --config.file=%CONTAINER_SANDBOX_MOUNT_POINT%/config.yml
|
||||
name: windows-exporter
|
||||
image: ghcr.io/prometheus-community/windows-exporter:latest
|
||||
@@ -65,4 +65,4 @@ data:
|
||||
enabled: '[defaults],container'
|
||||
collector:
|
||||
service:
|
||||
services-where: "Name='containerd' or Name='kubelet'"
|
||||
include: "containerd|kubelet"
|
||||
|
||||
@@ -4,10 +4,9 @@ package ad
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
@@ -108,15 +107,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
@@ -502,12 +501,16 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting ad metrics", "err", err)
|
||||
logger.Error("failed collecting ad metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -668,6 +671,7 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_DirectoryServices_DirectoryServices", &dst); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(dst) == 0 {
|
||||
return errors.New("WMI query returned empty result set")
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@ package adcs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||
@@ -60,15 +59,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"Certification Authority"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
c.requestsPerSecond = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "requests_total"),
|
||||
"Total certificate requests processed",
|
||||
@@ -151,12 +150,16 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collectADCSCounters(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting ADCS metrics", "err", err)
|
||||
logger.Error("failed collecting ADCS metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -177,15 +180,18 @@ type perflibADCS struct {
|
||||
SignedCertificateTimestampListProcessingTime float64 `perflib:"Signed Certificate Timestamp List processing time (ms)"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectADCSCounters(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectADCSCounters(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
dst := make([]perflibADCS, 0)
|
||||
|
||||
if _, ok := ctx.PerfObjects["Certification Authority"]; !ok {
|
||||
return errors.New("perflib did not contain an entry for Certification Authority")
|
||||
}
|
||||
|
||||
err := perflib.UnmarshalObject(ctx.PerfObjects["Certification Authority"], &dst, logger)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(dst) == 0 {
|
||||
return errors.New("perflib query for Certification Authority (ADCS) returned empty result set")
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
package adfs
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"math"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -87,15 +87,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"AD FS"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
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",
|
||||
@@ -404,9 +404,11 @@ type perflibADFS struct {
|
||||
FederationMetadataRequests float64 `perflib:"Federation Metadata Requests"`
|
||||
}
|
||||
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var adfsData []perflibADFS
|
||||
|
||||
err := perflib.UnmarshalObject(ctx.PerfObjects["AD FS"], &adfsData, logger)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -669,5 +671,6 @@ func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
prometheus.CounterValue,
|
||||
adfsData[0].FederationMetadataRequests,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
27
pkg/collector/cache/cache.go
vendored
27
pkg/collector/cache/cache.go
vendored
@@ -3,10 +3,10 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -74,15 +74,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"Cache"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
c.asyncCopyReadsTotal = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "async_copy_reads_total"),
|
||||
"(AsyncCopyReadsTotal)",
|
||||
@@ -257,14 +257,17 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect implements the Collector interface.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting cache metrics", "err", err)
|
||||
logger.Error("failed collecting cache metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
@@ -306,9 +309,11 @@ type perflibCache struct {
|
||||
SyncPinReadsTotal float64 `perflib:"Sync Pin Reads/sec"`
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var dst []perflibCache // Single-instance class, array is required but will have single entry.
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["Cache"], &dst, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ package collector
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/ad"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/adcs"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/adfs"
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/diskdrive"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/dns"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/exchange"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/filetime"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/fsrmquota"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/hyperv"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/iis"
|
||||
@@ -34,16 +35,10 @@ import (
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/msmq"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/mssql"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/net"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrexceptions"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrinterop"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrjit"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrloading"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrlocksandthreads"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrmemory"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrremoting"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrsecurity"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/nps"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/os"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/perfdata"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/physical_disk"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/printer"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/process"
|
||||
@@ -68,7 +63,7 @@ import (
|
||||
)
|
||||
|
||||
// NewWithFlags To be called by the exporter for collector initialization before running kingpin.Parse.
|
||||
func NewWithFlags(app *kingpin.Application) *Collectors {
|
||||
func NewWithFlags(app *kingpin.Application) *MetricCollectors {
|
||||
collectors := map[string]Collector{}
|
||||
|
||||
for name, builder := range BuildersWithFlags {
|
||||
@@ -81,8 +76,8 @@ func NewWithFlags(app *kingpin.Application) *Collectors {
|
||||
// NewWithConfig To be called by the external libraries for collector initialization without running kingpin.Parse
|
||||
//
|
||||
//goland:noinspection GoUnusedExportedFunction
|
||||
func NewWithConfig(config Config) *Collectors {
|
||||
collectors := map[string]Collector{}
|
||||
func NewWithConfig(config Config) *MetricCollectors {
|
||||
collectors := Map{}
|
||||
collectors[ad.Name] = ad.New(&config.AD)
|
||||
collectors[adcs.Name] = adcs.New(&config.ADCS)
|
||||
collectors[adfs.Name] = adfs.New(&config.ADFS)
|
||||
@@ -96,6 +91,7 @@ func NewWithConfig(config Config) *Collectors {
|
||||
collectors[diskdrive.Name] = diskdrive.New(&config.DiskDrive)
|
||||
collectors[dns.Name] = dns.New(&config.DNS)
|
||||
collectors[exchange.Name] = exchange.New(&config.Exchange)
|
||||
collectors[filetime.Name] = filetime.New(&config.Filetime)
|
||||
collectors[fsrmquota.Name] = fsrmquota.New(&config.Fsrmquota)
|
||||
collectors[hyperv.Name] = hyperv.New(&config.Hyperv)
|
||||
collectors[iis.Name] = iis.New(&config.IIS)
|
||||
@@ -107,16 +103,10 @@ func NewWithConfig(config Config) *Collectors {
|
||||
collectors[msmq.Name] = msmq.New(&config.Msmq)
|
||||
collectors[mssql.Name] = mssql.New(&config.Mssql)
|
||||
collectors[net.Name] = net.New(&config.Net)
|
||||
collectors[netframework_clrexceptions.Name] = netframework_clrexceptions.New(&config.NetframeworkClrexceptions)
|
||||
collectors[netframework_clrinterop.Name] = netframework_clrinterop.New(&config.NetframeworkClrinterop)
|
||||
collectors[netframework_clrjit.Name] = netframework_clrjit.New(&config.NetframeworkClrjit)
|
||||
collectors[netframework_clrloading.Name] = netframework_clrloading.New(&config.NetframeworkClrloading)
|
||||
collectors[netframework_clrlocksandthreads.Name] = netframework_clrlocksandthreads.New(&config.NetframeworkClrlocksandthreads)
|
||||
collectors[netframework_clrmemory.Name] = netframework_clrmemory.New(&config.NetframeworkClrmemory)
|
||||
collectors[netframework_clrremoting.Name] = netframework_clrremoting.New(&config.NetframeworkClrremoting)
|
||||
collectors[netframework_clrsecurity.Name] = netframework_clrsecurity.New(&config.NetframeworkClrsecurity)
|
||||
collectors[netframework.Name] = netframework.New(&config.NetFramework)
|
||||
collectors[nps.Name] = nps.New(&config.Nps)
|
||||
collectors[os.Name] = os.New(&config.Os)
|
||||
collectors[perfdata.Name] = perfdata.New(&config.PerfData)
|
||||
collectors[physical_disk.Name] = physical_disk.New(&config.PhysicalDisk)
|
||||
collectors[printer.Name] = printer.New(&config.Printer)
|
||||
collectors[process.Name] = process.New(&config.Process)
|
||||
@@ -140,16 +130,16 @@ func NewWithConfig(config Config) *Collectors {
|
||||
}
|
||||
|
||||
// New To be called by the external libraries for collector initialization.
|
||||
func New(collectors Map) *Collectors {
|
||||
return &Collectors{
|
||||
collectors: collectors,
|
||||
wmiClient: &wmi.Client{
|
||||
func New(collectors Map) *MetricCollectors {
|
||||
return &MetricCollectors{
|
||||
Collectors: collectors,
|
||||
WMIClient: &wmi.Client{
|
||||
AllowMissingFields: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Collectors) SetPerfCounterQuery(logger log.Logger) error {
|
||||
func (c *MetricCollectors) SetPerfCounterQuery(logger *slog.Logger) error {
|
||||
var (
|
||||
err error
|
||||
|
||||
@@ -157,9 +147,9 @@ func (c *Collectors) SetPerfCounterQuery(logger log.Logger) error {
|
||||
perfIndicies []string
|
||||
)
|
||||
|
||||
perfCounterDependencies := make([]string, 0, len(c.collectors))
|
||||
perfCounterDependencies := make([]string, 0, len(c.Collectors))
|
||||
|
||||
for _, collector := range c.collectors {
|
||||
for _, collector := range c.Collectors {
|
||||
perfCounterNames, err = collector.GetPerfCounter(logger)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -173,31 +163,31 @@ func (c *Collectors) SetPerfCounterQuery(logger log.Logger) error {
|
||||
perfCounterDependencies = append(perfCounterDependencies, strings.Join(perfIndicies, " "))
|
||||
}
|
||||
|
||||
c.perfCounterQuery = strings.Join(perfCounterDependencies, " ")
|
||||
c.PerfCounterQuery = strings.Join(perfCounterDependencies, " ")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Enable removes all collectors that not enabledCollectors.
|
||||
func (c *Collectors) Enable(enabledCollectors []string) {
|
||||
for name := range c.collectors {
|
||||
func (c *MetricCollectors) Enable(enabledCollectors []string) {
|
||||
for name := range c.Collectors {
|
||||
if !slices.Contains(enabledCollectors, name) {
|
||||
delete(c.collectors, name)
|
||||
delete(c.Collectors, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build To be called by the exporter for collector initialization.
|
||||
func (c *Collectors) Build(logger log.Logger) error {
|
||||
func (c *MetricCollectors) Build(logger *slog.Logger) error {
|
||||
var err error
|
||||
|
||||
c.wmiClient.SWbemServicesClient, err = wmi.InitializeSWbemServices(c.wmiClient)
|
||||
c.WMIClient.SWbemServicesClient, err = wmi.InitializeSWbemServices(c.WMIClient)
|
||||
if err != nil {
|
||||
return fmt.Errorf("initialize SWbemServices: %w", err)
|
||||
}
|
||||
|
||||
for _, collector := range c.collectors {
|
||||
if err = collector.Build(logger, c.wmiClient); err != nil {
|
||||
for _, collector := range c.Collectors {
|
||||
if err = collector.Build(logger, c.WMIClient); err != nil {
|
||||
return fmt.Errorf("error build collector %s: %w", collector.GetName(), err)
|
||||
}
|
||||
}
|
||||
@@ -206,8 +196,12 @@ func (c *Collectors) Build(logger log.Logger) error {
|
||||
}
|
||||
|
||||
// PrepareScrapeContext creates a ScrapeContext to be used during a single scrape.
|
||||
func (c *Collectors) PrepareScrapeContext() (*types.ScrapeContext, error) {
|
||||
objs, err := perflib.GetPerflibSnapshot(c.perfCounterQuery)
|
||||
func (c *MetricCollectors) PrepareScrapeContext() (*types.ScrapeContext, error) {
|
||||
if c.PerfCounterQuery == "" { // if perfCounterQuery is empty, no perf counters are needed.
|
||||
return &types.ScrapeContext{}, nil
|
||||
}
|
||||
|
||||
objs, err := perflib.GetPerflibSnapshot(c.PerfCounterQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -216,17 +210,17 @@ func (c *Collectors) PrepareScrapeContext() (*types.ScrapeContext, error) {
|
||||
}
|
||||
|
||||
// Close To be called by the exporter for collector cleanup.
|
||||
func (c *Collectors) Close() error {
|
||||
errs := make([]error, 0, len(c.collectors))
|
||||
func (c *MetricCollectors) Close(logger *slog.Logger) error {
|
||||
errs := make([]error, 0, len(c.Collectors))
|
||||
|
||||
for _, collector := range c.collectors {
|
||||
if err := collector.Close(); err != nil {
|
||||
for _, collector := range c.Collectors {
|
||||
if err := collector.Close(logger); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
if c.wmiClient != nil && c.wmiClient.SWbemServicesClient != nil {
|
||||
if err := c.wmiClient.SWbemServicesClient.Close(); err != nil {
|
||||
if c.WMIClient != nil && c.WMIClient.SWbemServicesClient != nil {
|
||||
if err := c.WMIClient.SWbemServicesClient.Close(); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/diskdrive"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/dns"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/exchange"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/filetime"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/fsrmquota"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/hyperv"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/iis"
|
||||
@@ -25,16 +26,10 @@ import (
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/msmq"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/mssql"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/net"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrexceptions"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrinterop"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrjit"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrloading"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrlocksandthreads"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrmemory"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrremoting"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrsecurity"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/nps"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/os"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/perfdata"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/physical_disk"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/printer"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/process"
|
||||
@@ -56,114 +51,104 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
AD ad.Config `yaml:"ad"`
|
||||
ADCS adcs.Config `yaml:"adcs"`
|
||||
ADFS adfs.Config `yaml:"adfs"`
|
||||
Cache cache.Config `yaml:"cache"`
|
||||
Container container.Config `yaml:"container"`
|
||||
CPU cpu.Config `yaml:"cpu"`
|
||||
CPUInfo cpu_info.Config `yaml:"cpu_info"`
|
||||
Cs cs.Config `yaml:"cs"`
|
||||
DFSR dfsr.Config `yaml:"dfsr"`
|
||||
Dhcp dhcp.Config `yaml:"dhcp"`
|
||||
DiskDrive diskdrive.Config `yaml:"diskdrive"` //nolint:tagliatelle
|
||||
DNS dns.Config `yaml:"dns"`
|
||||
Exchange exchange.Config `yaml:"exchange"`
|
||||
Fsrmquota fsrmquota.Config `yaml:"fsrmquota"`
|
||||
Hyperv hyperv.Config `yaml:"hyperv"`
|
||||
IIS iis.Config `yaml:"iis"`
|
||||
License license.Config `yaml:"license"`
|
||||
LogicalDisk logical_disk.Config `yaml:"logical_disk"`
|
||||
Logon logon.Config `yaml:"logon"`
|
||||
Memory memory.Config `yaml:"memory"`
|
||||
Mscluster mscluster.Config `yaml:"mscluster"`
|
||||
Msmq msmq.Config `yaml:"msmq"`
|
||||
Mssql mssql.Config `yaml:"mssql"`
|
||||
Net net.Config `yaml:"net"`
|
||||
NetframeworkClrexceptions netframework_clrexceptions.Config `yaml:"netframework_clrexceptions"`
|
||||
NetframeworkClrinterop netframework_clrinterop.Config `yaml:"netframework_clrinterop"`
|
||||
NetframeworkClrjit netframework_clrjit.Config `yaml:"netframework_clrjit"`
|
||||
NetframeworkClrloading netframework_clrloading.Config `yaml:"netframework_clrloading"`
|
||||
NetframeworkClrlocksandthreads netframework_clrlocksandthreads.Config `yaml:"netframework_clrlocksandthreads"`
|
||||
NetframeworkClrmemory netframework_clrmemory.Config `yaml:"netframework_clrmemory"`
|
||||
NetframeworkClrremoting netframework_clrremoting.Config `yaml:"netframework_clrremoting"`
|
||||
NetframeworkClrsecurity netframework_clrsecurity.Config `yaml:"netframework_clrsecurity"`
|
||||
Nps nps.Config `yaml:"nps"`
|
||||
Os os.Config `yaml:"os"`
|
||||
PhysicalDisk physical_disk.Config `yaml:"physical_disk"`
|
||||
Printer printer.Config `yaml:"printer"`
|
||||
Process process.Config `yaml:"process"`
|
||||
RemoteFx remote_fx.Config `yaml:"remote_fx"`
|
||||
ScheduledTask scheduled_task.Config `yaml:"scheduled_task"`
|
||||
Service service.Config `yaml:"service"`
|
||||
SMB smb.Config `yaml:"smb"`
|
||||
SMBClient smbclient.Config `yaml:"smbclient"` //nolint:tagliatelle
|
||||
SMTP smtp.Config `yaml:"smtp"`
|
||||
System system.Config `yaml:"system"`
|
||||
TeradiciPcoip teradici_pcoip.Config `yaml:"teradici_pcoip"`
|
||||
TCP tcp.Config `yaml:"tcp"`
|
||||
TerminalServices terminal_services.Config `yaml:"terminal_services"`
|
||||
Textfile textfile.Config `yaml:"textfile"`
|
||||
Thermalzone thermalzone.Config `yaml:"thermalzone"`
|
||||
Time time.Config `yaml:"time"`
|
||||
Vmware vmware.Config `yaml:"vmware"`
|
||||
VmwareBlast vmware_blast.Config `yaml:"vmware_blast"`
|
||||
AD ad.Config `yaml:"ad"`
|
||||
ADCS adcs.Config `yaml:"adcs"`
|
||||
ADFS adfs.Config `yaml:"adfs"`
|
||||
Cache cache.Config `yaml:"cache"`
|
||||
Container container.Config `yaml:"container"`
|
||||
CPU cpu.Config `yaml:"cpu"`
|
||||
CPUInfo cpu_info.Config `yaml:"cpu_info"`
|
||||
Cs cs.Config `yaml:"cs"`
|
||||
DFSR dfsr.Config `yaml:"dfsr"`
|
||||
Dhcp dhcp.Config `yaml:"dhcp"`
|
||||
DiskDrive diskdrive.Config `yaml:"diskdrive"` //nolint:tagliatelle
|
||||
DNS dns.Config `yaml:"dns"`
|
||||
Exchange exchange.Config `yaml:"exchange"`
|
||||
Filetime filetime.Config `yaml:"filetime"`
|
||||
Fsrmquota fsrmquota.Config `yaml:"fsrmquota"`
|
||||
Hyperv hyperv.Config `yaml:"hyperv"`
|
||||
IIS iis.Config `yaml:"iis"`
|
||||
License license.Config `yaml:"license"`
|
||||
LogicalDisk logical_disk.Config `yaml:"logical_disk"`
|
||||
Logon logon.Config `yaml:"logon"`
|
||||
Memory memory.Config `yaml:"memory"`
|
||||
Mscluster mscluster.Config `yaml:"mscluster"`
|
||||
Msmq msmq.Config `yaml:"msmq"`
|
||||
Mssql mssql.Config `yaml:"mssql"`
|
||||
Net net.Config `yaml:"net"`
|
||||
NetFramework netframework.Config `yaml:"net_framework"`
|
||||
Nps nps.Config `yaml:"nps"`
|
||||
Os os.Config `yaml:"os"`
|
||||
PerfData perfdata.Config `yaml:"perf_data"`
|
||||
PhysicalDisk physical_disk.Config `yaml:"physical_disk"`
|
||||
Printer printer.Config `yaml:"printer"`
|
||||
Process process.Config `yaml:"process"`
|
||||
RemoteFx remote_fx.Config `yaml:"remote_fx"`
|
||||
ScheduledTask scheduled_task.Config `yaml:"scheduled_task"`
|
||||
Service service.Config `yaml:"service"`
|
||||
SMB smb.Config `yaml:"smb"`
|
||||
SMBClient smbclient.Config `yaml:"smbclient"` //nolint:tagliatelle
|
||||
SMTP smtp.Config `yaml:"smtp"`
|
||||
System system.Config `yaml:"system"`
|
||||
TeradiciPcoip teradici_pcoip.Config `yaml:"teradici_pcoip"`
|
||||
TCP tcp.Config `yaml:"tcp"`
|
||||
TerminalServices terminal_services.Config `yaml:"terminal_services"`
|
||||
Textfile textfile.Config `yaml:"textfile"`
|
||||
Thermalzone thermalzone.Config `yaml:"thermalzone"`
|
||||
Time time.Config `yaml:"time"`
|
||||
Vmware vmware.Config `yaml:"vmware"`
|
||||
VmwareBlast vmware_blast.Config `yaml:"vmware_blast"`
|
||||
}
|
||||
|
||||
// ConfigDefaults Is an interface to be used by the external libraries. It holds all ConfigDefaults form all collectors
|
||||
//
|
||||
//goland:noinspection GoUnusedGlobalVariable
|
||||
var ConfigDefaults = Config{
|
||||
AD: ad.ConfigDefaults,
|
||||
ADCS: adcs.ConfigDefaults,
|
||||
ADFS: adfs.ConfigDefaults,
|
||||
Cache: cache.ConfigDefaults,
|
||||
Container: container.ConfigDefaults,
|
||||
CPU: cpu.ConfigDefaults,
|
||||
CPUInfo: cpu_info.ConfigDefaults,
|
||||
Cs: cs.ConfigDefaults,
|
||||
DFSR: dfsr.ConfigDefaults,
|
||||
Dhcp: dhcp.ConfigDefaults,
|
||||
DiskDrive: diskdrive.ConfigDefaults,
|
||||
DNS: dns.ConfigDefaults,
|
||||
Exchange: exchange.ConfigDefaults,
|
||||
Fsrmquota: fsrmquota.ConfigDefaults,
|
||||
Hyperv: hyperv.ConfigDefaults,
|
||||
IIS: iis.ConfigDefaults,
|
||||
License: license.ConfigDefaults,
|
||||
LogicalDisk: logical_disk.ConfigDefaults,
|
||||
Logon: logon.ConfigDefaults,
|
||||
Memory: memory.ConfigDefaults,
|
||||
Mscluster: mscluster.ConfigDefaults,
|
||||
Msmq: msmq.ConfigDefaults,
|
||||
Mssql: mssql.ConfigDefaults,
|
||||
Net: net.ConfigDefaults,
|
||||
NetframeworkClrexceptions: netframework_clrexceptions.ConfigDefaults,
|
||||
NetframeworkClrinterop: netframework_clrinterop.ConfigDefaults,
|
||||
NetframeworkClrjit: netframework_clrjit.ConfigDefaults,
|
||||
NetframeworkClrloading: netframework_clrloading.ConfigDefaults,
|
||||
NetframeworkClrlocksandthreads: netframework_clrlocksandthreads.ConfigDefaults,
|
||||
NetframeworkClrmemory: netframework_clrmemory.ConfigDefaults,
|
||||
NetframeworkClrremoting: netframework_clrremoting.ConfigDefaults,
|
||||
NetframeworkClrsecurity: netframework_clrsecurity.ConfigDefaults,
|
||||
Nps: nps.ConfigDefaults,
|
||||
Os: os.ConfigDefaults,
|
||||
PhysicalDisk: physical_disk.ConfigDefaults,
|
||||
Printer: printer.ConfigDefaults,
|
||||
Process: process.ConfigDefaults,
|
||||
RemoteFx: remote_fx.ConfigDefaults,
|
||||
ScheduledTask: scheduled_task.ConfigDefaults,
|
||||
Service: service.ConfigDefaults,
|
||||
SMB: smb.ConfigDefaults,
|
||||
SMBClient: smbclient.ConfigDefaults,
|
||||
SMTP: smtp.ConfigDefaults,
|
||||
System: system.ConfigDefaults,
|
||||
TeradiciPcoip: teradici_pcoip.ConfigDefaults,
|
||||
TCP: tcp.ConfigDefaults,
|
||||
TerminalServices: terminal_services.ConfigDefaults,
|
||||
Textfile: textfile.ConfigDefaults,
|
||||
Thermalzone: thermalzone.ConfigDefaults,
|
||||
Time: time.ConfigDefaults,
|
||||
Vmware: vmware.ConfigDefaults,
|
||||
VmwareBlast: vmware_blast.ConfigDefaults,
|
||||
AD: ad.ConfigDefaults,
|
||||
ADCS: adcs.ConfigDefaults,
|
||||
ADFS: adfs.ConfigDefaults,
|
||||
Cache: cache.ConfigDefaults,
|
||||
Container: container.ConfigDefaults,
|
||||
CPU: cpu.ConfigDefaults,
|
||||
CPUInfo: cpu_info.ConfigDefaults,
|
||||
Cs: cs.ConfigDefaults,
|
||||
DFSR: dfsr.ConfigDefaults,
|
||||
Dhcp: dhcp.ConfigDefaults,
|
||||
DiskDrive: diskdrive.ConfigDefaults,
|
||||
DNS: dns.ConfigDefaults,
|
||||
Exchange: exchange.ConfigDefaults,
|
||||
Filetime: filetime.ConfigDefaults,
|
||||
Fsrmquota: fsrmquota.ConfigDefaults,
|
||||
Hyperv: hyperv.ConfigDefaults,
|
||||
IIS: iis.ConfigDefaults,
|
||||
License: license.ConfigDefaults,
|
||||
LogicalDisk: logical_disk.ConfigDefaults,
|
||||
Logon: logon.ConfigDefaults,
|
||||
Memory: memory.ConfigDefaults,
|
||||
Mscluster: mscluster.ConfigDefaults,
|
||||
Msmq: msmq.ConfigDefaults,
|
||||
Mssql: mssql.ConfigDefaults,
|
||||
Net: net.ConfigDefaults,
|
||||
NetFramework: netframework.ConfigDefaults,
|
||||
Nps: nps.ConfigDefaults,
|
||||
Os: os.ConfigDefaults,
|
||||
PerfData: perfdata.ConfigDefaults,
|
||||
PhysicalDisk: physical_disk.ConfigDefaults,
|
||||
Printer: printer.ConfigDefaults,
|
||||
Process: process.ConfigDefaults,
|
||||
RemoteFx: remote_fx.ConfigDefaults,
|
||||
ScheduledTask: scheduled_task.ConfigDefaults,
|
||||
Service: service.ConfigDefaults,
|
||||
SMB: smb.ConfigDefaults,
|
||||
SMBClient: smbclient.ConfigDefaults,
|
||||
SMTP: smtp.ConfigDefaults,
|
||||
System: system.ConfigDefaults,
|
||||
TeradiciPcoip: teradici_pcoip.ConfigDefaults,
|
||||
TCP: tcp.ConfigDefaults,
|
||||
TerminalServices: terminal_services.ConfigDefaults,
|
||||
Textfile: textfile.ConfigDefaults,
|
||||
Thermalzone: thermalzone.ConfigDefaults,
|
||||
Time: time.ConfigDefaults,
|
||||
Vmware: vmware.ConfigDefaults,
|
||||
VmwareBlast: vmware_blast.ConfigDefaults,
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
package container
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"github.com/Microsoft/hcsshim"
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -77,15 +78,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
c.containerAvailable = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "available"),
|
||||
"Available",
|
||||
@@ -194,33 +195,33 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
[]string{"container_id"},
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting collector metrics", "err", err)
|
||||
logger.Error("failed collecting collector metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// containerClose closes the container resource.
|
||||
func (c *Collector) containerClose(logger log.Logger, container hcsshim.Container) {
|
||||
err := container.Close()
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("err", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Collector) collect(logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collect(logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
// Types Container is passed to get the containers compute systems only
|
||||
containers, err := hcsshim.GetContainers(hcsshim.ComputeSystemQuery{Types: []string{"Container"}})
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("msg", "Err in Getting containers", "err", err)
|
||||
logger.Error("Err in Getting containers",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -231,129 +232,181 @@ func (c *Collector) collect(logger log.Logger, ch chan<- prometheus.Metric) erro
|
||||
prometheus.GaugeValue,
|
||||
float64(count),
|
||||
)
|
||||
|
||||
if count == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
containerPrefixes := make(map[string]string)
|
||||
collectErrors := make([]error, 0, len(containers))
|
||||
|
||||
for _, containerDetails := range containers {
|
||||
// https://stackoverflow.com/questions/45617758/proper-way-to-release-resources-with-defer-in-a-loop
|
||||
func() {
|
||||
container, err := hcsshim.OpenContainer(containerDetails.ID)
|
||||
if container != nil {
|
||||
defer c.containerClose(logger, container)
|
||||
}
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("msg", "err in opening container", "containerId", containerDetails.ID, "err", err)
|
||||
return
|
||||
containerIdWithPrefix := getContainerIdWithPrefix(containerDetails)
|
||||
|
||||
if err = c.collectContainer(logger, ch, containerDetails, containerIdWithPrefix); err != nil {
|
||||
if hcsshim.IsNotExist(err) {
|
||||
logger.Debug("err in fetching container statistics",
|
||||
slog.String("container_id", containerDetails.ID),
|
||||
slog.Any("err", err),
|
||||
)
|
||||
} else {
|
||||
logger.Error("err in fetching container statistics",
|
||||
slog.String("container_id", containerDetails.ID),
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
collectErrors = append(collectErrors, err)
|
||||
}
|
||||
|
||||
cstats, err := container.Statistics()
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("msg", "err in fetching container Statistics", "containerId", containerDetails.ID, "err", err)
|
||||
return
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
containerIdWithPrefix := getContainerIdWithPrefix(containerDetails)
|
||||
containerPrefixes[containerDetails.ID] = containerIdWithPrefix
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.containerAvailable,
|
||||
prometheus.CounterValue,
|
||||
1,
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usageCommitBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(cstats.Memory.UsageCommitBytes),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usageCommitPeakBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(cstats.Memory.UsageCommitPeakBytes),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usagePrivateWorkingSetBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(cstats.Memory.UsagePrivateWorkingSetBytes),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeTotal,
|
||||
prometheus.CounterValue,
|
||||
float64(cstats.Processor.TotalRuntime100ns)*perflib.TicksToSecondScaleFactor,
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeUser,
|
||||
prometheus.CounterValue,
|
||||
float64(cstats.Processor.RuntimeUser100ns)*perflib.TicksToSecondScaleFactor,
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeKernel,
|
||||
prometheus.CounterValue,
|
||||
float64(cstats.Processor.RuntimeKernel100ns)*perflib.TicksToSecondScaleFactor,
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readCountNormalized,
|
||||
prometheus.CounterValue,
|
||||
float64(cstats.Storage.ReadCountNormalized),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readSizeBytes,
|
||||
prometheus.CounterValue,
|
||||
float64(cstats.Storage.ReadSizeBytes),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeCountNormalized,
|
||||
prometheus.CounterValue,
|
||||
float64(cstats.Storage.WriteCountNormalized),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeSizeBytes,
|
||||
prometheus.CounterValue,
|
||||
float64(cstats.Storage.WriteSizeBytes),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
}()
|
||||
containerPrefixes[containerDetails.ID] = containerIdWithPrefix
|
||||
}
|
||||
|
||||
if err = c.collectNetworkMetrics(logger, ch, containerPrefixes); err != nil {
|
||||
return fmt.Errorf("error in fetching container network statistics: %w", err)
|
||||
}
|
||||
|
||||
if len(collectErrors) > 0 {
|
||||
return fmt.Errorf("errors while fetching container statistics: %w", errors.Join(collectErrors...))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collectContainer(logger *slog.Logger, ch chan<- prometheus.Metric, containerDetails hcsshim.ContainerProperties, containerIdWithPrefix string) error {
|
||||
container, err := hcsshim.OpenContainer(containerDetails.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error in opening container: %w", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if container == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err := container.Close(); err != nil {
|
||||
logger.Error("error in closing container",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
}()
|
||||
|
||||
containerStats, err := container.Statistics()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error in fetching container statistics: %w", err)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.containerAvailable,
|
||||
prometheus.CounterValue,
|
||||
1,
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usageCommitBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(containerStats.Memory.UsageCommitBytes),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usageCommitPeakBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(containerStats.Memory.UsageCommitPeakBytes),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usagePrivateWorkingSetBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(containerStats.Memory.UsagePrivateWorkingSetBytes),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeTotal,
|
||||
prometheus.CounterValue,
|
||||
float64(containerStats.Processor.TotalRuntime100ns)*perflib.TicksToSecondScaleFactor,
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeUser,
|
||||
prometheus.CounterValue,
|
||||
float64(containerStats.Processor.RuntimeUser100ns)*perflib.TicksToSecondScaleFactor,
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeKernel,
|
||||
prometheus.CounterValue,
|
||||
float64(containerStats.Processor.RuntimeKernel100ns)*perflib.TicksToSecondScaleFactor,
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readCountNormalized,
|
||||
prometheus.CounterValue,
|
||||
float64(containerStats.Storage.ReadCountNormalized),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readSizeBytes,
|
||||
prometheus.CounterValue,
|
||||
float64(containerStats.Storage.ReadSizeBytes),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeCountNormalized,
|
||||
prometheus.CounterValue,
|
||||
float64(containerStats.Storage.WriteCountNormalized),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeSizeBytes,
|
||||
prometheus.CounterValue,
|
||||
float64(containerStats.Storage.WriteSizeBytes),
|
||||
containerIdWithPrefix,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// collectNetworkMetrics collects network metrics for containers.
|
||||
// With HNSv2, the network stats must be collected from hcsshim.HNSListEndpointRequest.
|
||||
// Network statistics from the container.Statistics() are providing data only, if HNSv1 is used.
|
||||
// Ref: https://github.com/prometheus-community/windows_exporter/pull/1218
|
||||
func (c *Collector) collectNetworkMetrics(logger *slog.Logger, ch chan<- prometheus.Metric, containerPrefixes map[string]string) error {
|
||||
hnsEndpoints, err := hcsshim.HNSListEndpointRequest()
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Failed to collect network stats for containers")
|
||||
logger.Warn("Failed to collect network stats for containers")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if len(hnsEndpoints) == 0 {
|
||||
_ = level.Info(logger).Log("msg", "No network stats for containers to collect")
|
||||
logger.Info("No network stats for containers to collect")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, endpoint := range hnsEndpoints {
|
||||
endpointStats, err := hcsshim.GetHNSEndpointStats(endpoint.Id)
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Failed to collect network stats for interface "+endpoint.Id, "err", err)
|
||||
logger.Warn("Failed to collect network stats for interface "+endpoint.Id,
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
for _, containerId := range endpoint.SharedContainers {
|
||||
containerIdWithPrefix, ok := containerPrefixes[containerId]
|
||||
endpointId := strings.ToUpper(endpoint.Id)
|
||||
|
||||
if !ok {
|
||||
_ = level.Warn(logger).Log("msg", "Failed to collect network stats for container "+containerId)
|
||||
logger.Debug("Failed to collect network stats for container " + containerId)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
endpointId := strings.ToUpper(endpoint.Id)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bytesReceived,
|
||||
prometheus.CounterValue,
|
||||
|
||||
28
pkg/collector/cpu/const.go
Normal file
28
pkg/collector/cpu/const.go
Normal file
@@ -0,0 +1,28 @@
|
||||
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"
|
||||
DPCsQueuedTotal = "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"
|
||||
)
|
||||
@@ -3,13 +3,15 @@
|
||||
package cpu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perfdata"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/winversion"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
@@ -23,6 +25,9 @@ var ConfigDefaults = Config{}
|
||||
type Collector struct {
|
||||
config Config
|
||||
|
||||
perfDataCollector *perfdata.Collector
|
||||
|
||||
logicalProcessors *prometheus.Desc
|
||||
cStateSecondsTotal *prometheus.Desc
|
||||
timeTotal *prometheus.Desc
|
||||
interruptsTotal *prometheus.Desc
|
||||
@@ -58,18 +63,61 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
if winversion.WindowsVersionFloat() > 6.05 {
|
||||
return []string{"Processor Information"}, nil
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
if utils.PDHEnabled() {
|
||||
return []string{}, nil
|
||||
}
|
||||
return []string{"Processor"}, nil
|
||||
|
||||
return []string{"Processor Information"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
if utils.PDHEnabled() {
|
||||
counters := []string{
|
||||
C1TimeSeconds,
|
||||
C2TimeSeconds,
|
||||
C3TimeSeconds,
|
||||
C1TransitionsTotal,
|
||||
C2TransitionsTotal,
|
||||
C3TransitionsTotal,
|
||||
ClockInterruptsTotal,
|
||||
DPCsQueuedTotal,
|
||||
DPCTimeSeconds,
|
||||
IdleBreakEventsTotal,
|
||||
IdleTimeSeconds,
|
||||
InterruptsTotal,
|
||||
InterruptTimeSeconds,
|
||||
ParkingStatus,
|
||||
PerformanceLimitPercent,
|
||||
PriorityTimeSeconds,
|
||||
PrivilegedTimeSeconds,
|
||||
PrivilegedUtilitySeconds,
|
||||
ProcessorFrequencyMHz,
|
||||
ProcessorPerformance,
|
||||
ProcessorTimeSeconds,
|
||||
ProcessorUtilityRate,
|
||||
UserTimeSeconds,
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
c.perfDataCollector, err = perfdata.NewCollector("Processor Information", []string{"*"}, counters)
|
||||
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",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
c.cStateSecondsTotal = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "cstate_seconds_total"),
|
||||
"Time spent in low-power idle state",
|
||||
@@ -95,16 +143,6 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
nil,
|
||||
)
|
||||
|
||||
// For Windows 2008 (version 6.0) or earlier we only have the "Processor"
|
||||
// class. As of Windows 2008 R2 (version 6.1) the more detailed
|
||||
// "Processor Information" set is available (although some of the counters
|
||||
// are added in later versions, so we aren't guaranteed to get all of
|
||||
// them).
|
||||
// Value 6.05 was selected to split between Windows versions.
|
||||
if winversion.WindowsVersionFloat() < 6.05 {
|
||||
return nil
|
||||
}
|
||||
|
||||
c.cStateSecondsTotal = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "cstate_seconds_total"),
|
||||
"Time spent in low-power idle state",
|
||||
@@ -187,113 +225,14 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if winversion.WindowsVersionFloat() > 6.05 {
|
||||
return c.CollectFull(ctx, logger, ch)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
if utils.PDHEnabled() {
|
||||
return c.collectPDH(ch)
|
||||
}
|
||||
|
||||
return c.CollectBasic(ctx, logger, ch)
|
||||
}
|
||||
|
||||
type perflibProcessor struct {
|
||||
Name string
|
||||
C1Transitions float64 `perflib:"C1 Transitions/sec"`
|
||||
C2Transitions float64 `perflib:"C2 Transitions/sec"`
|
||||
C3Transitions float64 `perflib:"C3 Transitions/sec"`
|
||||
DPCRate float64 `perflib:"DPC Rate"`
|
||||
DPCsQueued float64 `perflib:"DPCs Queued/sec"`
|
||||
Interrupts float64 `perflib:"Interrupts/sec"`
|
||||
PercentC1Time float64 `perflib:"% C1 Time"`
|
||||
PercentC2Time float64 `perflib:"% C2 Time"`
|
||||
PercentC3Time float64 `perflib:"% C3 Time"`
|
||||
PercentDPCTime float64 `perflib:"% DPC Time"`
|
||||
PercentIdleTime float64 `perflib:"% Idle Time"`
|
||||
PercentInterruptTime float64 `perflib:"% Interrupt Time"`
|
||||
PercentPrivilegedTime float64 `perflib:"% Privileged Time"`
|
||||
PercentProcessorTime float64 `perflib:"% Processor Time"`
|
||||
PercentUserTime float64 `perflib:"% User Time"`
|
||||
}
|
||||
|
||||
func (c *Collector) CollectBasic(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
data := make([]perflibProcessor, 0)
|
||||
err := perflib.UnmarshalObject(ctx.PerfObjects["Processor"], &data, logger)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, cpu := range data {
|
||||
if strings.Contains(strings.ToLower(cpu.Name), "_total") {
|
||||
continue
|
||||
}
|
||||
core := cpu.Name
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
cpu.PercentC1Time,
|
||||
core, "c1",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
cpu.PercentC2Time,
|
||||
core, "c2",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
cpu.PercentC3Time,
|
||||
core, "c3",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
cpu.PercentIdleTime,
|
||||
core, "idle",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
cpu.PercentInterruptTime,
|
||||
core, "interrupt",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
cpu.PercentDPCTime,
|
||||
core, "dpc",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
cpu.PercentPrivilegedTime,
|
||||
core, "privileged",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
cpu.PercentUserTime,
|
||||
core, "user",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.interruptsTotal,
|
||||
prometheus.CounterValue,
|
||||
cpu.Interrupts,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.dpcsTotal,
|
||||
prometheus.CounterValue,
|
||||
cpu.DPCsQueued,
|
||||
core,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
return c.collectFull(ctx, logger, ch)
|
||||
}
|
||||
|
||||
type perflibProcessorInformation struct {
|
||||
@@ -325,20 +264,25 @@ type perflibProcessorInformation struct {
|
||||
UserTimeSeconds float64 `perflib:"% User Time"`
|
||||
}
|
||||
|
||||
func (c *Collector) CollectFull(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectFull(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
data := make([]perflibProcessorInformation, 0)
|
||||
|
||||
err := perflib.UnmarshalObject(ctx.PerfObjects["Processor Information"], &data, logger)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var coreCount float64
|
||||
|
||||
for _, cpu := range data {
|
||||
if strings.Contains(strings.ToLower(cpu.Name), "_total") {
|
||||
continue
|
||||
}
|
||||
|
||||
core := cpu.Name
|
||||
|
||||
coreCount++
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -459,5 +403,151 @@ func (c *Collector) CollectFull(ctx *types.ScrapeContext, logger log.Logger, ch
|
||||
)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.logicalProcessors,
|
||||
prometheus.GaugeValue,
|
||||
coreCount,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
|
||||
data, err := c.perfDataCollector.Collect()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect Processor Information metrics: %w", err)
|
||||
}
|
||||
|
||||
var coreCount float64
|
||||
|
||||
for core, coreData := range data {
|
||||
coreCount++
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[C1TimeSeconds].FirstValue,
|
||||
core, "c1",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[C2TimeSeconds].FirstValue,
|
||||
core, "c2",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[C3TimeSeconds].FirstValue,
|
||||
core, "c3",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[IdleTimeSeconds].FirstValue,
|
||||
core, "idle",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[InterruptTimeSeconds].FirstValue,
|
||||
core, "interrupt",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[DPCTimeSeconds].FirstValue,
|
||||
core, "dpc",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[PrivilegedTimeSeconds].FirstValue,
|
||||
core, "privileged",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[UserTimeSeconds].FirstValue,
|
||||
core, "user",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.interruptsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[InterruptsTotal].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.dpcsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[DPCsQueuedTotal].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.clockInterruptsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[ClockInterruptsTotal].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.idleBreakEventsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[IdleBreakEventsTotal].FirstValue,
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.parkingStatus,
|
||||
prometheus.GaugeValue,
|
||||
coreData[ParkingStatus].FirstValue,
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorFrequencyMHz,
|
||||
prometheus.GaugeValue,
|
||||
coreData[ProcessorFrequencyMHz].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorPerformance,
|
||||
prometheus.CounterValue,
|
||||
coreData[ProcessorPerformance].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorMPerf,
|
||||
prometheus.CounterValue,
|
||||
coreData[ProcessorPerformance].SecondValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorRTC,
|
||||
prometheus.CounterValue,
|
||||
coreData[ProcessorUtilityRate].SecondValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorUtility,
|
||||
prometheus.CounterValue,
|
||||
coreData[ProcessorUtilityRate].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorPrivilegedUtility,
|
||||
prometheus.CounterValue,
|
||||
coreData[PrivilegedUtilitySeconds].FirstValue,
|
||||
core,
|
||||
)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.logicalProcessors,
|
||||
prometheus.GaugeValue,
|
||||
coreCount,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -4,12 +4,11 @@ package cpu_info
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
@@ -58,15 +57,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
@@ -152,12 +151,16 @@ type win32Processor struct {
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting cpu_info metrics", "err", err)
|
||||
logger.Error("failed collecting cpu_info metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -169,6 +172,7 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
if err := c.wmiClient.Query("SELECT Architecture, DeviceId, Description, Family, L2CacheSize, L3CacheSize, Name, ThreadCount, NumberOfCores, NumberOfEnabledCore, NumberOfLogicalProcessors FROM Win32_Processor", &dst); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(dst) == 0 {
|
||||
return errors.New("WMI query returned empty result set")
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
package cs
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/headers/sysinfoapi"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -22,9 +22,15 @@ var ConfigDefaults = Config{}
|
||||
type Collector struct {
|
||||
config Config
|
||||
|
||||
// physicalMemoryBytes
|
||||
// Deprecated: Use windows_cpu_logical_processor instead
|
||||
physicalMemoryBytes *prometheus.Desc
|
||||
logicalProcessors *prometheus.Desc
|
||||
hostname *prometheus.Desc
|
||||
// logicalProcessors
|
||||
// Deprecated: Use windows_physical_memory_total_bytes instead
|
||||
logicalProcessors *prometheus.Desc
|
||||
// hostname
|
||||
// Deprecated: Use windows_os_hostname instead
|
||||
hostname *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
@@ -47,30 +53,35 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(logger *slog.Logger, _ *wmi.Client) error {
|
||||
logger.Warn("The cs collector is deprecated and will be removed in a future release. " +
|
||||
"Logical processors has been moved to cpu_info collector. " +
|
||||
"Physical memory has been moved to memory collector. " +
|
||||
"Hostname has been moved to os collector.")
|
||||
|
||||
c.logicalProcessors = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "logical_processors"),
|
||||
"ComputerSystem.NumberOfLogicalProcessors",
|
||||
"Deprecated: Use windows_cpu_logical_processor instead",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.physicalMemoryBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "physical_memory_bytes"),
|
||||
"ComputerSystem.TotalPhysicalMemory",
|
||||
"Deprecated: Use windows_physical_memory_total_bytes instead",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.hostname = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "hostname"),
|
||||
"Labelled system hostname information as provided by ComputerSystem.DNSHostName and ComputerSystem.Domain",
|
||||
"Deprecated: Use windows_os_hostname instead",
|
||||
[]string{
|
||||
"hostname",
|
||||
"domain",
|
||||
@@ -78,17 +89,23 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
},
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting cs metrics", "err", err)
|
||||
logger.Error("failed collecting cs metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -118,10 +135,12 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
domain, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSDomain)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fqdn, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSFullyQualified)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
package dfsr
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -80,13 +79,14 @@ type Collector struct {
|
||||
dfsrChildCollectors []dfsrCollectorFunc
|
||||
}
|
||||
|
||||
type dfsrCollectorFunc func(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error
|
||||
type dfsrCollectorFunc func(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error
|
||||
|
||||
// Map Perflib sources to DFSR Collector names
|
||||
// e.g, volume -> DFS Replication Service Volumes.
|
||||
func dfsrGetPerfObjectName(collector string) string {
|
||||
prefix := "DFS "
|
||||
suffix := ""
|
||||
|
||||
switch collector {
|
||||
case "connection":
|
||||
suffix = "Replication Connections"
|
||||
@@ -95,6 +95,7 @@ func dfsrGetPerfObjectName(collector string) string {
|
||||
case "volume":
|
||||
suffix = "Replication Service Volumes"
|
||||
}
|
||||
|
||||
return prefix + suffix
|
||||
}
|
||||
|
||||
@@ -137,7 +138,7 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
// Perflib sources are dynamic, depending on the enabled child collectors
|
||||
expandedChildCollectors := slices.Compact(c.config.CollectorsEnabled)
|
||||
perflibDependencies := make([]string, 0, len(expandedChildCollectors))
|
||||
@@ -149,14 +150,14 @@ func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
return perflibDependencies, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(logger log.Logger, _ *wmi.Client) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Build(logger *slog.Logger, _ *wmi.Client) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
_ = level.Info(logger).Log("msg", "dfsr collector is in an experimental state! Metrics for this collector have not been tested.")
|
||||
logger.Info("dfsr collector is in an experimental state! Metrics for this collector have not been tested.")
|
||||
|
||||
// connection
|
||||
c.connectionBandwidthSavingsUsingDFSReplicationTotal = prometheus.NewDesc(
|
||||
@@ -459,6 +460,7 @@ func (c *Collector) Build(logger log.Logger, _ *wmi.Client) error {
|
||||
// for use in Collector.Collect().
|
||||
func (c *Collector) getDFSRChildCollectors(enabledCollectors []string) []dfsrCollectorFunc {
|
||||
var dfsrCollectors []dfsrCollectorFunc
|
||||
|
||||
for _, collector := range enabledCollectors {
|
||||
switch collector {
|
||||
case "connection":
|
||||
@@ -475,14 +477,15 @@ func (c *Collector) getDFSRChildCollectors(enabledCollectors []string) []dfsrCol
|
||||
|
||||
// Collect implements the Collector interface.
|
||||
// Sends metric values for each metric to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
for _, fn := range c.dfsrChildCollectors {
|
||||
err := fn(ctx, logger, ch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -501,9 +504,11 @@ type PerflibDFSRConnection struct {
|
||||
SizeOfFilesReceivedTotal float64 `perflib:"Size of Files Received"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectConnection(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectConnection(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var dst []PerflibDFSRConnection
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["DFS Replication Connections"], &dst, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -572,6 +577,7 @@ func (c *Collector) collectConnection(ctx *types.ScrapeContext, logger log.Logge
|
||||
connection.Name,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -608,9 +614,11 @@ type perflibDFSRFolder struct {
|
||||
UpdatesDroppedTotal float64 `perflib:"Updates Dropped"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectFolder(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectFolder(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var dst []perflibDFSRFolder
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["DFS Replicated Folders"], &dst, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -805,6 +813,7 @@ func (c *Collector) collectFolder(ctx *types.ScrapeContext, logger log.Logger, c
|
||||
folder.Name,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -819,10 +828,12 @@ type perflibDFSRVolume struct {
|
||||
USNJournalUnreadPercentage float64 `perflib:"USN Journal Records Unread Percentage"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectVolume(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectVolume(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var dst []perflibDFSRVolume
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["DFS Replication Service volumes"], &dst, logger); err != nil {
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["DFS Replication Service Volumes"], &dst, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -862,5 +873,6 @@ func (c *Collector) collectVolume(ctx *types.ScrapeContext, logger log.Logger, c
|
||||
volume.Name,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
package dhcp
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -68,15 +69,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"DHCP Server"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
c.packetsReceivedTotal = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "packets_received_total"),
|
||||
"Total number of packets received by the DHCP server (PacketsReceivedTotal)",
|
||||
@@ -227,6 +228,7 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -261,9 +263,11 @@ type dhcpPerf struct {
|
||||
FailoverBndupdDropped float64 `perflib:"Failover: BndUpd Dropped."`
|
||||
}
|
||||
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var dhcpPerfs []dhcpPerf
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["DHCP Server"], &dhcpPerfs, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@ package diskdrive
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
@@ -55,15 +54,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
@@ -161,12 +160,16 @@ var (
|
||||
)
|
||||
|
||||
// Collect sends the metric values for each metric to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting disk_drive_info metrics", "err", err)
|
||||
logger.Error("failed collecting disk_drive_info metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -176,6 +179,7 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
if err := c.wmiClient.Query(win32DiskQuery, &dst); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(dst) == 0 {
|
||||
return errors.New("WMI query returned empty result set")
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@ package dns
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
@@ -68,15 +67,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
@@ -215,17 +214,22 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting dns metrics", "err", err)
|
||||
logger.Error("failed collecting dns metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -280,6 +284,7 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_DNS_DNS", &dst); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(dst) == 0 {
|
||||
return errors.New("WMI query returned empty result set")
|
||||
}
|
||||
|
||||
@@ -4,12 +4,11 @@ package exchange
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -103,6 +102,7 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
||||
c.config.CollectorsEnabled = make([]string, 0)
|
||||
|
||||
var listAllCollectors bool
|
||||
|
||||
var collectorsEnabled string
|
||||
|
||||
app.Flag(
|
||||
@@ -158,7 +158,7 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{
|
||||
"MSExchange ADAccess Processes",
|
||||
"MSExchangeTransport Queues",
|
||||
@@ -173,11 +173,11 @@ func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
// desc creates a new prometheus description
|
||||
desc := func(metricName string, description string, labels ...string) *prometheus.Desc {
|
||||
return prometheus.NewDesc(
|
||||
@@ -231,9 +231,9 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
}
|
||||
|
||||
// Collect collects exchange metrics and sends them to prometheus.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
collectorFuncs := map[string]func(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error{
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
collectorFuncs := map[string]func(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error{
|
||||
"ADAccessProcesses": c.collectADAccessProcesses,
|
||||
"TransportQueues": c.collectTransportQueues,
|
||||
"HttpProxy": c.collectHTTPProxy,
|
||||
@@ -248,10 +248,14 @@ func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
|
||||
for _, collectorName := range c.config.CollectorsEnabled {
|
||||
if err := collectorFuncs[collectorName](ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "Error in "+collectorName, "err", err)
|
||||
logger.Error("Error in "+collectorName,
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -266,14 +270,17 @@ type perflibADAccessProcesses struct {
|
||||
LongRunningLDAPOperationsPerMin float64 `perflib:"Long Running LDAP Operations/min"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectADAccessProcesses(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectADAccessProcesses(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var data []perflibADAccessProcesses
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchange ADAccess Processes"], &data, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
labelUseCount := make(map[string]int)
|
||||
|
||||
for _, proc := range data {
|
||||
labelName := c.toLabelName(proc.Name)
|
||||
if strings.HasSuffix(labelName, "_total") {
|
||||
@@ -317,6 +324,7 @@ func (c *Collector) collectADAccessProcesses(ctx *types.ScrapeContext, logger lo
|
||||
labelName,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -325,9 +333,11 @@ type perflibAvailabilityService struct {
|
||||
RequestsSec float64 `perflib:"Availability Requests (sec)"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectAvailabilityService(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectAvailabilityService(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var data []perflibAvailabilityService
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchange Availability Service"], &data, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -339,6 +349,7 @@ func (c *Collector) collectAvailabilityService(ctx *types.ScrapeContext, logger
|
||||
availservice.RequestsSec,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -354,9 +365,11 @@ type perflibHTTPProxy struct {
|
||||
ProxyRequestsPerSec float64 `perflib:"Proxy Requests/Sec"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectHTTPProxy(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectHTTPProxy(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var data []perflibHTTPProxy
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchange HttpProxy"], &data, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -400,6 +413,7 @@ func (c *Collector) collectHTTPProxy(ctx *types.ScrapeContext, logger log.Logger
|
||||
labelName,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -409,9 +423,11 @@ type perflibOWA struct {
|
||||
RequestsPerSec float64 `perflib:"Requests/sec"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectOWA(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectOWA(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var data []perflibOWA
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchange OWA"], &data, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -428,6 +444,7 @@ func (c *Collector) collectOWA(ctx *types.ScrapeContext, logger log.Logger, ch c
|
||||
owa.RequestsPerSec,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -438,9 +455,11 @@ type perflibActiveSync struct {
|
||||
SyncCommandsPerSec float64 `perflib:"Sync Commands/sec"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectActiveSync(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectActiveSync(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var data []perflibActiveSync
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchange ActiveSync"], &data, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -462,6 +481,7 @@ func (c *Collector) collectActiveSync(ctx *types.ScrapeContext, logger log.Logge
|
||||
instance.SyncCommandsPerSec,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -475,9 +495,11 @@ type perflibRPCClientAccess struct {
|
||||
UserCount float64 `perflib:"User Count"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectRPC(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectRPC(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var data []perflibRPCClientAccess
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchange RpcClientAccess"], &data, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -532,9 +554,11 @@ type perflibTransportQueues struct {
|
||||
PoisonQueueLength float64 `perflib:"Poison Queue Length"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectTransportQueues(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectTransportQueues(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var data []perflibTransportQueues
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchangeTransport Queues"], &data, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -593,6 +617,7 @@ func (c *Collector) collectTransportQueues(ctx *types.ScrapeContext, logger log.
|
||||
labelName,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -607,9 +632,11 @@ type perflibWorkloadManagementWorkloads struct {
|
||||
IsActive float64 `perflib:"Active"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectWorkloadManagementWorkloads(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectWorkloadManagementWorkloads(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var data []perflibWorkloadManagementWorkloads
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchange WorkloadManagement Workloads"], &data, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -659,12 +686,15 @@ type perflibAutodiscover struct {
|
||||
RequestsPerSec float64 `perflib:"Requests/sec"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectAutoDiscover(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectAutoDiscover(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var data []perflibAutodiscover
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchangeAutodiscover"], &data, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, autodisc := range data {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.autoDiscoverRequestsPerSec,
|
||||
@@ -672,6 +702,7 @@ func (c *Collector) collectAutoDiscover(ctx *types.ScrapeContext, logger log.Log
|
||||
autodisc.RequestsPerSec,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -680,9 +711,11 @@ type perflibMapiHttpEmsmdb struct {
|
||||
ActiveUserCount float64 `perflib:"Active User Count"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectMapiHttpEmsmdb(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectMapiHttpEmsmdb(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var data []perflibMapiHttpEmsmdb
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["MSExchange MapiHttp Emsmdb"], &data, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -702,6 +735,7 @@ func (c *Collector) collectMapiHttpEmsmdb(ctx *types.ScrapeContext, logger log.L
|
||||
func (c *Collector) toLabelName(name string) string {
|
||||
s := strings.ReplaceAll(strings.Join(strings.Fields(strings.ToLower(name)), "_"), ".", "_")
|
||||
s = strings.ReplaceAll(s, "__", "_")
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
175
pkg/collector/filetime/filetime.go
Normal file
175
pkg/collector/filetime/filetime.go
Normal file
@@ -0,0 +1,175 @@
|
||||
//go:build windows
|
||||
|
||||
package filetime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/bmatcuk/doublestar/v4"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const Name = "filetime"
|
||||
|
||||
type Config struct {
|
||||
filePatterns []string
|
||||
}
|
||||
|
||||
var ConfigDefaults = Config{
|
||||
filePatterns: []string{},
|
||||
}
|
||||
|
||||
// A Collector is a Prometheus Collector for collecting file times.
|
||||
type Collector struct {
|
||||
config Config
|
||||
|
||||
fileMTime *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
if config.filePatterns == nil {
|
||||
config.filePatterns = ConfigDefaults.filePatterns
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(app *kingpin.Application) *Collector {
|
||||
c := &Collector{
|
||||
config: ConfigDefaults,
|
||||
}
|
||||
c.config.filePatterns = make([]string, 0)
|
||||
|
||||
var filePatterns string
|
||||
|
||||
app.Flag(
|
||||
"collectors.filetime.file-patterns",
|
||||
"Comma-separated list of file patterns. Each pattern is a glob pattern that can contain `*`, `?`, and `**` (recursive). See https://github.com/bmatcuk/doublestar#patterns",
|
||||
).Default(strings.Join(ConfigDefaults.filePatterns, ",")).StringVar(&filePatterns)
|
||||
|
||||
app.Action(func(*kingpin.ParseContext) error {
|
||||
// doublestar.Glob() requires forward slashes
|
||||
c.config.filePatterns = strings.Split(filepath.ToSlash(filePatterns), ",")
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(logger *slog.Logger, _ *wmi.Client) error {
|
||||
logger.Info("filetime collector is in an experimental state! It may subject to change.",
|
||||
slog.String("collector", Name),
|
||||
)
|
||||
|
||||
c.fileMTime = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "mtime_timestamp_seconds"),
|
||||
"File modification time",
|
||||
[]string{"file"},
|
||||
nil,
|
||||
)
|
||||
|
||||
for _, filePattern := range c.config.filePatterns {
|
||||
basePath, pattern := doublestar.SplitPattern(filePattern)
|
||||
|
||||
_, err := doublestar.Glob(os.DirFS(basePath), pattern, doublestar.WithFilesOnly())
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid glob pattern: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
return c.collectGlob(logger, ch)
|
||||
}
|
||||
|
||||
// collectWin32 collects file times for each file path in the config. It using Win32 FindFirstFile and FindNextFile.
|
||||
func (c *Collector) collectGlob(logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
wg := sync.WaitGroup{}
|
||||
|
||||
for _, filePattern := range c.config.filePatterns {
|
||||
wg.Add(1)
|
||||
|
||||
go func(filePattern string) {
|
||||
defer wg.Done()
|
||||
|
||||
if err := c.collectGlobFilePath(logger, ch, filePattern); err != nil {
|
||||
logger.Error("failed collecting metrics for filepath",
|
||||
slog.String("filepath", filePattern),
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
}(filePattern)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collectGlobFilePath(logger *slog.Logger, ch chan<- prometheus.Metric, filePattern string) error {
|
||||
basePath, pattern := doublestar.SplitPattern(filePattern)
|
||||
basePathFS := os.DirFS(basePath)
|
||||
|
||||
matches, err := doublestar.Glob(basePathFS, pattern, doublestar.WithFilesOnly())
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to glob: %w", err)
|
||||
}
|
||||
|
||||
for _, match := range matches {
|
||||
filePath := filepath.Join(basePath, match)
|
||||
|
||||
fileInfo, err := os.Stat(filePath)
|
||||
if err != nil {
|
||||
logger.Warn("failed to state file",
|
||||
slog.String("file", filePath),
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.fileMTime,
|
||||
prometheus.GaugeValue,
|
||||
float64(fileInfo.ModTime().UTC().Unix()),
|
||||
filePath,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
12
pkg/collector/filetime/filetime_test.go
Normal file
12
pkg/collector/filetime/filetime_test.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package filetime_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/filetime"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
testutils.FuncBenchmarkCollector(b, filetime.Name, filetime.NewWithFlags)
|
||||
}
|
||||
@@ -4,10 +4,9 @@ package fsrmquota
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -56,15 +55,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
@@ -125,17 +124,22 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"path", "template"},
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting fsrmquota metrics", "err", err)
|
||||
logger.Error("failed collecting fsrmquota metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -158,6 +162,7 @@ type MSFT_FSRMQuota struct {
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
var dst []MSFT_FSRMQuota
|
||||
|
||||
var count int
|
||||
|
||||
if err := c.wmiClient.Query("SELECT * FROM MSFT_FSRMQuota", &dst, nil, "root/microsoft/windows/fsrm"); err != nil {
|
||||
@@ -225,5 +230,6 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.GaugeValue,
|
||||
float64(count),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
//go:build windows
|
||||
|
||||
package collector
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
stdlog "log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/google/uuid"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/collectors"
|
||||
"github.com/prometheus/client_golang/prometheus/collectors/version"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
func (c *Collectors) BuildServeHTTP(logger log.Logger, disableExporterMetrics bool, timeoutMargin float64) http.HandlerFunc {
|
||||
collectorFactory := func(timeout time.Duration, requestedCollectors []string) (error, *Prometheus) {
|
||||
filteredCollectors := make(map[string]Collector)
|
||||
// scrape all enabled collectors if no collector is requested
|
||||
if len(requestedCollectors) == 0 {
|
||||
filteredCollectors = c.collectors
|
||||
}
|
||||
for _, name := range requestedCollectors {
|
||||
col, exists := c.collectors[name]
|
||||
if !exists {
|
||||
return fmt.Errorf("unavailable collector: %s", name), nil
|
||||
}
|
||||
filteredCollectors[name] = col
|
||||
}
|
||||
|
||||
filtered := Collectors{
|
||||
collectors: filteredCollectors,
|
||||
perfCounterQuery: c.perfCounterQuery,
|
||||
}
|
||||
|
||||
return nil, NewPrometheus(timeout, &filtered, logger)
|
||||
}
|
||||
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
logger := log.With(logger, "remote", r.RemoteAddr, "correlation_id", uuid.New().String())
|
||||
|
||||
const defaultTimeout = 10.0
|
||||
|
||||
var timeoutSeconds float64
|
||||
if v := r.Header.Get("X-Prometheus-Scrape-Timeout-Seconds"); v != "" {
|
||||
var err error
|
||||
timeoutSeconds, err = strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", fmt.Sprintf("Couldn't parse X-Prometheus-Scrape-Timeout-Seconds: %q. Defaulting timeout to %f", v, defaultTimeout))
|
||||
}
|
||||
}
|
||||
if timeoutSeconds == 0 {
|
||||
timeoutSeconds = defaultTimeout
|
||||
}
|
||||
timeoutSeconds -= timeoutMargin
|
||||
|
||||
reg := prometheus.NewRegistry()
|
||||
err, wc := collectorFactory(time.Duration(timeoutSeconds*float64(time.Second)), r.URL.Query()["collect[]"])
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Couldn't create filtered metrics handler", "err", err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
_, _ = w.Write([]byte(fmt.Sprintf("Couldn't create filtered metrics handler: %s", err)))
|
||||
return
|
||||
}
|
||||
|
||||
reg.MustRegister(wc)
|
||||
if !disableExporterMetrics {
|
||||
reg.MustRegister(
|
||||
collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}),
|
||||
collectors.NewGoCollector(),
|
||||
version.NewCollector("windows_exporter"),
|
||||
)
|
||||
}
|
||||
|
||||
h := promhttp.HandlerFor(reg, promhttp.HandlerOpts{
|
||||
ErrorLog: stdlog.New(log.NewStdlibAdapter(level.Error(logger)), "", stdlog.Lshortfile),
|
||||
})
|
||||
h.ServeHTTP(w, r)
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,10 @@ package hyperv
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
@@ -161,15 +160,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
@@ -750,70 +749,107 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"vm"},
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collectVmHealth(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV health status metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV health status metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectVmVid(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV pages metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV pages metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectVmHv(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV hv status metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV hv status metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectVmProcessor(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV processor metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV processor metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectHostLPUsage(logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV host logical processors metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV host logical processors metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectHostCpuUsage(logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV host CPU metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV host CPU metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectVmCpuUsage(logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV VM CPU metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV VM CPU metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectVmSwitch(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV switch metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV switch metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectVmEthernet(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV ethernet metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV ethernet metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectVmStorage(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV virtual storage metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV virtual storage metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectVmNetwork(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV virtual network metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV virtual network metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectVmMemory(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting hyperV virtual memory metrics", "err", err)
|
||||
logger.Error("failed collecting hyperV virtual memory metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1086,7 +1122,7 @@ type Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor struct {
|
||||
PercentTotalRunTime uint
|
||||
}
|
||||
|
||||
func (c *Collector) collectHostLPUsage(logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectHostLPUsage(logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor", &dst); err != nil {
|
||||
return err
|
||||
@@ -1096,12 +1132,15 @@ func (c *Collector) collectHostLPUsage(logger log.Logger, ch chan<- prometheus.M
|
||||
if strings.Contains(obj.Name, "_Total") {
|
||||
continue
|
||||
}
|
||||
|
||||
// The name format is Hv LP <core id>
|
||||
parts := strings.Split(obj.Name, " ")
|
||||
if len(parts) != 3 {
|
||||
_ = level.Warn(logger).Log("msg", fmt.Sprintf("Unexpected format of Name in collectHostLPUsage: %q", obj.Name))
|
||||
logger.Warn(fmt.Sprintf("Unexpected format of Name in collectHostLPUsage: %q", obj.Name))
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
coreId := parts[2]
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -1139,7 +1178,7 @@ type Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor struct {
|
||||
CPUWaitTimePerDispatch uint64
|
||||
}
|
||||
|
||||
func (c *Collector) collectHostCpuUsage(logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectHostCpuUsage(logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor", &dst); err != nil {
|
||||
return err
|
||||
@@ -1149,12 +1188,15 @@ func (c *Collector) collectHostCpuUsage(logger log.Logger, ch chan<- prometheus.
|
||||
if strings.Contains(obj.Name, "_Total") {
|
||||
continue
|
||||
}
|
||||
|
||||
// The name format is Root VP <core id>
|
||||
parts := strings.Split(obj.Name, " ")
|
||||
if len(parts) != 3 {
|
||||
_ = level.Warn(logger).Log("msg", "Unexpected format of Name in collectHostCpuUsage: "+obj.Name)
|
||||
logger.Warn("Unexpected format of Name in collectHostCpuUsage: " + obj.Name)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
coreId := parts[2]
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -1206,7 +1248,7 @@ type Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor struct {
|
||||
CPUWaitTimePerDispatch uint64
|
||||
}
|
||||
|
||||
func (c *Collector) collectVmCpuUsage(logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectVmCpuUsage(logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor", &dst); err != nil {
|
||||
return err
|
||||
@@ -1216,17 +1258,22 @@ func (c *Collector) collectVmCpuUsage(logger log.Logger, ch chan<- prometheus.Me
|
||||
if strings.Contains(obj.Name, "_Total") {
|
||||
continue
|
||||
}
|
||||
|
||||
// The name format is <VM Name>:Hv VP <vcore id>
|
||||
parts := strings.Split(obj.Name, ":")
|
||||
if len(parts) != 2 {
|
||||
_ = level.Warn(logger).Log("msg", fmt.Sprintf("Unexpected format of Name in collectVmCpuUsage: %q, expected %q. Skipping.", obj.Name, "<VM Name>:Hv VP <vcore id>"))
|
||||
logger.Warn(fmt.Sprintf("Unexpected format of Name in collectVmCpuUsage: %q, expected %q. Skipping.", obj.Name, "<VM Name>:Hv VP <vcore id>"))
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
coreParts := strings.Split(parts[1], " ")
|
||||
if len(coreParts) != 3 {
|
||||
_ = level.Warn(logger).Log("msg", fmt.Sprintf("Unexpected format of core identifier in collectVmCpuUsage: %q, expected %q. Skipping.", parts[1], "Hv VP <vcore id>"))
|
||||
logger.Warn(fmt.Sprintf("Unexpected format of core identifier in collectVmCpuUsage: %q, expected %q. Skipping.", parts[1], "Hv VP <vcore id>"))
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
vmName := parts[0]
|
||||
coreId := coreParts[2]
|
||||
|
||||
|
||||
@@ -4,13 +4,12 @@ package iis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -250,7 +249,7 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{
|
||||
"Web Service",
|
||||
"APP_POOL_WAS",
|
||||
@@ -259,12 +258,12 @@ func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(logger log.Logger, _ *wmi.Client) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Build(logger *slog.Logger, _ *wmi.Client) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
c.iisVersion = getIISVersion(logger)
|
||||
|
||||
@@ -894,31 +893,44 @@ type simpleVersion struct {
|
||||
minor uint64
|
||||
}
|
||||
|
||||
func getIISVersion(logger log.Logger) simpleVersion {
|
||||
func getIISVersion(logger *slog.Logger) simpleVersion {
|
||||
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\InetStp\`, registry.QUERY_VALUE)
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Couldn't open registry to determine IIS version", "err", err)
|
||||
logger.Warn("Couldn't open registry to determine IIS version",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return simpleVersion{}
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err = k.Close()
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Failed to close registry key", "err", err)
|
||||
logger.Warn("Failed to close registry key",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
}()
|
||||
|
||||
major, _, err := k.GetIntegerValue("MajorVersion")
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Couldn't open registry to determine IIS version", "err", err)
|
||||
return simpleVersion{}
|
||||
}
|
||||
minor, _, err := k.GetIntegerValue("MinorVersion")
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Couldn't open registry to determine IIS version", "err", err)
|
||||
logger.Warn("Couldn't open registry to determine IIS version",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return simpleVersion{}
|
||||
}
|
||||
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("Detected IIS %d.%d\n", major, minor))
|
||||
minor, _, err := k.GetIntegerValue("MinorVersion")
|
||||
if err != nil {
|
||||
logger.Warn("Couldn't open registry to determine IIS version",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return simpleVersion{}
|
||||
}
|
||||
|
||||
logger.Debug(fmt.Sprintf("Detected IIS %d.%d\n", major, minor))
|
||||
|
||||
return simpleVersion{
|
||||
major: major,
|
||||
@@ -928,25 +940,37 @@ func getIISVersion(logger log.Logger) simpleVersion {
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collectWebService(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting iis metrics", "err", err)
|
||||
logger.Error("failed collecting iis metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectAPP_POOL_WAS(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting iis metrics", "err", err)
|
||||
logger.Error("failed collecting iis metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectW3SVC_W3WP(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting iis metrics", "err", err)
|
||||
logger.Error("failed collecting iis metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectWebServiceCache(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting iis metrics", "err", err)
|
||||
logger.Error("failed collecting iis metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1040,12 +1064,15 @@ func dedupIISNames[V hasGetIISName](services []V) map[string]V {
|
||||
name := strings.Split(entry.getIISName(), "#")[0]
|
||||
webServiceDeDuplicated[name] = entry
|
||||
}
|
||||
|
||||
return webServiceDeDuplicated
|
||||
}
|
||||
|
||||
func (c *Collector) collectWebService(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectWebService(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var webService []perflibWebService
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["Web Service"], &webService, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1336,9 +1363,11 @@ var applicationStates = map[uint32]string{
|
||||
7: "Delete Pending",
|
||||
}
|
||||
|
||||
func (c *Collector) collectAPP_POOL_WAS(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectAPP_POOL_WAS(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var APP_POOL_WAS []perflibAPP_POOL_WAS
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["APP_POOL_WAS"], &APP_POOL_WAS, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1514,9 +1543,11 @@ type perflibW3SVC_W3WP_IIS8 struct {
|
||||
WebSocketConnectionsRejected float64 `perflib:"WebSocket Connections Rejected / Sec"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectW3SVC_W3WP(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectW3SVC_W3WP(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var W3SVC_W3WP []perflibW3SVC_W3WP
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["W3SVC_W3WP"], &W3SVC_W3WP, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1526,6 +1557,7 @@ func (c *Collector) collectW3SVC_W3WP(ctx *types.ScrapeContext, logger log.Logge
|
||||
for w3Name, app := range w3svcW3WPDeduplicated {
|
||||
// Extract the apppool name from the format <PID>_<NAME>
|
||||
pid := workerProcessNameExtractor.ReplaceAllString(w3Name, "$1")
|
||||
|
||||
name := workerProcessNameExtractor.ReplaceAllString(w3Name, "$2")
|
||||
if name == "" || name == "_Total" ||
|
||||
c.config.AppExclude.MatchString(name) ||
|
||||
@@ -1784,6 +1816,7 @@ func (c *Collector) collectW3SVC_W3WP(ctx *types.ScrapeContext, logger log.Logge
|
||||
for w3Name, app := range w3svcW3WPIIS8Deduplicated {
|
||||
// Extract the apppool name from the format <PID>_<NAME>
|
||||
pid := workerProcessNameExtractor.ReplaceAllString(w3Name, "$1")
|
||||
|
||||
name := workerProcessNameExtractor.ReplaceAllString(w3Name, "$2")
|
||||
if name == "" || name == "_Total" ||
|
||||
c.config.AppExclude.MatchString(name) ||
|
||||
@@ -1912,9 +1945,11 @@ type perflibWebServiceCache struct {
|
||||
ServiceCache_OutputCacheQueriesTotal float64
|
||||
}
|
||||
|
||||
func (c *Collector) collectWebServiceCache(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectWebServiceCache(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var WebServiceCache []perflibWebServiceCache
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["Web Service Cache"], &WebServiceCache, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
package license
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/headers/slc"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -53,15 +53,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
c.licenseStatus = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "status"),
|
||||
"Status of windows license",
|
||||
@@ -74,12 +74,16 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting license metrics", "err", err)
|
||||
logger.Error("failed collecting license metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -5,14 +5,13 @@ package logical_disk
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -124,15 +123,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"LogicalDisk"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
c.information = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
||||
"A metric with a constant '1' value labeled with logical disk information",
|
||||
@@ -262,12 +261,16 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting logical_disk metrics", "err", err)
|
||||
logger.Error("failed collecting logical_disk metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -294,8 +297,9 @@ type logicalDisk struct {
|
||||
AvgDiskSecPerTransfer float64 `perflib:"Avg. Disk sec/Transfer"`
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var (
|
||||
err error
|
||||
diskID string
|
||||
@@ -316,12 +320,16 @@ func (c *Collector) collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
|
||||
diskID, err = getDiskIDByVolume(volume.Name)
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "failed to get disk ID for "+volume.Name, "err", err)
|
||||
logger.Warn("failed to get disk ID for "+volume.Name,
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
|
||||
info, err = getVolumeInfo(volume.Name)
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "failed to get volume information for %s"+volume.Name, "err", err)
|
||||
logger.Warn("failed to get volume information for %s"+volume.Name,
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -480,11 +488,13 @@ const diskExtentSize = 24
|
||||
func getDiskIDByVolume(rootDrive string) (string, error) {
|
||||
// Open a volume handle to the Disk Root.
|
||||
var err error
|
||||
|
||||
var f windows.Handle
|
||||
|
||||
// mode has to include FILE_SHARE permission to allow concurrent access to the disk.
|
||||
// use 0 as access mode to avoid admin permission.
|
||||
mode := uint32(windows.FILE_SHARE_READ | windows.FILE_SHARE_WRITE | windows.FILE_SHARE_DELETE)
|
||||
|
||||
f, err = windows.CreateFile(
|
||||
windows.StringToUTF16Ptr(`\\.\`+rootDrive),
|
||||
0, mode, nil, windows.OPEN_EXISTING, uint32(windows.FILE_ATTRIBUTE_READONLY), 0)
|
||||
@@ -498,6 +508,7 @@ func getDiskIDByVolume(rootDrive string) (string, error) {
|
||||
volumeDiskExtents := make([]byte, 16*1024)
|
||||
|
||||
var bytesReturned uint32
|
||||
|
||||
err = windows.DeviceIoControl(f, controlCode, nil, 0, &volumeDiskExtents[0], uint32(len(volumeDiskExtents)), &bytesReturned, nil)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not identify physical drive for %s: %w", rootDrive, err)
|
||||
|
||||
@@ -4,10 +4,9 @@ package logon
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
@@ -47,15 +46,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
@@ -67,17 +66,22 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"status"},
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting user metrics", "err", err)
|
||||
logger.Error("failed collecting user metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -92,6 +96,7 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_LogonSession", &dst); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(dst) == 0 {
|
||||
return errors.New("WMI query returned empty result set")
|
||||
}
|
||||
@@ -232,5 +237,6 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
float64(cachedunlock),
|
||||
"cached_unlock",
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package collector
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/ad"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/adcs"
|
||||
@@ -15,6 +18,7 @@ import (
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/diskdrive"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/dns"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/exchange"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/filetime"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/fsrmquota"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/hyperv"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/iis"
|
||||
@@ -26,16 +30,10 @@ import (
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/msmq"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/mssql"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/net"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrexceptions"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrinterop"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrjit"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrloading"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrlocksandthreads"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrmemory"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrremoting"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrsecurity"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/nps"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/os"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/perfdata"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/physical_disk"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/printer"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/process"
|
||||
@@ -54,7 +52,6 @@ import (
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/time"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/vmware"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/vmware_blast"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
func NewBuilderWithFlags[C Collector](fn BuilderWithFlags[C]) BuilderWithFlags[Collector] {
|
||||
@@ -64,60 +61,55 @@ func NewBuilderWithFlags[C Collector](fn BuilderWithFlags[C]) BuilderWithFlags[C
|
||||
}
|
||||
|
||||
var BuildersWithFlags = map[string]BuilderWithFlags[Collector]{
|
||||
ad.Name: NewBuilderWithFlags(ad.NewWithFlags),
|
||||
adcs.Name: NewBuilderWithFlags(adcs.NewWithFlags),
|
||||
adfs.Name: NewBuilderWithFlags(adfs.NewWithFlags),
|
||||
cache.Name: NewBuilderWithFlags(cache.NewWithFlags),
|
||||
container.Name: NewBuilderWithFlags(container.NewWithFlags),
|
||||
cpu.Name: NewBuilderWithFlags(cpu.NewWithFlags),
|
||||
cpu_info.Name: NewBuilderWithFlags(cpu_info.NewWithFlags),
|
||||
cs.Name: NewBuilderWithFlags(cs.NewWithFlags),
|
||||
dfsr.Name: NewBuilderWithFlags(dfsr.NewWithFlags),
|
||||
dhcp.Name: NewBuilderWithFlags(dhcp.NewWithFlags),
|
||||
diskdrive.Name: NewBuilderWithFlags(diskdrive.NewWithFlags),
|
||||
dns.Name: NewBuilderWithFlags(dns.NewWithFlags),
|
||||
exchange.Name: NewBuilderWithFlags(exchange.NewWithFlags),
|
||||
fsrmquota.Name: NewBuilderWithFlags(fsrmquota.NewWithFlags),
|
||||
hyperv.Name: NewBuilderWithFlags(hyperv.NewWithFlags),
|
||||
iis.Name: NewBuilderWithFlags(iis.NewWithFlags),
|
||||
license.Name: NewBuilderWithFlags(license.NewWithFlags),
|
||||
logical_disk.Name: NewBuilderWithFlags(logical_disk.NewWithFlags),
|
||||
logon.Name: NewBuilderWithFlags(logon.NewWithFlags),
|
||||
memory.Name: NewBuilderWithFlags(memory.NewWithFlags),
|
||||
mscluster.Name: NewBuilderWithFlags(mscluster.NewWithFlags),
|
||||
msmq.Name: NewBuilderWithFlags(msmq.NewWithFlags),
|
||||
mssql.Name: NewBuilderWithFlags(mssql.NewWithFlags),
|
||||
net.Name: NewBuilderWithFlags(net.NewWithFlags),
|
||||
netframework_clrexceptions.Name: NewBuilderWithFlags(netframework_clrexceptions.NewWithFlags),
|
||||
netframework_clrinterop.Name: NewBuilderWithFlags(netframework_clrinterop.NewWithFlags),
|
||||
netframework_clrjit.Name: NewBuilderWithFlags(netframework_clrjit.NewWithFlags),
|
||||
netframework_clrloading.Name: NewBuilderWithFlags(netframework_clrloading.NewWithFlags),
|
||||
netframework_clrlocksandthreads.Name: NewBuilderWithFlags(netframework_clrlocksandthreads.NewWithFlags),
|
||||
netframework_clrmemory.Name: NewBuilderWithFlags(netframework_clrmemory.NewWithFlags),
|
||||
netframework_clrremoting.Name: NewBuilderWithFlags(netframework_clrremoting.NewWithFlags),
|
||||
netframework_clrsecurity.Name: NewBuilderWithFlags(netframework_clrsecurity.NewWithFlags),
|
||||
nps.Name: NewBuilderWithFlags(nps.NewWithFlags),
|
||||
os.Name: NewBuilderWithFlags(os.NewWithFlags),
|
||||
physical_disk.Name: NewBuilderWithFlags(physical_disk.NewWithFlags),
|
||||
printer.Name: NewBuilderWithFlags(printer.NewWithFlags),
|
||||
process.Name: NewBuilderWithFlags(process.NewWithFlags),
|
||||
remote_fx.Name: NewBuilderWithFlags(remote_fx.NewWithFlags),
|
||||
scheduled_task.Name: NewBuilderWithFlags(scheduled_task.NewWithFlags),
|
||||
service.Name: NewBuilderWithFlags(service.NewWithFlags),
|
||||
smb.Name: NewBuilderWithFlags(smb.NewWithFlags),
|
||||
smbclient.Name: NewBuilderWithFlags(smbclient.NewWithFlags),
|
||||
smtp.Name: NewBuilderWithFlags(smtp.NewWithFlags),
|
||||
system.Name: NewBuilderWithFlags(system.NewWithFlags),
|
||||
teradici_pcoip.Name: NewBuilderWithFlags(teradici_pcoip.NewWithFlags),
|
||||
tcp.Name: NewBuilderWithFlags(tcp.NewWithFlags),
|
||||
terminal_services.Name: NewBuilderWithFlags(terminal_services.NewWithFlags),
|
||||
textfile.Name: NewBuilderWithFlags(textfile.NewWithFlags),
|
||||
thermalzone.Name: NewBuilderWithFlags(thermalzone.NewWithFlags),
|
||||
time.Name: NewBuilderWithFlags(time.NewWithFlags),
|
||||
vmware.Name: NewBuilderWithFlags(vmware.NewWithFlags),
|
||||
vmware_blast.Name: NewBuilderWithFlags(vmware_blast.NewWithFlags),
|
||||
ad.Name: NewBuilderWithFlags(ad.NewWithFlags),
|
||||
adcs.Name: NewBuilderWithFlags(adcs.NewWithFlags),
|
||||
adfs.Name: NewBuilderWithFlags(adfs.NewWithFlags),
|
||||
cache.Name: NewBuilderWithFlags(cache.NewWithFlags),
|
||||
container.Name: NewBuilderWithFlags(container.NewWithFlags),
|
||||
cpu.Name: NewBuilderWithFlags(cpu.NewWithFlags),
|
||||
cpu_info.Name: NewBuilderWithFlags(cpu_info.NewWithFlags),
|
||||
cs.Name: NewBuilderWithFlags(cs.NewWithFlags),
|
||||
dfsr.Name: NewBuilderWithFlags(dfsr.NewWithFlags),
|
||||
dhcp.Name: NewBuilderWithFlags(dhcp.NewWithFlags),
|
||||
diskdrive.Name: NewBuilderWithFlags(diskdrive.NewWithFlags),
|
||||
dns.Name: NewBuilderWithFlags(dns.NewWithFlags),
|
||||
exchange.Name: NewBuilderWithFlags(exchange.NewWithFlags),
|
||||
filetime.Name: NewBuilderWithFlags(filetime.NewWithFlags),
|
||||
fsrmquota.Name: NewBuilderWithFlags(fsrmquota.NewWithFlags),
|
||||
hyperv.Name: NewBuilderWithFlags(hyperv.NewWithFlags),
|
||||
iis.Name: NewBuilderWithFlags(iis.NewWithFlags),
|
||||
license.Name: NewBuilderWithFlags(license.NewWithFlags),
|
||||
logical_disk.Name: NewBuilderWithFlags(logical_disk.NewWithFlags),
|
||||
logon.Name: NewBuilderWithFlags(logon.NewWithFlags),
|
||||
memory.Name: NewBuilderWithFlags(memory.NewWithFlags),
|
||||
mscluster.Name: NewBuilderWithFlags(mscluster.NewWithFlags),
|
||||
msmq.Name: NewBuilderWithFlags(msmq.NewWithFlags),
|
||||
mssql.Name: NewBuilderWithFlags(mssql.NewWithFlags),
|
||||
net.Name: NewBuilderWithFlags(net.NewWithFlags),
|
||||
netframework.Name: NewBuilderWithFlags(netframework.NewWithFlags),
|
||||
nps.Name: NewBuilderWithFlags(nps.NewWithFlags),
|
||||
os.Name: NewBuilderWithFlags(os.NewWithFlags),
|
||||
perfdata.Name: NewBuilderWithFlags(perfdata.NewWithFlags),
|
||||
physical_disk.Name: NewBuilderWithFlags(physical_disk.NewWithFlags),
|
||||
printer.Name: NewBuilderWithFlags(printer.NewWithFlags),
|
||||
process.Name: NewBuilderWithFlags(process.NewWithFlags),
|
||||
remote_fx.Name: NewBuilderWithFlags(remote_fx.NewWithFlags),
|
||||
scheduled_task.Name: NewBuilderWithFlags(scheduled_task.NewWithFlags),
|
||||
service.Name: NewBuilderWithFlags(service.NewWithFlags),
|
||||
smb.Name: NewBuilderWithFlags(smb.NewWithFlags),
|
||||
smbclient.Name: NewBuilderWithFlags(smbclient.NewWithFlags),
|
||||
smtp.Name: NewBuilderWithFlags(smtp.NewWithFlags),
|
||||
system.Name: NewBuilderWithFlags(system.NewWithFlags),
|
||||
teradici_pcoip.Name: NewBuilderWithFlags(teradici_pcoip.NewWithFlags),
|
||||
tcp.Name: NewBuilderWithFlags(tcp.NewWithFlags),
|
||||
terminal_services.Name: NewBuilderWithFlags(terminal_services.NewWithFlags),
|
||||
textfile.Name: NewBuilderWithFlags(textfile.NewWithFlags),
|
||||
thermalzone.Name: NewBuilderWithFlags(thermalzone.NewWithFlags),
|
||||
time.Name: NewBuilderWithFlags(time.NewWithFlags),
|
||||
vmware.Name: NewBuilderWithFlags(vmware.NewWithFlags),
|
||||
vmware_blast.Name: NewBuilderWithFlags(vmware_blast.NewWithFlags),
|
||||
}
|
||||
|
||||
func Available() []string {
|
||||
return maps.Keys(BuildersWithFlags)
|
||||
return slices.Sorted(maps.Keys(BuildersWithFlags))
|
||||
}
|
||||
|
||||
@@ -6,9 +6,12 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/headers/sysinfoapi"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -25,6 +28,7 @@ var ConfigDefaults = Config{}
|
||||
type Collector struct {
|
||||
config Config
|
||||
|
||||
// Performance metrics
|
||||
availableBytes *prometheus.Desc
|
||||
cacheBytes *prometheus.Desc
|
||||
cacheBytesPeak *prometheus.Desc
|
||||
@@ -57,6 +61,11 @@ type Collector struct {
|
||||
transitionFaultsTotal *prometheus.Desc
|
||||
transitionPagesRepurposedTotal *prometheus.Desc
|
||||
writeCopiesTotal *prometheus.Desc
|
||||
|
||||
// Global memory status
|
||||
processMemoryLimitBytes *prometheus.Desc
|
||||
physicalMemoryTotalBytes *prometheus.Desc
|
||||
physicalMemoryFreeBytes *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
@@ -79,15 +88,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"Memory"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
c.availableBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "available_bytes"),
|
||||
"The amount of physical memory immediately available for allocation to a process or for system use. It is equal to the sum of memory assigned to"+
|
||||
@@ -292,17 +301,78 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.processMemoryLimitBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "process_memory_limit_bytes"),
|
||||
"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.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.physicalMemoryTotalBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "physical_total_bytes"),
|
||||
"The amount of actual physical memory, in bytes.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.physicalMemoryFreeBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "physical_free_bytes"),
|
||||
"The amount of physical memory currently available, in bytes. This is the amount of physical memory that can be immediately reused without having to write its contents to disk first. It is the sum of the size of the standby, free, and zero lists.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if err := c.collect(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting memory metrics", "err", err)
|
||||
return err
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
errs := make([]error, 0, 2)
|
||||
|
||||
if err := c.collectPerformanceData(ctx, logger, ch); err != nil {
|
||||
logger.Error("failed collecting memory metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
if err := c.collectGlobalMemoryStatus(ch); err != nil {
|
||||
logger.Error("failed collecting memory metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
func (c *Collector) collectGlobalMemoryStatus(ch chan<- prometheus.Metric) error {
|
||||
memoryStatusEx, err := sysinfoapi.GlobalMemoryStatusEx()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get memory status: %w", err)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processMemoryLimitBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.TotalVirtual),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.physicalMemoryTotalBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.TotalPhys),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.physicalMemoryFreeBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.AvailPhys),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -343,9 +413,11 @@ type memory struct {
|
||||
WriteCopiesPersec float64 `perflib:"Write Copies/sec"`
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectPerformanceData(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var dst []memory
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["Memory"], &dst, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package mscluster
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
@@ -213,15 +213,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"Memory"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if len(c.config.CollectorsEnabled) == 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -257,7 +257,7 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, _ log.Logger, ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, _ *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
if len(c.config.CollectorsEnabled) == 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -298,9 +298,5 @@ func (c *Collector) Collect(_ *types.ScrapeContext, _ log.Logger, ch chan<- prom
|
||||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
return nil
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@ package msmq
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -68,16 +67,16 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(logger log.Logger, wmiClient *wmi.Client) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Build(logger *slog.Logger, wmiClient *wmi.Client) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
@@ -86,7 +85,7 @@ func (c *Collector) Build(logger log.Logger, wmiClient *wmi.Client) error {
|
||||
c.wmiClient = wmiClient
|
||||
|
||||
if *c.config.QueryWhereClause == "" {
|
||||
_ = level.Warn(logger).Log("msg", "No where-clause specified for msmq collector. This will generate a very large number of metrics!")
|
||||
logger.Warn("No where-clause specified for msmq collector. This will generate a very large number of metrics!")
|
||||
}
|
||||
|
||||
c.bytesInJournalQueue = prometheus.NewDesc(
|
||||
@@ -113,17 +112,22 @@ func (c *Collector) Build(logger log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"name"},
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting msmq metrics", "err", err)
|
||||
logger.Error("failed collecting msmq metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ package mssql
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -12,8 +13,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -46,7 +45,7 @@ var ConfigDefaults = Config{
|
||||
|
||||
type mssqlInstancesType map[string]string
|
||||
|
||||
func getMSSQLInstances(logger log.Logger) mssqlInstancesType {
|
||||
func getMSSQLInstances(logger *slog.Logger) mssqlInstancesType {
|
||||
sqlInstances := make(mssqlInstancesType)
|
||||
|
||||
// in case querying the registry fails, return the default instance
|
||||
@@ -54,21 +53,31 @@ func getMSSQLInstances(logger log.Logger) mssqlInstancesType {
|
||||
sqlDefaultInstance["MSSQLSERVER"] = ""
|
||||
|
||||
regKey := `Software\Microsoft\Microsoft SQL Server\Instance Names\SQL`
|
||||
|
||||
k, err := registry.OpenKey(registry.LOCAL_MACHINE, regKey, registry.QUERY_VALUE)
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Couldn't open registry to determine SQL instances", "err", err)
|
||||
logger.Warn("Couldn't open registry to determine SQL instances",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return sqlDefaultInstance
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err = k.Close()
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Failed to close registry key", "err", err)
|
||||
logger.Warn("Failed to close registry key",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
}()
|
||||
|
||||
instanceNames, err := k.ReadValueNames(0)
|
||||
if err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Can't ReadSubKeyNames", "err", err)
|
||||
logger.Warn("Can't ReadSubKeyNames",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return sqlDefaultInstance
|
||||
}
|
||||
|
||||
@@ -78,7 +87,7 @@ func getMSSQLInstances(logger log.Logger) mssqlInstancesType {
|
||||
}
|
||||
}
|
||||
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("Detected MSSQL Instances: %#v\n", sqlInstances))
|
||||
logger.Debug(fmt.Sprintf("Detected MSSQL Instances: %#v\n", sqlInstances))
|
||||
|
||||
return sqlInstances
|
||||
}
|
||||
@@ -110,7 +119,9 @@ func mssqlGetPerfObjectName(sqlInstance string, collector string) string {
|
||||
if sqlInstance != "MSSQLSERVER" {
|
||||
prefix = "MSSQL$" + sqlInstance + ":"
|
||||
}
|
||||
|
||||
suffix := ""
|
||||
|
||||
switch collector {
|
||||
case "accessmethods":
|
||||
suffix = "Access Methods"
|
||||
@@ -137,6 +148,7 @@ func mssqlGetPerfObjectName(sqlInstance string, collector string) string {
|
||||
case "waitstats":
|
||||
suffix = "Wait Statistics"
|
||||
}
|
||||
|
||||
return prefix + suffix
|
||||
}
|
||||
|
||||
@@ -436,6 +448,7 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
||||
}
|
||||
|
||||
var listAllCollectors bool
|
||||
|
||||
var collectorsEnabled string
|
||||
|
||||
app.Flag(
|
||||
@@ -478,7 +491,7 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(logger log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(logger *slog.Logger) ([]string, error) {
|
||||
c.mssqlInstances = getMSSQLInstances(logger)
|
||||
perfCounters := make([]string, 0, len(c.mssqlInstances)*len(c.config.CollectorsEnabled))
|
||||
|
||||
@@ -491,11 +504,11 @@ func (c *Collector) GetPerfCounter(logger log.Logger) ([]string, error) {
|
||||
return perfCounters, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
// Result must order, to prevent test failures.
|
||||
sort.Strings(c.config.CollectorsEnabled)
|
||||
|
||||
@@ -1971,24 +1984,30 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type mssqlCollectorFunc func(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error
|
||||
type mssqlCollectorFunc func(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error
|
||||
|
||||
func (c *Collector) execute(ctx *types.ScrapeContext, logger log.Logger, name string, fn mssqlCollectorFunc, ch chan<- prometheus.Metric, sqlInstance string, wg *sync.WaitGroup) {
|
||||
func (c *Collector) execute(ctx *types.ScrapeContext, logger *slog.Logger, name string, fn mssqlCollectorFunc, ch chan<- prometheus.Metric, sqlInstance string, wg *sync.WaitGroup) {
|
||||
// Reset failure counter on each scrape
|
||||
c.mssqlChildCollectorFailure = 0
|
||||
|
||||
defer wg.Done()
|
||||
|
||||
begin := time.Now()
|
||||
err := fn(ctx, logger, ch, sqlInstance)
|
||||
duration := time.Since(begin)
|
||||
|
||||
var success float64
|
||||
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("msg", fmt.Sprintf("mssql class collector %s failed after %fs", name, duration.Seconds()), "err", err)
|
||||
logger.Error(fmt.Sprintf("mssql class collector %s failed after %fs", name, duration.Seconds()),
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
success = 0
|
||||
c.mssqlChildCollectorFailure++
|
||||
} else {
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql class collector %s succeeded after %fs.", name, duration.Seconds()))
|
||||
logger.Debug(fmt.Sprintf("mssql class collector %s succeeded after %fs.", name, duration.Seconds()))
|
||||
|
||||
success = 1
|
||||
}
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -2007,8 +2026,8 @@ func (c *Collector) execute(ctx *types.ScrapeContext, logger log.Logger, name st
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
wg := sync.WaitGroup{}
|
||||
|
||||
for sqlInstance := range c.mssqlInstances {
|
||||
@@ -2016,6 +2035,7 @@ func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
function := c.mssqlCollectors[name]
|
||||
|
||||
wg.Add(1)
|
||||
|
||||
go c.execute(ctx, logger, name, function, ch, sqlInstance, &wg)
|
||||
}
|
||||
}
|
||||
@@ -2079,9 +2099,10 @@ type mssqlAccessMethods struct {
|
||||
WorktablesFromCacheRatioBase float64 `perflib:"Worktables From Cache Base_Base"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectAccessMethods(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectAccessMethods(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlAccessMethods
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_accessmethods collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_accessmethods collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "accessmethods")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -2396,6 +2417,7 @@ func (c *Collector) collectAccessMethods(ctx *types.ScrapeContext, logger log.Lo
|
||||
sqlInstance,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2414,9 +2436,10 @@ type mssqlAvailabilityReplica struct {
|
||||
SendstoTransportPerSec float64 `perflib:"Sends to Transport/sec"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectAvailabilityReplica(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectAvailabilityReplica(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlAvailabilityReplica
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_availreplica collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_availreplica collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "availreplica")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -2426,6 +2449,7 @@ func (c *Collector) collectAvailabilityReplica(ctx *types.ScrapeContext, logger
|
||||
if strings.ToLower(v.Name) == "_total" {
|
||||
continue
|
||||
}
|
||||
|
||||
replicaName := v.Name
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -2491,6 +2515,7 @@ func (c *Collector) collectAvailabilityReplica(ctx *types.ScrapeContext, logger
|
||||
sqlInstance, replicaName,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2522,9 +2547,10 @@ type mssqlBufferManager struct {
|
||||
TargetPages float64 `perflib:"Target pages"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectBufferManager(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectBufferManager(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlBufferManager
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_bufman collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_bufman collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "bufman")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -2726,9 +2752,10 @@ type mssqlDatabaseReplica struct {
|
||||
TransactionDelay float64 `perflib:"Transaction Delay"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectDatabaseReplica(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectDatabaseReplica(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlDatabaseReplica
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_dbreplica collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_dbreplica collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "dbreplica")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -2738,6 +2765,7 @@ func (c *Collector) collectDatabaseReplica(ctx *types.ScrapeContext, logger log.
|
||||
if strings.ToLower(v.Name) == "_total" {
|
||||
continue
|
||||
}
|
||||
|
||||
replicaName := v.Name
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -2908,6 +2936,7 @@ func (c *Collector) collectDatabaseReplica(ctx *types.ScrapeContext, logger log.
|
||||
sqlInstance, replicaName,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2965,9 +2994,10 @@ type mssqlDatabases struct {
|
||||
XTPMemoryUsedKB float64 `perflib:"XTP Memory Used (KB)"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectDatabases(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectDatabases(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlDatabases
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_databases collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_databases collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "databases")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -2977,6 +3007,7 @@ func (c *Collector) collectDatabases(ctx *types.ScrapeContext, logger log.Logger
|
||||
if strings.ToLower(v.Name) == "_total" {
|
||||
continue
|
||||
}
|
||||
|
||||
dbName := v.Name
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -3315,6 +3346,7 @@ func (c *Collector) collectDatabases(ctx *types.ScrapeContext, logger log.Logger
|
||||
sqlInstance, dbName,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3347,9 +3379,10 @@ type mssqlGeneralStatistics struct {
|
||||
UserConnections float64 `perflib:"User Connections"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectGeneralStatistics(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectGeneralStatistics(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlGeneralStatistics
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_genstats collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_genstats collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "genstats")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -3542,9 +3575,10 @@ type mssqlLocks struct {
|
||||
NumberOfDeadlocksPerSec float64 `perflib:"Number of Deadlocks/sec"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectLocks(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectLocks(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlLocks
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_locks collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_locks collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "locks")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -3554,6 +3588,7 @@ func (c *Collector) collectLocks(ctx *types.ScrapeContext, logger log.Logger, ch
|
||||
if strings.ToLower(v.Name) == "_total" {
|
||||
continue
|
||||
}
|
||||
|
||||
lockResourceName := v.Name
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -3612,6 +3647,7 @@ func (c *Collector) collectLocks(ctx *types.ScrapeContext, logger log.Logger, ch
|
||||
sqlInstance, lockResourceName,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3640,9 +3676,10 @@ type mssqlMemoryManager struct {
|
||||
TotalServerMemoryKB float64 `perflib:"Total Server Memory (KB)"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectMemoryManager(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectMemoryManager(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlMemoryManager
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_memmgr collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_memmgr collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "memmgr")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -3809,9 +3846,10 @@ type mssqlSQLStatistics struct {
|
||||
UnsafeAutoParamsPerSec float64 `perflib:"Unsafe Auto-Params/sec"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectSQLStats(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectSQLStats(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlSQLStatistics
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_sqlstats collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_sqlstats collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "sqlstats")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -3917,9 +3955,10 @@ type mssqlWaitStatistics struct {
|
||||
WaitStatsTransactionOwnershipWaits float64 `perflib:"Transaction ownership waits"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectWaitStats(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectWaitStats(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlWaitStatistics
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_waitstats collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_waitstats collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "waitstats")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -4023,9 +4062,10 @@ type mssqlSQLErrors struct {
|
||||
|
||||
// Win32_PerfRawData_MSSQLSERVER_SQLServerErrors docs:
|
||||
// - https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-sql-errors-object
|
||||
func (c *Collector) collectSQLErrors(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectSQLErrors(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlSQLErrors
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_sqlerrors collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_sqlerrors collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "sqlerrors")], &dst, logger); err != nil {
|
||||
return err
|
||||
@@ -4035,6 +4075,7 @@ func (c *Collector) collectSQLErrors(ctx *types.ScrapeContext, logger log.Logger
|
||||
if strings.ToLower(v.Name) == "_total" {
|
||||
continue
|
||||
}
|
||||
|
||||
resource := v.Name
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -4066,9 +4107,10 @@ type mssqlTransactions struct {
|
||||
|
||||
// Win32_PerfRawData_MSSQLSERVER_Transactions docs:
|
||||
// - https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-transactions-object
|
||||
func (c *Collector) collectTransactions(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
func (c *Collector) collectTransactions(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric, sqlInstance string) error {
|
||||
var dst []mssqlTransactions
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("mssql_transactions collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
logger.Debug(fmt.Sprintf("mssql_transactions collector iterating sql instance %s.", sqlInstance))
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects[mssqlGetPerfObjectName(sqlInstance, "transactions")], &dst, logger); err != nil {
|
||||
return err
|
||||
|
||||
@@ -4,11 +4,10 @@ package net
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"regexp"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -108,15 +107,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"Network Interface"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
c.bytesReceivedTotal = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "bytes_received_total"),
|
||||
"(Network.BytesReceivedPerSec)",
|
||||
@@ -201,12 +200,16 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting net metrics", "err", err)
|
||||
logger.Error("failed collecting net metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -235,8 +238,9 @@ type networkInterface struct {
|
||||
CurrentBandwidth float64 `perflib:"Current Bandwidth"`
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var dst []networkInterface
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["Network Interface"], &dst, logger); err != nil {
|
||||
|
||||
245
pkg/collector/netframework/netframework.go
Normal file
245
pkg/collector/netframework/netframework.go
Normal file
@@ -0,0 +1,245 @@
|
||||
//go:build windows
|
||||
|
||||
package netframework
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"slices"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const Name = "netframework"
|
||||
|
||||
type Config struct {
|
||||
CollectorsEnabled []string `yaml:"collectors_enabled"`
|
||||
}
|
||||
|
||||
var ConfigDefaults = Config{
|
||||
CollectorsEnabled: []string{
|
||||
collectorClrExceptions,
|
||||
collectorClrInterop,
|
||||
collectorClrJIT,
|
||||
collectorClrLoading,
|
||||
collectorClrLocksAndThreads,
|
||||
collectorClrMemory,
|
||||
collectorClrRemoting,
|
||||
collectorClrSecurity,
|
||||
},
|
||||
}
|
||||
|
||||
const (
|
||||
collectorClrExceptions = "clrexceptions"
|
||||
collectorClrInterop = "clrinterop"
|
||||
collectorClrJIT = "clrjit"
|
||||
collectorClrLoading = "clrloading"
|
||||
collectorClrLocksAndThreads = "clrlocksandthreads"
|
||||
collectorClrMemory = "clrmemory"
|
||||
collectorClrRemoting = "clrremoting"
|
||||
collectorClrSecurity = "clrsecurity"
|
||||
)
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRExceptions metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
wmiClient *wmi.Client
|
||||
|
||||
// clrexceptions
|
||||
numberOfExceptionsThrown *prometheus.Desc
|
||||
numberOfFilters *prometheus.Desc
|
||||
numberOfFinally *prometheus.Desc
|
||||
throwToCatchDepth *prometheus.Desc
|
||||
|
||||
// clrinterop
|
||||
numberOfCCWs *prometheus.Desc
|
||||
numberOfMarshalling *prometheus.Desc
|
||||
numberOfStubs *prometheus.Desc
|
||||
|
||||
// clrjit
|
||||
numberOfMethodsJitted *prometheus.Desc
|
||||
timeInJit *prometheus.Desc
|
||||
standardJitFailures *prometheus.Desc
|
||||
totalNumberOfILBytesJitted *prometheus.Desc
|
||||
|
||||
// clrloading
|
||||
bytesInLoaderHeap *prometheus.Desc
|
||||
currentAppDomains *prometheus.Desc
|
||||
currentAssemblies *prometheus.Desc
|
||||
currentClassesLoaded *prometheus.Desc
|
||||
totalAppDomains *prometheus.Desc
|
||||
totalAppDomainsUnloaded *prometheus.Desc
|
||||
totalAssemblies *prometheus.Desc
|
||||
totalClassesLoaded *prometheus.Desc
|
||||
totalNumberOfLoadFailures *prometheus.Desc
|
||||
|
||||
// clrlocksandthreads
|
||||
currentQueueLength *prometheus.Desc
|
||||
numberOfCurrentLogicalThreads *prometheus.Desc
|
||||
numberOfCurrentPhysicalThreads *prometheus.Desc
|
||||
numberOfCurrentRecognizedThreads *prometheus.Desc
|
||||
numberOfTotalRecognizedThreads *prometheus.Desc
|
||||
queueLengthPeak *prometheus.Desc
|
||||
totalNumberOfContentions *prometheus.Desc
|
||||
|
||||
// clrmemory
|
||||
allocatedBytes *prometheus.Desc
|
||||
finalizationSurvivors *prometheus.Desc
|
||||
heapSize *prometheus.Desc
|
||||
promotedBytes *prometheus.Desc
|
||||
numberGCHandles *prometheus.Desc
|
||||
numberCollections *prometheus.Desc
|
||||
numberInducedGC *prometheus.Desc
|
||||
numberOfPinnedObjects *prometheus.Desc
|
||||
numberOfSinkBlocksInUse *prometheus.Desc
|
||||
numberTotalCommittedBytes *prometheus.Desc
|
||||
numberTotalReservedBytes *prometheus.Desc
|
||||
timeInGC *prometheus.Desc
|
||||
|
||||
// clrremoting
|
||||
channels *prometheus.Desc
|
||||
contextBoundClassesLoaded *prometheus.Desc
|
||||
contextBoundObjects *prometheus.Desc
|
||||
contextProxies *prometheus.Desc
|
||||
contexts *prometheus.Desc
|
||||
totalRemoteCalls *prometheus.Desc
|
||||
|
||||
// clrsecurity
|
||||
numberLinkTimeChecks *prometheus.Desc
|
||||
timeInRTChecks *prometheus.Desc
|
||||
stackWalkDepth *prometheus.Desc
|
||||
totalRuntimeChecks *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(_ *kingpin.Application) *Collector {
|
||||
return &Collector{}
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
|
||||
c.wmiClient = wmiClient
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrExceptions) {
|
||||
c.buildClrExceptions()
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrInterop) {
|
||||
c.buildClrInterop()
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrJIT) {
|
||||
c.buildClrJIT()
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrLoading) {
|
||||
c.buildClrLoading()
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrLocksAndThreads) {
|
||||
c.buildClrLocksAndThreads()
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrMemory) {
|
||||
c.buildClrMemory()
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrRemoting) {
|
||||
c.buildClrRemoting()
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrSecurity) {
|
||||
c.buildClrSecurity()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, _ *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
var (
|
||||
err error
|
||||
errs []error
|
||||
)
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrExceptions) {
|
||||
if err = c.collectClrExceptions(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrExceptions, err))
|
||||
}
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrInterop) {
|
||||
if err = c.collectClrInterop(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrInterop, err))
|
||||
}
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrJIT) {
|
||||
if err = c.collectClrJIT(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrJIT, err))
|
||||
}
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrLoading) {
|
||||
if err = c.collectClrLoading(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrLoading, err))
|
||||
}
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrLocksAndThreads) {
|
||||
if err = c.collectClrLocksAndThreads(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrLocksAndThreads, err))
|
||||
}
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrMemory) {
|
||||
if err = c.collectClrMemory(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrMemory, err))
|
||||
}
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrRemoting) {
|
||||
if err = c.collectClrRemoting(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrRemoting, err))
|
||||
}
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, collectorClrSecurity) {
|
||||
if err = c.collectClrSecurity(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect %s metrics: %w", collectorClrSecurity, err))
|
||||
}
|
||||
}
|
||||
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
@@ -1,69 +1,13 @@
|
||||
//go:build windows
|
||||
|
||||
package netframework_clrexceptions
|
||||
package netframework
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const Name = "netframework_clrexceptions"
|
||||
|
||||
type Config struct{}
|
||||
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRExceptions metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
wmiClient *wmi.Client
|
||||
|
||||
numberOfExceptionsThrown *prometheus.Desc
|
||||
numberOfFilters *prometheus.Desc
|
||||
numberOfFinally *prometheus.Desc
|
||||
throwToCatchDepth *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(_ *kingpin.Application) *Collector {
|
||||
return &Collector{}
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
|
||||
c.wmiClient = wmiClient
|
||||
func (c *Collector) buildClrExceptions() {
|
||||
c.numberOfExceptionsThrown = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "exceptions_thrown_total"),
|
||||
"Displays the total number of exceptions thrown since the application started. This includes both .NET exceptions and unmanaged exceptions that are converted into .NET exceptions.",
|
||||
@@ -88,18 +32,6 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"process"},
|
||||
nil,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting win32_perfrawdata_netframework_netclrexceptions metrics", "err", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Win32_PerfRawData_NETFramework_NETCLRExceptions struct {
|
||||
@@ -112,7 +44,7 @@ type Win32_PerfRawData_NETFramework_NETCLRExceptions struct {
|
||||
ThrowToCatchDepthPersec uint32
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectClrExceptions(ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_NETFramework_NETCLRExceptions
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRExceptions", &dst); err != nil {
|
||||
return err
|
||||
@@ -1,68 +1,13 @@
|
||||
//go:build windows
|
||||
|
||||
package netframework_clrinterop
|
||||
package netframework
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const Name = "netframework_clrinterop"
|
||||
|
||||
type Config struct{}
|
||||
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRInterop metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
wmiClient *wmi.Client
|
||||
|
||||
numberOfCCWs *prometheus.Desc
|
||||
numberOfMarshalling *prometheus.Desc
|
||||
numberOfStubs *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(_ *kingpin.Application) *Collector {
|
||||
return &Collector{}
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
|
||||
c.wmiClient = wmiClient
|
||||
func (c *Collector) buildClrInterop() {
|
||||
c.numberOfCCWs = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "com_callable_wrappers_total"),
|
||||
"Displays the current number of COM callable wrappers (CCWs). A CCW is a proxy for a managed object being referenced from an unmanaged COM client.",
|
||||
@@ -81,18 +26,6 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"process"},
|
||||
nil,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting win32_perfrawdata_netframework_netclrinterop metrics", "err", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Win32_PerfRawData_NETFramework_NETCLRInterop struct {
|
||||
@@ -105,7 +38,7 @@ type Win32_PerfRawData_NETFramework_NETCLRInterop struct {
|
||||
NumberofTLBimportsPersec uint32
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectClrInterop(ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_NETFramework_NETCLRInterop
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRInterop", &dst); err != nil {
|
||||
return err
|
||||
@@ -1,62 +1,13 @@
|
||||
//go:build windows
|
||||
|
||||
package netframework_clrjit
|
||||
package netframework
|
||||
|
||||
import (
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const Name = "netframework_clrjit"
|
||||
|
||||
type Config struct{}
|
||||
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRJit metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
wmiClient *wmi.Client
|
||||
|
||||
numberOfMethodsJitted *prometheus.Desc
|
||||
timeInJit *prometheus.Desc
|
||||
standardJitFailures *prometheus.Desc
|
||||
totalNumberOfILBytesJitted *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(_ *kingpin.Application) *Collector {
|
||||
return &Collector{}
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) buildClrJIT() {
|
||||
c.numberOfMethodsJitted = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "jit_methods_total"),
|
||||
"Displays the total number of methods JIT-compiled since the application started. This counter does not include pre-JIT-compiled methods.",
|
||||
@@ -81,18 +32,6 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
[]string{"process"},
|
||||
nil,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting win32_perfrawdata_netframework_netclrjit metrics", "err", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Win32_PerfRawData_NETFramework_NETCLRJit struct {
|
||||
@@ -107,7 +46,7 @@ type Win32_PerfRawData_NETFramework_NETCLRJit struct {
|
||||
TotalNumberofILBytesJitted uint32
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectClrJIT(ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_NETFramework_NETCLRJit
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRJit", &dst); err != nil {
|
||||
return err
|
||||
@@ -1,75 +1,13 @@
|
||||
//go:build windows
|
||||
|
||||
package netframework_clrloading
|
||||
package netframework
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const Name = "netframework_clrloading"
|
||||
|
||||
type Config struct{}
|
||||
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRLoading metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
wmiClient *wmi.Client
|
||||
|
||||
bytesInLoaderHeap *prometheus.Desc
|
||||
currentAppDomains *prometheus.Desc
|
||||
currentAssemblies *prometheus.Desc
|
||||
currentClassesLoaded *prometheus.Desc
|
||||
totalAppDomains *prometheus.Desc
|
||||
totalAppDomainsUnloaded *prometheus.Desc
|
||||
totalAssemblies *prometheus.Desc
|
||||
totalClassesLoaded *prometheus.Desc
|
||||
totalNumberOfLoadFailures *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(_ *kingpin.Application) *Collector {
|
||||
return &Collector{}
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
|
||||
c.wmiClient = wmiClient
|
||||
|
||||
func (c *Collector) buildClrLoading() {
|
||||
c.bytesInLoaderHeap = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "loader_heap_size_bytes"),
|
||||
"Displays the current size, in bytes, of the memory committed by the class loader across all application domains. Committed memory is the physical space reserved in the disk paging file.",
|
||||
@@ -124,18 +62,6 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"process"},
|
||||
nil,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting win32_perfrawdata_netframework_netclrloading metrics", "err", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Win32_PerfRawData_NETFramework_NETCLRLoading struct {
|
||||
@@ -159,7 +85,7 @@ type Win32_PerfRawData_NETFramework_NETCLRLoading struct {
|
||||
TotalNumberofLoadFailures uint32
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectClrLoading(ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_NETFramework_NETCLRLoading
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRLoading", &dst); err != nil {
|
||||
return err
|
||||
@@ -1,73 +1,13 @@
|
||||
//go:build windows
|
||||
|
||||
package netframework_clrlocksandthreads
|
||||
package netframework
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const Name = "netframework_clrlocksandthreads"
|
||||
|
||||
type Config struct{}
|
||||
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
wmiClient *wmi.Client
|
||||
|
||||
currentQueueLength *prometheus.Desc
|
||||
numberOfCurrentLogicalThreads *prometheus.Desc
|
||||
numberOfCurrentPhysicalThreads *prometheus.Desc
|
||||
numberOfCurrentRecognizedThreads *prometheus.Desc
|
||||
numberOfTotalRecognizedThreads *prometheus.Desc
|
||||
queueLengthPeak *prometheus.Desc
|
||||
totalNumberOfContentions *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(_ *kingpin.Application) *Collector {
|
||||
return &Collector{}
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
|
||||
c.wmiClient = wmiClient
|
||||
|
||||
func (c *Collector) buildClrLocksAndThreads() {
|
||||
c.currentQueueLength = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "current_queue_length"),
|
||||
"Displays the total number of threads that are currently waiting to acquire a managed lock in the application.",
|
||||
@@ -110,18 +50,6 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"process"},
|
||||
nil,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting win32_perfrawdata_netframework_netclrlocksandthreads metrics", "err", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads struct {
|
||||
@@ -139,7 +67,7 @@ type Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads struct {
|
||||
TotalNumberofContentions uint32
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectClrLocksAndThreads(ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads", &dst); err != nil {
|
||||
return err
|
||||
@@ -1,78 +1,13 @@
|
||||
//go:build windows
|
||||
|
||||
package netframework_clrmemory
|
||||
package netframework
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const Name = "netframework_clrmemory"
|
||||
|
||||
type Config struct{}
|
||||
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRMemory metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
wmiClient *wmi.Client
|
||||
|
||||
allocatedBytes *prometheus.Desc
|
||||
finalizationSurvivors *prometheus.Desc
|
||||
heapSize *prometheus.Desc
|
||||
promotedBytes *prometheus.Desc
|
||||
numberGCHandles *prometheus.Desc
|
||||
numberCollections *prometheus.Desc
|
||||
numberInducedGC *prometheus.Desc
|
||||
numberOfPinnedObjects *prometheus.Desc
|
||||
numberOfSinkBlocksInUse *prometheus.Desc
|
||||
numberTotalCommittedBytes *prometheus.Desc
|
||||
numberTotalReservedBytes *prometheus.Desc
|
||||
timeInGC *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(_ *kingpin.Application) *Collector {
|
||||
return &Collector{}
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
|
||||
c.wmiClient = wmiClient
|
||||
|
||||
func (c *Collector) buildClrMemory() {
|
||||
c.allocatedBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "allocated_bytes_total"),
|
||||
"Displays the total number of bytes allocated on the garbage collection heap.",
|
||||
@@ -145,18 +80,6 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"process"},
|
||||
nil,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting win32_perfrawdata_netframework_netclrmemory metrics", "err", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Win32_PerfRawData_NETFramework_NETCLRMemory struct {
|
||||
@@ -193,7 +116,7 @@ type Win32_PerfRawData_NETFramework_NETCLRMemory struct {
|
||||
PromotedMemoryfromGen1 uint64
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectClrMemory(ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_NETFramework_NETCLRMemory
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRMemory", &dst); err != nil {
|
||||
return err
|
||||
@@ -1,72 +1,13 @@
|
||||
//go:build windows
|
||||
|
||||
package netframework_clrremoting
|
||||
package netframework
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const Name = "netframework_clrremoting"
|
||||
|
||||
type Config struct{}
|
||||
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRRemoting metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
wmiClient *wmi.Client
|
||||
|
||||
channels *prometheus.Desc
|
||||
contextBoundClassesLoaded *prometheus.Desc
|
||||
contextBoundObjects *prometheus.Desc
|
||||
contextProxies *prometheus.Desc
|
||||
contexts *prometheus.Desc
|
||||
totalRemoteCalls *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(_ *kingpin.Application) *Collector {
|
||||
return &Collector{}
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
|
||||
c.wmiClient = wmiClient
|
||||
|
||||
func (c *Collector) buildClrRemoting() {
|
||||
c.channels = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "channels_total"),
|
||||
"Displays the total number of remoting channels registered across all application domains since application started.",
|
||||
@@ -103,18 +44,6 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"process"},
|
||||
nil,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting win32_perfrawdata_netframework_netclrremoting metrics", "err", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Win32_PerfRawData_NETFramework_NETCLRRemoting struct {
|
||||
@@ -129,7 +58,7 @@ type Win32_PerfRawData_NETFramework_NETCLRRemoting struct {
|
||||
TotalRemoteCalls uint32
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectClrRemoting(ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_NETFramework_NETCLRRemoting
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRRemoting", &dst); err != nil {
|
||||
return err
|
||||
@@ -1,69 +1,13 @@
|
||||
//go:build windows
|
||||
|
||||
package netframework_clrsecurity
|
||||
package netframework
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const Name = "netframework_clrsecurity"
|
||||
|
||||
type Config struct{}
|
||||
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_NETFramework_NETCLRSecurity metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
wmiClient *wmi.Client
|
||||
|
||||
numberLinkTimeChecks *prometheus.Desc
|
||||
timeInRTChecks *prometheus.Desc
|
||||
stackWalkDepth *prometheus.Desc
|
||||
totalRuntimeChecks *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(_ *kingpin.Application) *Collector {
|
||||
return &Collector{}
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
|
||||
c.wmiClient = wmiClient
|
||||
func (c *Collector) buildClrSecurity() {
|
||||
c.numberLinkTimeChecks = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "link_time_checks_total"),
|
||||
"Displays the total number of link-time code access security checks since the application started.",
|
||||
@@ -88,18 +32,6 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
[]string{"process"},
|
||||
nil,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if err := c.collect(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting win32_perfrawdata_netframework_netclrsecurity metrics", "err", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Win32_PerfRawData_NETFramework_NETCLRSecurity struct {
|
||||
@@ -113,7 +45,7 @@ type Win32_PerfRawData_NETFramework_NETCLRSecurity struct {
|
||||
TotalRuntimeChecks uint32
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectClrSecurity(ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_NETFramework_NETCLRSecurity
|
||||
if err := c.wmiClient.Query("SELECT * FROM Win32_PerfRawData_NETFramework_NETCLRSecurity", &dst); err != nil {
|
||||
return err
|
||||
@@ -1,13 +1,13 @@
|
||||
package netframework_clrexceptions_test
|
||||
package netframework_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrexceptions"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
// No context name required as Collector source is WMI
|
||||
testutils.FuncBenchmarkCollector(b, netframework_clrexceptions.Name, netframework_clrexceptions.NewWithFlags)
|
||||
testutils.FuncBenchmarkCollector(b, netframework.Name, netframework.NewWithFlags)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package netframework_clrinterop_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrinterop"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
// No context name required as collector source is WMI
|
||||
testutils.FuncBenchmarkCollector(b, netframework_clrinterop.Name, netframework_clrinterop.NewWithFlags)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package netframework_clrjit_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrjit"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
// No context name required as collector source is WMI
|
||||
testutils.FuncBenchmarkCollector(b, netframework_clrjit.Name, netframework_clrjit.NewWithFlags)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package netframework_clrloading_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrloading"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
// No context name required as collector source is WMI
|
||||
testutils.FuncBenchmarkCollector(b, netframework_clrloading.Name, netframework_clrloading.NewWithFlags)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package netframework_clrlocksandthreads_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrlocksandthreads"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
// No context name required as collector source is WMI
|
||||
testutils.FuncBenchmarkCollector(b, netframework_clrlocksandthreads.Name, netframework_clrlocksandthreads.NewWithFlags)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package netframework_clrmemory_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrmemory"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
// No context name required as collector source is WMI
|
||||
testutils.FuncBenchmarkCollector(b, netframework_clrmemory.Name, netframework_clrmemory.NewWithFlags)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package netframework_clrremoting_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrremoting"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
// No context name required as collector source is WMI
|
||||
testutils.FuncBenchmarkCollector(b, netframework_clrremoting.Name, netframework_clrremoting.NewWithFlags)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package netframework_clrsecurity_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/netframework_clrsecurity"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
// No context name required as collector source is WMI
|
||||
testutils.FuncBenchmarkCollector(b, netframework_clrsecurity.Name, netframework_clrsecurity.NewWithFlags)
|
||||
}
|
||||
@@ -3,10 +3,9 @@ package nps
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
@@ -71,15 +70,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
@@ -236,21 +235,26 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.CollectAccept(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", fmt.Sprintf("failed collecting NPS accept data: %s", err))
|
||||
logger.Error(fmt.Sprintf("failed collecting NPS accept data: %s", err))
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.CollectAccounting(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", fmt.Sprintf("failed collecting NPS accounting data: %s", err))
|
||||
logger.Error(fmt.Sprintf("failed collecting NPS accounting data: %s", err))
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -5,15 +5,13 @@ package os
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/headers/kernel32"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/headers/netapi32"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/headers/psapi"
|
||||
@@ -22,6 +20,7 @@ import (
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
"golang.org/x/sys/windows"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
@@ -35,19 +34,45 @@ var ConfigDefaults = Config{}
|
||||
type Collector struct {
|
||||
config Config
|
||||
|
||||
osInformation *prometheus.Desc
|
||||
pagingFreeBytes *prometheus.Desc
|
||||
pagingLimitBytes *prometheus.Desc
|
||||
hostname *prometheus.Desc
|
||||
osInformation *prometheus.Desc
|
||||
pagingFreeBytes *prometheus.Desc
|
||||
pagingLimitBytes *prometheus.Desc
|
||||
|
||||
// users
|
||||
// Deprecated: Use windows_system_processes instead.
|
||||
processes *prometheus.Desc
|
||||
// users
|
||||
// Deprecated: Use windows_system_process_limit instead.
|
||||
processesLimit *prometheus.Desc
|
||||
|
||||
// users
|
||||
// Deprecated: Use count(windows_logon_logon_type) instead.
|
||||
users *prometheus.Desc
|
||||
|
||||
// physicalMemoryFreeBytes
|
||||
// Deprecated: Use windows_memory_physical_free_bytes instead.
|
||||
physicalMemoryFreeBytes *prometheus.Desc
|
||||
|
||||
// processMemoryLimitBytes
|
||||
// Deprecated: Use windows_memory_process_memory_limit_bytes instead.
|
||||
processMemoryLimitBytes *prometheus.Desc
|
||||
processes *prometheus.Desc
|
||||
processesLimit *prometheus.Desc
|
||||
time *prometheus.Desc
|
||||
timezone *prometheus.Desc
|
||||
users *prometheus.Desc
|
||||
virtualMemoryBytes *prometheus.Desc
|
||||
virtualMemoryFreeBytes *prometheus.Desc
|
||||
visibleMemoryBytes *prometheus.Desc
|
||||
|
||||
// time
|
||||
// Deprecated: Use windows_time_current_timestamp_seconds instead.
|
||||
time *prometheus.Desc
|
||||
// timezone
|
||||
// Deprecated: Use windows_time_timezone instead.
|
||||
timezone *prometheus.Desc
|
||||
// virtualMemoryBytes
|
||||
// Deprecated: Use windows_memory_commit_limit instead.
|
||||
virtualMemoryBytes *prometheus.Desc
|
||||
// virtualMemoryFreeBytes
|
||||
// Deprecated: Use windows_memory_commit_limit instead.
|
||||
virtualMemoryFreeBytes *prometheus.Desc
|
||||
// visibleMemoryBytes
|
||||
// Deprecated: Use windows_memory_physical_total_bytes instead.
|
||||
visibleMemoryBytes *prometheus.Desc
|
||||
}
|
||||
|
||||
type pagingFileCounter struct {
|
||||
@@ -76,19 +101,50 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"Paging File"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(logger *slog.Logger, _ *wmi.Client) error {
|
||||
logger.Warn("The os collect holds a number of deprecated metrics and will be removed mid 2025. " +
|
||||
"See https://github.com/prometheus-community/windows_exporter/pull/1596 for more information.")
|
||||
|
||||
workstationInfo, err := netapi32.GetWorkstationInfo()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get workstation info: %w", err)
|
||||
}
|
||||
|
||||
productName, buildNumber, revision, err := c.getWindowsVersion()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Windows version: %w", err)
|
||||
}
|
||||
|
||||
c.osInformation = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
||||
"OperatingSystem.Caption, OperatingSystem.Version",
|
||||
[]string{"product", "version", "major_version", "minor_version", "build_number", "revision"},
|
||||
`Contains full product name & version in labels. Note that the "major_version" for Windows 11 is \"10\"; a build number greater than 22000 represents Windows 11.`,
|
||||
nil,
|
||||
prometheus.Labels{
|
||||
"product": productName,
|
||||
"version": fmt.Sprintf("%d.%d.%s", workstationInfo.VersionMajor, workstationInfo.VersionMinor, buildNumber),
|
||||
"major_version": strconv.FormatUint(uint64(workstationInfo.VersionMajor), 10),
|
||||
"minor_version": strconv.FormatUint(uint64(workstationInfo.VersionMinor), 10),
|
||||
"build_number": buildNumber,
|
||||
"revision": revision,
|
||||
},
|
||||
)
|
||||
|
||||
c.hostname = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "hostname"),
|
||||
"Labelled system hostname information as provided by ComputerSystem.DNSHostName and ComputerSystem.Domain",
|
||||
[]string{
|
||||
"hostname",
|
||||
"domain",
|
||||
"fqdn",
|
||||
},
|
||||
nil,
|
||||
)
|
||||
c.pagingLimitBytes = prometheus.NewDesc(
|
||||
@@ -105,118 +161,228 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
)
|
||||
c.physicalMemoryFreeBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "physical_memory_free_bytes"),
|
||||
"OperatingSystem.FreePhysicalMemory",
|
||||
"Deprecated: Use `windows_memory_physical_free_bytes` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.time = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "time"),
|
||||
"OperatingSystem.LocalDateTime",
|
||||
"Deprecated: Use windows_time_current_timestamp_seconds instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.timezone = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "timezone"),
|
||||
"OperatingSystem.LocalDateTime",
|
||||
"Deprecated: Use windows_time_timezone instead.",
|
||||
[]string{"timezone"},
|
||||
nil,
|
||||
)
|
||||
c.processes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "processes"),
|
||||
"OperatingSystem.NumberOfProcesses",
|
||||
"Deprecated: Use `windows_system_processes` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.processesLimit = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "processes_limit"),
|
||||
"OperatingSystem.MaxNumberOfProcesses",
|
||||
"Deprecated: Use `windows_system_process_limit` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.processMemoryLimitBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "process_memory_limit_bytes"),
|
||||
"OperatingSystem.MaxProcessMemorySize",
|
||||
"Deprecated: Use `windows_memory_process_memory_limit_bytes` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.users = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "users"),
|
||||
"OperatingSystem.NumberOfUsers",
|
||||
"Deprecated: Use `count(windows_logon_logon_type)` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.virtualMemoryBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "virtual_memory_bytes"),
|
||||
"OperatingSystem.TotalVirtualMemorySize",
|
||||
"Deprecated: Use `windows_memory_commit_limit` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.visibleMemoryBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "visible_memory_bytes"),
|
||||
"OperatingSystem.TotalVisibleMemorySize",
|
||||
"Deprecated: Use `windows_memory_physical_total_bytes` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.virtualMemoryFreeBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "virtual_memory_free_bytes"),
|
||||
"OperatingSystem.FreeVirtualMemory",
|
||||
"Deprecated: Use `windows_memory_commit_limit - windows_memory_committed_bytes` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
if err := c.collect(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting os metrics", "err", err)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
errs := make([]error, 0, 5)
|
||||
|
||||
c.collect(ch)
|
||||
|
||||
if err := c.collectHostname(ch); err != nil {
|
||||
logger.Error("failed collecting os metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
if err := c.collectLoggedInUserCount(ch); err != nil {
|
||||
logger.Error("failed collecting os user count metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
if err := c.collectMemory(ch); err != nil {
|
||||
logger.Error("failed collecting os memory metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
if err := c.collectTime(ch); err != nil {
|
||||
logger.Error("failed collecting os time metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
if err := c.collectPaging(ctx, logger, ch); err != nil {
|
||||
logger.Error("failed collecting os paging metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
func (c *Collector) collectLoggedInUserCount(ch chan<- prometheus.Metric) error {
|
||||
workstationInfo, err := netapi32.GetWorkstationInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.users,
|
||||
prometheus.GaugeValue,
|
||||
float64(workstationInfo.LoggedOnUsers),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Win32_OperatingSystem docs:
|
||||
// - https://msdn.microsoft.com/en-us/library/aa394239 - Win32_OperatingSystem class.
|
||||
type Win32_OperatingSystem struct {
|
||||
Caption string
|
||||
FreePhysicalMemory uint64
|
||||
FreeSpaceInPagingFiles uint64
|
||||
FreeVirtualMemory uint64
|
||||
LocalDateTime time.Time
|
||||
MaxNumberOfProcesses uint32
|
||||
MaxProcessMemorySize uint64
|
||||
NumberOfProcesses uint32
|
||||
NumberOfUsers uint32
|
||||
SizeStoredInPagingFiles uint64
|
||||
TotalVirtualMemorySize uint64
|
||||
TotalVisibleMemorySize uint64
|
||||
Version string
|
||||
func (c *Collector) collectHostname(ch chan<- prometheus.Metric) error {
|
||||
hostname, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSHostname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
domain, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSDomain)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fqdn, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSFullyQualified)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.hostname,
|
||||
prometheus.GaugeValue,
|
||||
1.0,
|
||||
hostname,
|
||||
domain,
|
||||
fqdn,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
nwgi, err := netapi32.GetWorkstationInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gmse, err := sysinfoapi.GlobalMemoryStatusEx()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
currentTime := time.Now()
|
||||
|
||||
func (c *Collector) collectTime(ch chan<- prometheus.Metric) error {
|
||||
timeZoneInfo, err := kernel32.GetDynamicTimeZoneInformation()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// timeZoneKeyName contains the english name of the timezone.
|
||||
timezoneName := syscall.UTF16ToString(timeZoneInfo.TimeZoneKeyName[:])
|
||||
timezoneName := windows.UTF16ToString(timeZoneInfo.TimeZoneKeyName[:])
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.time,
|
||||
prometheus.GaugeValue,
|
||||
float64(time.Now().Unix()),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timezone,
|
||||
prometheus.GaugeValue,
|
||||
1.0,
|
||||
timezoneName,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collectMemory(ch chan<- prometheus.Metric) error {
|
||||
memoryStatusEx, err := sysinfoapi.GlobalMemoryStatusEx()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.physicalMemoryFreeBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.AvailPhys),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualMemoryFreeBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.AvailPageFile),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualMemoryBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.TotalPageFile),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.visibleMemoryBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.TotalPhys),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processMemoryLimitBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.TotalVirtual),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collectPaging(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
// Get total allocation of paging files across all disks.
|
||||
memManKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management`, registry.QUERY_VALUE)
|
||||
if err != nil {
|
||||
@@ -228,96 +394,43 @@ func (c *Collector) collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
pagingFiles, _, pagingErr := memManKey.GetStringsValue("ExistingPageFiles")
|
||||
|
||||
var fsipf float64
|
||||
|
||||
for _, pagingFile := range pagingFiles {
|
||||
fileString := strings.ReplaceAll(pagingFile, `\??\`, "")
|
||||
file, err := os.Stat(fileString)
|
||||
// For unknown reasons, Windows doesn't always create a page file. Continue collection rather than aborting.
|
||||
if err != nil {
|
||||
_ = level.Debug(logger).Log("msg", fmt.Sprintf("Failed to read page file (reason: %s): %s\n", err, fileString))
|
||||
logger.Debug(fmt.Sprintf("Failed to read page file (reason: %s): %s\n", err, fileString))
|
||||
} else {
|
||||
fsipf += float64(file.Size())
|
||||
}
|
||||
}
|
||||
|
||||
// Get build number and product name from registry
|
||||
ntKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer ntKey.Close()
|
||||
|
||||
pn, _, err := ntKey.GetStringValue("ProductName")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
bn, _, err := ntKey.GetStringValue("CurrentBuildNumber")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
revision, _, err := ntKey.GetIntegerValue("UBR")
|
||||
if errors.Is(err, registry.ErrNotExist) {
|
||||
revision = 0
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gpi, err := psapi.GetPerformanceInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pfc := make([]pagingFileCounter, 0)
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["Paging File"], &pfc, logger); err != nil {
|
||||
if err = perflib.UnmarshalObject(ctx.PerfObjects["Paging File"], &pfc, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Get current page file usage.
|
||||
var pfbRaw float64
|
||||
|
||||
for _, pageFile := range pfc {
|
||||
if strings.Contains(strings.ToLower(pageFile.Name), "_total") {
|
||||
continue
|
||||
}
|
||||
|
||||
pfbRaw += pageFile.Usage
|
||||
}
|
||||
|
||||
// Subtract from total page file allocation on disk.
|
||||
pfb := fsipf - (pfbRaw * float64(gpi.PageSize))
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.osInformation,
|
||||
prometheus.GaugeValue,
|
||||
1.0,
|
||||
"Microsoft "+pn, // Caption
|
||||
fmt.Sprintf("%d.%d.%s", nwgi.VersionMajor, nwgi.VersionMinor, bn), // Version
|
||||
strconv.FormatUint(uint64(nwgi.VersionMajor), 10), // Major Version
|
||||
strconv.FormatUint(uint64(nwgi.VersionMinor), 10), // Minor Version
|
||||
bn, // Build number
|
||||
strconv.FormatUint(revision, 10), // Revision
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.physicalMemoryFreeBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(gmse.AvailPhys),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.time,
|
||||
prometheus.GaugeValue,
|
||||
float64(currentTime.Unix()),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timezone,
|
||||
prometheus.GaugeValue,
|
||||
1.0,
|
||||
timezoneName,
|
||||
)
|
||||
|
||||
if pagingErr == nil {
|
||||
// Subtract from total page file allocation on disk.
|
||||
pfb := fsipf - (pfbRaw * float64(gpi.PageSize))
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.pagingFreeBytes,
|
||||
prometheus.GaugeValue,
|
||||
@@ -330,12 +443,23 @@ func (c *Collector) collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
fsipf,
|
||||
)
|
||||
} else {
|
||||
_ = level.Debug(logger).Log("msg", "Could not find HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management key. windows_os_paging_free_bytes and windows_os_paging_limit_bytes will be omitted.")
|
||||
logger.Debug("Could not find HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management key. windows_os_paging_free_bytes and windows_os_paging_limit_bytes will be omitted.")
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualMemoryFreeBytes,
|
||||
c.processes,
|
||||
prometheus.GaugeValue,
|
||||
float64(gmse.AvailPageFile),
|
||||
float64(gpi.ProcessCount),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.osInformation,
|
||||
prometheus.GaugeValue,
|
||||
1.0,
|
||||
)
|
||||
|
||||
// Windows has no defined limit, and is based off available resources. This currently isn't calculated by WMI and is set to default value.
|
||||
@@ -346,36 +470,33 @@ func (c *Collector) collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
prometheus.GaugeValue,
|
||||
float64(4294967295),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processMemoryLimitBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(gmse.TotalVirtual),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processes,
|
||||
prometheus.GaugeValue,
|
||||
float64(gpi.ProcessCount),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.users,
|
||||
prometheus.GaugeValue,
|
||||
float64(nwgi.LoggedOnUsers),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualMemoryBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(gmse.TotalPageFile),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.visibleMemoryBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(gmse.TotalPhys),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) getWindowsVersion() (string, string, string, error) {
|
||||
// Get build number and product name from registry
|
||||
ntKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
|
||||
if err != nil {
|
||||
return "", "", "", fmt.Errorf("failed to open registry key: %w", err)
|
||||
}
|
||||
|
||||
defer ntKey.Close()
|
||||
|
||||
productName, _, err := ntKey.GetStringValue("ProductName")
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
|
||||
buildNumber, _, err := ntKey.GetStringValue("CurrentBuildNumber")
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
|
||||
revision, _, err := ntKey.GetIntegerValue("UBR")
|
||||
if errors.Is(err, registry.ErrNotExist) {
|
||||
revision = 0
|
||||
} else if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
|
||||
return productName, buildNumber, strconv.FormatUint(revision, 10), nil
|
||||
}
|
||||
|
||||
181
pkg/collector/perfdata/perfdata.go
Normal file
181
pkg/collector/perfdata/perfdata.go
Normal file
@@ -0,0 +1,181 @@
|
||||
//go:build windows
|
||||
|
||||
package perfdata
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perfdata"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
const (
|
||||
Name = "perfdata"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Objects []Object `yaml:"objects"`
|
||||
}
|
||||
|
||||
var ConfigDefaults = Config{
|
||||
Objects: make([]Object, 0),
|
||||
}
|
||||
|
||||
// A Collector is a Prometheus collector for perfdata metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
if config == nil {
|
||||
config = &ConfigDefaults
|
||||
}
|
||||
|
||||
if config.Objects == nil {
|
||||
config.Objects = ConfigDefaults.Objects
|
||||
}
|
||||
|
||||
c := &Collector{
|
||||
config: *config,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(app *kingpin.Application) *Collector {
|
||||
c := &Collector{
|
||||
config: ConfigDefaults,
|
||||
}
|
||||
|
||||
var objects string
|
||||
|
||||
app.Flag(
|
||||
"collector.perfdata.objects",
|
||||
"Objects of performance data to observe. See docs for more information on how to use this flag. By default, no objects are observed.",
|
||||
).Default("").StringVar(&objects)
|
||||
|
||||
app.Action(func(*kingpin.ParseContext) error {
|
||||
if objects == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := json.Unmarshal([]byte(objects), &c.config.Objects); err != nil {
|
||||
return fmt.Errorf("failed to parse objects: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
for _, object := range c.config.Objects {
|
||||
object.collector.Close()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(logger *slog.Logger, _ *wmi.Client) error {
|
||||
logger.Warn("The perfdata collector is in an experimental state! The configuration may change in future. Please report any issues.")
|
||||
|
||||
for i, object := range c.config.Objects {
|
||||
collector, err := perfdata.NewCollector(object.Object, object.Instances, slices.Sorted(maps.Keys(object.Counters)))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create pdh collector: %w", err)
|
||||
}
|
||||
|
||||
if object.InstanceLabel == "" {
|
||||
c.config.Objects[i].InstanceLabel = "instance"
|
||||
}
|
||||
|
||||
c.config.Objects[i].collector = collector
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
if err := c.collect(ch); err != nil {
|
||||
logger.Error("failed collecting performance data metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
for _, object := range c.config.Objects {
|
||||
data, err := object.collector.Collect()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect data: %w", err)
|
||||
}
|
||||
|
||||
for instance, counters := range data {
|
||||
for counter, value := range counters {
|
||||
var labels prometheus.Labels
|
||||
if instance != perfdata.EmptyInstance {
|
||||
labels = prometheus.Labels{object.InstanceLabel: instance}
|
||||
}
|
||||
|
||||
metricType := value.Type
|
||||
|
||||
if val, ok := object.Counters[counter]; ok {
|
||||
switch val.Type {
|
||||
case "counter":
|
||||
metricType = prometheus.CounterValue
|
||||
case "gauge":
|
||||
metricType = prometheus.GaugeValue
|
||||
}
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
sanitizeMetricName(fmt.Sprintf("%s_perfdata_%s_%s", types.Namespace, object.Object, counter)),
|
||||
fmt.Sprintf("Performance data for \\%s\\%s", object.Object, counter),
|
||||
nil,
|
||||
labels,
|
||||
),
|
||||
metricType,
|
||||
value.FirstValue,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func sanitizeMetricName(name string) string {
|
||||
replacer := strings.NewReplacer(
|
||||
".", "",
|
||||
"%", "",
|
||||
"/", "_",
|
||||
" ", "_",
|
||||
"-", "_",
|
||||
)
|
||||
|
||||
return strings.Trim(replacer.Replace(strings.ToLower(name)), "_")
|
||||
}
|
||||
87
pkg/collector/perfdata/perfdata_collector_test.go
Normal file
87
pkg/collector/perfdata/perfdata_collector_test.go
Normal file
@@ -0,0 +1,87 @@
|
||||
//go:build windows
|
||||
|
||||
package perfdata_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/perfdata"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type collectorAdapter struct {
|
||||
perfdata.Collector
|
||||
}
|
||||
|
||||
// Describe implements the prometheus.Collector interface.
|
||||
func (a collectorAdapter) Describe(_ chan<- *prometheus.Desc) {}
|
||||
|
||||
// Collect implements the prometheus.Collector interface.
|
||||
func (a collectorAdapter) Collect(ch chan<- prometheus.Metric) {
|
||||
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
|
||||
if err := a.Collector.Collect(nil, logger, ch); err != nil {
|
||||
panic(fmt.Sprintf("failed to update collector: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollector(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, tc := range []struct {
|
||||
object string
|
||||
instances []string
|
||||
counters map[string]perfdata.Counter
|
||||
expectedMetrics *regexp.Regexp
|
||||
}{
|
||||
{
|
||||
object: "Memory",
|
||||
instances: nil,
|
||||
counters: map[string]perfdata.Counter{"Available Bytes": {Type: "gauge"}},
|
||||
expectedMetrics: regexp.MustCompile(`^# HELP windows_perfdata_memory_available_bytes Performance data for \\\\Memory\\\\Available Bytes\s*# TYPE windows_perfdata_memory_available_bytes gauge\s*windows_perfdata_memory_available_bytes \d`),
|
||||
},
|
||||
{
|
||||
object: "Process",
|
||||
instances: []string{"*"},
|
||||
counters: map[string]perfdata.Counter{"Thread Count": {Type: "counter"}},
|
||||
expectedMetrics: regexp.MustCompile(`^# HELP windows_perfdata_process_thread_count Performance data for \\\\Process\\\\Thread Count\s*# TYPE windows_perfdata_process_thread_count counter\s*windows_perfdata_process_thread_count\{instance=".+"} \d`),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.object, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
perfDataCollector := perfdata.New(&perfdata.Config{
|
||||
Objects: []perfdata.Object{
|
||||
{
|
||||
Object: tc.object,
|
||||
Instances: tc.instances,
|
||||
Counters: tc.counters,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
err := perfDataCollector.Build(logger, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
registry := prometheus.NewRegistry()
|
||||
registry.MustRegister(collectorAdapter{*perfDataCollector})
|
||||
|
||||
rw := httptest.NewRecorder()
|
||||
promhttp.HandlerFor(registry, promhttp.HandlerOpts{ErrorHandling: promhttp.ContinueOnError}).ServeHTTP(rw, &http.Request{})
|
||||
got := rw.Body.String()
|
||||
|
||||
assert.NotEmpty(t, got)
|
||||
assert.Regexp(t, tc.expectedMetrics, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
18
pkg/collector/perfdata/perfdata_test.go
Normal file
18
pkg/collector/perfdata/perfdata_test.go
Normal file
@@ -0,0 +1,18 @@
|
||||
//go:build windows
|
||||
|
||||
package perfdata_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector/perfdata"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
perfDataObjects := `[{"object":"Processor Information","instances":["*"],"counters":{"*": {}}}]`
|
||||
kingpin.CommandLine.GetArg("collector.perfdata.objects").StringVar(&perfDataObjects)
|
||||
|
||||
testutils.FuncBenchmarkCollector(b, perfdata.Name, perfdata.NewWithFlags)
|
||||
}
|
||||
18
pkg/collector/perfdata/types.go
Normal file
18
pkg/collector/perfdata/types.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package perfdata
|
||||
|
||||
import (
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perfdata"
|
||||
)
|
||||
|
||||
type Object struct {
|
||||
Object string `json:"object" yaml:"object"`
|
||||
Instances []string `json:"instances" yaml:"instances"`
|
||||
Counters map[string]Counter `json:"counters" yaml:"counters"`
|
||||
InstanceLabel string `json:"instance_label" yaml:"instance_label"` //nolint:tagliatelle
|
||||
|
||||
collector *perfdata.Collector
|
||||
}
|
||||
|
||||
type Counter struct {
|
||||
Type string `json:"type" yaml:"type"`
|
||||
}
|
||||
@@ -4,12 +4,11 @@ package physical_disk
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -106,15 +105,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"PhysicalDisk"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
c.requestsQueued = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "requests_queued"),
|
||||
"The number of requests queued to the disk (PhysicalDisk.CurrentDiskQueueLength)",
|
||||
@@ -204,12 +203,16 @@ func (c *Collector) Build(_ log.Logger, _ *wmi.Client) error {
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collect(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting physical_disk metrics", "err", err)
|
||||
logger.Error("failed collecting physical_disk metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -232,9 +235,11 @@ type PhysicalDisk struct {
|
||||
AvgDiskSecPerTransfer float64 `perflib:"Avg. Disk sec/Transfer"`
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var dst []PhysicalDisk
|
||||
|
||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["PhysicalDisk"], &dst, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -5,12 +5,11 @@ package printer
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
@@ -104,11 +103,11 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, wmiClient *wmi.Client) error {
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
}
|
||||
@@ -139,7 +138,9 @@ func (c *Collector) Build(_ log.Logger, wmiClient *wmi.Client) error {
|
||||
|
||||
func (c *Collector) GetName() string { return Name }
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) { return []string{"Printer"}, nil }
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"Printer"}, nil
|
||||
}
|
||||
|
||||
type wmiPrinter struct {
|
||||
Name string
|
||||
@@ -153,15 +154,21 @@ type wmiPrintJob struct {
|
||||
Status string
|
||||
}
|
||||
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collectPrinterStatus(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed to collect printer status metrics", "err", err)
|
||||
logger.Error("failed to collect printer status metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectPrinterJobStatus(ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed to collect printer job status metrics", "err", err)
|
||||
logger.Error("failed to collect printer job status metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -5,15 +5,13 @@ package process
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -124,16 +122,16 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"Process"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(logger log.Logger, wmiClient *wmi.Client) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Build(logger *slog.Logger, wmiClient *wmi.Client) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
if wmiClient == nil || wmiClient.SWbemServicesClient == nil {
|
||||
return errors.New("wmiClient or SWbemServicesClient is nil")
|
||||
@@ -142,7 +140,7 @@ func (c *Collector) Build(logger log.Logger, wmiClient *wmi.Client) error {
|
||||
c.wmiClient = wmiClient
|
||||
|
||||
if c.config.ProcessInclude.String() == "^(?:.*)$" && c.config.ProcessExclude.String() == "^(?:)$" {
|
||||
_ = level.Warn(logger).Log("msg", "No filters specified for process collector. This will generate a very large number of metrics!")
|
||||
logger.Warn("No filters specified for process collector. This will generate a very large number of metrics!")
|
||||
}
|
||||
|
||||
c.info = prometheus.NewDesc(
|
||||
@@ -285,9 +283,10 @@ type WorkerProcess struct {
|
||||
ProcessId uint64
|
||||
}
|
||||
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
data := make([]perflibProcess, 0)
|
||||
|
||||
err := perflib.UnmarshalObject(ctx.PerfObjects["Process"], &data, logger)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -296,7 +295,9 @@ func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
var workerProcesses []WorkerProcess
|
||||
if c.config.EnableWorkerProcess {
|
||||
if err := c.wmiClient.Query("SELECT * FROM WorkerProcess", &workerProcesses, nil, "root\\WebAdministration"); err != nil {
|
||||
_ = level.Debug(logger).Log("msg", "Could not query WebAdministration namespace for IIS worker processes", "err", err)
|
||||
logger.Debug("Could not query WebAdministration namespace for IIS worker processes",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,6 +317,7 @@ func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
for _, wp := range workerProcesses {
|
||||
if wp.ProcessId == uint64(process.IDProcess) {
|
||||
processName = strings.Join([]string{processName, wp.AppPoolName}, "_")
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -323,7 +325,10 @@ func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
|
||||
cmdLine, processOwner, processGroupID, err := c.getProcessInformation(logger, uint32(process.IDProcess))
|
||||
if err != nil {
|
||||
_ = level.Debug(logger).Log("msg", "Failed to get process information", "pid", pid, "err", err)
|
||||
logger.Debug("Failed to get process information",
|
||||
slog.String("pid", pid),
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -485,7 +490,7 @@ func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
}
|
||||
|
||||
// ref: https://github.com/microsoft/hcsshim/blob/8beabacfc2d21767a07c20f8dd5f9f3932dbf305/internal/uvm/stats.go#L25
|
||||
func (c *Collector) getProcessInformation(logger log.Logger, pid uint32) (string, string, uint32, error) {
|
||||
func (c *Collector) getProcessInformation(logger *slog.Logger, pid uint32) (string, string, uint32, error) {
|
||||
if pid == 0 {
|
||||
return "", "", 0, nil
|
||||
}
|
||||
@@ -501,7 +506,9 @@ func (c *Collector) getProcessInformation(logger log.Logger, pid uint32) (string
|
||||
|
||||
defer func(hProcess windows.Handle) {
|
||||
if err := windows.CloseHandle(hProcess); err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "CloseHandle failed", "err", err)
|
||||
logger.Warn("CloseHandle failed",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
}(hProcess)
|
||||
|
||||
@@ -528,12 +535,14 @@ func (c *Collector) getProcessInformation(logger log.Logger, pid uint32) (string
|
||||
func (c *Collector) getExtendedProcessInformation(hProcess windows.Handle) (string, uint32, error) {
|
||||
// Get the process environment block (PEB) address
|
||||
var pbi windows.PROCESS_BASIC_INFORMATION
|
||||
|
||||
retLen := uint32(unsafe.Sizeof(pbi))
|
||||
if err := windows.NtQueryInformationProcess(hProcess, windows.ProcessBasicInformation, unsafe.Pointer(&pbi), retLen, &retLen); err != nil {
|
||||
return "", 0, fmt.Errorf("failed to query process basic information: %w", err)
|
||||
}
|
||||
|
||||
peb := windows.PEB{}
|
||||
|
||||
err := windows.ReadProcessMemory(hProcess,
|
||||
uintptr(unsafe.Pointer(pbi.PebBaseAddress)),
|
||||
(*byte)(unsafe.Pointer(&peb)),
|
||||
@@ -545,6 +554,7 @@ func (c *Collector) getExtendedProcessInformation(hProcess windows.Handle) (stri
|
||||
}
|
||||
|
||||
processParameters := windows.RTL_USER_PROCESS_PARAMETERS{}
|
||||
|
||||
err = windows.ReadProcessMemory(hProcess,
|
||||
uintptr(unsafe.Pointer(peb.ProcessParameters)),
|
||||
(*byte)(unsafe.Pointer(&processParameters)),
|
||||
@@ -570,7 +580,7 @@ func (c *Collector) getExtendedProcessInformation(hProcess windows.Handle) (stri
|
||||
return strings.TrimSpace(windows.UTF16ToString(cmdLineUTF16)), processParameters.ProcessGroupId, nil
|
||||
}
|
||||
|
||||
func (c *Collector) getProcessOwner(logger log.Logger, hProcess windows.Handle) (string, error) {
|
||||
func (c *Collector) getProcessOwner(logger *slog.Logger, hProcess windows.Handle) (string, error) {
|
||||
var tok windows.Token
|
||||
|
||||
if err := windows.OpenProcessToken(hProcess, windows.TOKEN_QUERY, &tok); err != nil {
|
||||
@@ -583,7 +593,9 @@ func (c *Collector) getProcessOwner(logger log.Logger, hProcess windows.Handle)
|
||||
|
||||
defer func(tok windows.Token) {
|
||||
if err := tok.Close(); err != nil {
|
||||
_ = level.Warn(logger).Log("msg", "Token close failed", "err", err)
|
||||
logger.Warn("Token close failed",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
}(tok)
|
||||
|
||||
@@ -620,7 +632,7 @@ func (c *Collector) openProcess(pid uint32) (windows.Handle, bool, error) {
|
||||
return 0, false, fmt.Errorf("failed to open process: %w", err)
|
||||
}
|
||||
|
||||
if errors.Is(err, syscall.Errno(0x57)) { // invalid parameter, for PIDs that don't exist
|
||||
if errors.Is(err, windows.Errno(0x57)) { // invalid parameter, for PIDs that don't exist
|
||||
return 0, false, errors.New("process not found")
|
||||
}
|
||||
|
||||
|
||||
@@ -3,49 +3,73 @@
|
||||
package collector
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
// Prometheus implements prometheus.Collector for a set of Windows Collectors.
|
||||
// Interface guard.
|
||||
var _ prometheus.Collector = (*Prometheus)(nil)
|
||||
|
||||
// Prometheus implements prometheus.Collector for a set of Windows MetricCollectors.
|
||||
type Prometheus struct {
|
||||
maxScrapeDuration time.Duration
|
||||
collectors *Collectors
|
||||
logger log.Logger
|
||||
logger *slog.Logger
|
||||
metricCollectors *MetricCollectors
|
||||
|
||||
// Base metrics returned by Prometheus
|
||||
scrapeDurationDesc *prometheus.Desc
|
||||
scrapeSuccessDesc *prometheus.Desc
|
||||
scrapeTimeoutDesc *prometheus.Desc
|
||||
snapshotDuration *prometheus.Desc
|
||||
scrapeDurationDesc *prometheus.Desc
|
||||
collectorScrapeDurationDesc *prometheus.Desc
|
||||
collectorScrapeSuccessDesc *prometheus.Desc
|
||||
collectorScrapeTimeoutDesc *prometheus.Desc
|
||||
snapshotDuration *prometheus.Desc
|
||||
}
|
||||
|
||||
// NewPrometheus returns a new Prometheus where the set of Collectors must
|
||||
type collectorStatus struct {
|
||||
name string
|
||||
statusCode collectorStatusCode
|
||||
}
|
||||
|
||||
type collectorStatusCode int
|
||||
|
||||
const (
|
||||
pending collectorStatusCode = iota
|
||||
success
|
||||
failed
|
||||
)
|
||||
|
||||
// NewPrometheusCollector returns a new Prometheus where the set of MetricCollectors must
|
||||
// return metrics within the given timeout.
|
||||
func NewPrometheus(timeout time.Duration, cs *Collectors, logger log.Logger) *Prometheus {
|
||||
func (c *MetricCollectors) NewPrometheusCollector(timeout time.Duration, logger *slog.Logger) *Prometheus {
|
||||
return &Prometheus{
|
||||
maxScrapeDuration: timeout,
|
||||
collectors: cs,
|
||||
metricCollectors: c,
|
||||
logger: logger,
|
||||
scrapeDurationDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, "exporter", "scrape_duration_seconds"),
|
||||
"windows_exporter: Total scrape duration.",
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
collectorScrapeDurationDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, "exporter", "collector_duration_seconds"),
|
||||
"windows_exporter: Duration of a collection.",
|
||||
[]string{"collector"},
|
||||
nil,
|
||||
),
|
||||
scrapeSuccessDesc: prometheus.NewDesc(
|
||||
collectorScrapeSuccessDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, "exporter", "collector_success"),
|
||||
"windows_exporter: Whether the collector was successful.",
|
||||
[]string{"collector"},
|
||||
nil,
|
||||
),
|
||||
scrapeTimeoutDesc: prometheus.NewDesc(
|
||||
collectorScrapeTimeoutDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, "exporter", "collector_timeout"),
|
||||
"windows_exporter: Whether the collector timed out.",
|
||||
[]string{"collector"},
|
||||
@@ -60,133 +84,196 @@ func NewPrometheus(timeout time.Duration, cs *Collectors, logger log.Logger) *Pr
|
||||
}
|
||||
}
|
||||
|
||||
// Describe sends all the descriptors of the Collectors included to
|
||||
// the provided channel.
|
||||
func (coll *Prometheus) Describe(ch chan<- *prometheus.Desc) {
|
||||
ch <- coll.scrapeDurationDesc
|
||||
ch <- coll.scrapeSuccessDesc
|
||||
}
|
||||
func (p *Prometheus) Describe(_ chan<- *prometheus.Desc) {}
|
||||
|
||||
type collectorOutcome int
|
||||
|
||||
const (
|
||||
pending collectorOutcome = iota
|
||||
success
|
||||
failed
|
||||
)
|
||||
|
||||
// Collect sends the collected metrics from each of the Collectors to
|
||||
// Collect sends the collected metrics from each of the MetricCollectors to
|
||||
// prometheus.
|
||||
func (coll *Prometheus) Collect(ch chan<- prometheus.Metric) {
|
||||
func (p *Prometheus) Collect(ch chan<- prometheus.Metric) {
|
||||
t := time.Now()
|
||||
|
||||
scrapeContext, err := coll.collectors.PrepareScrapeContext()
|
||||
// Scrape Performance Counters for all collectors
|
||||
scrapeContext, err := p.metricCollectors.PrepareScrapeContext()
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
coll.snapshotDuration,
|
||||
p.snapshotDuration,
|
||||
prometheus.GaugeValue,
|
||||
time.Since(t).Seconds(),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
ch <- prometheus.NewInvalidMetric(coll.scrapeSuccessDesc, fmt.Errorf("failed to prepare scrape: %w", err))
|
||||
ch <- prometheus.NewInvalidMetric(p.collectorScrapeSuccessDesc, fmt.Errorf("failed to prepare scrape: %w", err))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// WaitGroup to wait for all collectors to finish
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(len(coll.collectors.collectors))
|
||||
collectorOutcomes := make(map[string]collectorOutcome)
|
||||
for name := range coll.collectors.collectors {
|
||||
collectorOutcomes[name] = pending
|
||||
}
|
||||
wg.Add(len(p.metricCollectors.Collectors))
|
||||
|
||||
metricsBuffer := make(chan prometheus.Metric)
|
||||
l := sync.Mutex{}
|
||||
finished := false
|
||||
go func() {
|
||||
for m := range metricsBuffer {
|
||||
l.Lock()
|
||||
if !finished {
|
||||
ch <- m
|
||||
}
|
||||
l.Unlock()
|
||||
}
|
||||
}()
|
||||
// Using a channel to collect the status of each collector
|
||||
// A channel is safe to use concurrently while a map is not
|
||||
collectorStatusCh := make(chan collectorStatus, len(p.metricCollectors.Collectors))
|
||||
|
||||
for name, c := range coll.collectors.collectors {
|
||||
go func(name string, c Collector) {
|
||||
// Execute all collectors concurrently
|
||||
// timeout handling is done in the execute function
|
||||
for name, metricsCollector := range p.metricCollectors.Collectors {
|
||||
go func(name string, metricsCollector Collector) {
|
||||
defer wg.Done()
|
||||
outcome := coll.execute(coll.logger, name, c, scrapeContext, metricsBuffer)
|
||||
l.Lock()
|
||||
if !finished {
|
||||
collectorOutcomes[name] = outcome
|
||||
|
||||
collectorStatusCh <- collectorStatus{
|
||||
name: name,
|
||||
statusCode: p.execute(name, metricsCollector, scrapeContext, ch),
|
||||
}
|
||||
l.Unlock()
|
||||
}(name, c)
|
||||
}(name, metricsCollector)
|
||||
}
|
||||
|
||||
allDone := make(chan struct{})
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(allDone)
|
||||
close(metricsBuffer)
|
||||
}()
|
||||
// Wait for all collectors to finish
|
||||
wg.Wait()
|
||||
|
||||
// Wait until either all Collectors finish, or timeout expires
|
||||
select {
|
||||
case <-allDone:
|
||||
case <-time.After(coll.maxScrapeDuration):
|
||||
}
|
||||
// Close the channel since we are done writing to it
|
||||
close(collectorStatusCh)
|
||||
|
||||
l.Lock()
|
||||
finished = true
|
||||
|
||||
remainingCollectorNames := make([]string, 0)
|
||||
for name, outcome := range collectorOutcomes {
|
||||
for status := range collectorStatusCh {
|
||||
var successValue, timeoutValue float64
|
||||
if outcome == pending {
|
||||
if status.statusCode == pending {
|
||||
timeoutValue = 1.0
|
||||
remainingCollectorNames = append(remainingCollectorNames, name)
|
||||
}
|
||||
if outcome == success {
|
||||
|
||||
if status.statusCode == success {
|
||||
successValue = 1.0
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
coll.scrapeSuccessDesc,
|
||||
p.collectorScrapeSuccessDesc,
|
||||
prometheus.GaugeValue,
|
||||
successValue,
|
||||
name,
|
||||
status.name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
coll.scrapeTimeoutDesc,
|
||||
p.collectorScrapeTimeoutDesc,
|
||||
prometheus.GaugeValue,
|
||||
timeoutValue,
|
||||
name,
|
||||
status.name,
|
||||
)
|
||||
}
|
||||
|
||||
if len(remainingCollectorNames) > 0 {
|
||||
_ = level.Warn(coll.logger).Log("msg", fmt.Sprintf("Collection timed out, still waiting for %v", remainingCollectorNames))
|
||||
}
|
||||
|
||||
l.Unlock()
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
p.scrapeDurationDesc,
|
||||
prometheus.GaugeValue,
|
||||
time.Since(t).Seconds(),
|
||||
)
|
||||
}
|
||||
|
||||
func (coll *Prometheus) execute(logger log.Logger, name string, c Collector, ctx *types.ScrapeContext, ch chan<- prometheus.Metric) collectorOutcome {
|
||||
t := time.Now()
|
||||
err := c.Collect(ctx, logger, ch)
|
||||
duration := time.Since(t).Seconds()
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
coll.scrapeDurationDesc,
|
||||
prometheus.GaugeValue,
|
||||
duration,
|
||||
name,
|
||||
func (p *Prometheus) execute(name string, c Collector, scrapeCtx *types.ScrapeContext, ch chan<- prometheus.Metric) collectorStatusCode {
|
||||
var (
|
||||
err error
|
||||
numMetrics int
|
||||
duration time.Duration
|
||||
timeout atomic.Bool
|
||||
)
|
||||
|
||||
// bufCh is a buffer channel to store the metrics
|
||||
// This is needed because once timeout is reached, the prometheus registry channel is closed.
|
||||
bufCh := make(chan prometheus.Metric, 1000)
|
||||
errCh := make(chan error, 1)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), p.maxScrapeDuration)
|
||||
defer cancel()
|
||||
|
||||
// Execute the collector
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
p.logger.Error("panic in collector "+name,
|
||||
slog.Any("panic", r),
|
||||
)
|
||||
}
|
||||
}()
|
||||
|
||||
errCh <- c.Collect(scrapeCtx, p.logger, bufCh)
|
||||
|
||||
close(bufCh)
|
||||
}()
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
// This prevents a panic from race-condition when closing the ch channel too early.
|
||||
_ = recover()
|
||||
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
// Pass metrics to the prometheus registry
|
||||
// If timeout is reached, the channel is closed.
|
||||
// This will cause a panic if we try to write to it.
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case m, ok := <-bufCh:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
if !timeout.Load() {
|
||||
ch <- m
|
||||
|
||||
numMetrics++
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
t := time.Now()
|
||||
|
||||
// Wait for the collector to finish or timeout
|
||||
select {
|
||||
case err = <-errCh:
|
||||
wg.Wait() // Wait for the buffer channel to be closed and empty
|
||||
|
||||
duration = time.Since(t)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
p.collectorScrapeDurationDesc,
|
||||
prometheus.GaugeValue,
|
||||
duration.Seconds(),
|
||||
name,
|
||||
)
|
||||
case <-ctx.Done():
|
||||
timeout.Store(true)
|
||||
|
||||
duration = time.Since(t)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
p.collectorScrapeDurationDesc,
|
||||
prometheus.GaugeValue,
|
||||
duration.Seconds(),
|
||||
name,
|
||||
)
|
||||
|
||||
p.logger.Warn(fmt.Sprintf("collector %s timeouted after %s, resulting in %d metrics", name, p.maxScrapeDuration, numMetrics))
|
||||
|
||||
go func() {
|
||||
// Drain channel in case of premature return to not leak a goroutine.
|
||||
//nolint:revive
|
||||
for range bufCh {
|
||||
}
|
||||
}()
|
||||
|
||||
return pending
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
_ = level.Error(coll.logger).Log("msg", fmt.Sprintf("collector %s failed after %fs", name, duration), "err", err)
|
||||
p.logger.Error(fmt.Sprintf("collector %s failed after %s, resulting in %d metrics", name, duration, numMetrics),
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return failed
|
||||
}
|
||||
|
||||
_ = level.Debug(coll.logger).Log("msg", fmt.Sprintf("collector %s succeeded after %fs.", name, duration))
|
||||
p.logger.Info(fmt.Sprintf("collector %s succeeded after %s, resulting in %d metrics", name, duration, numMetrics))
|
||||
|
||||
return success
|
||||
}
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
package remote_fx
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||
@@ -74,15 +73,15 @@ func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *Collector) GetPerfCounter(_ log.Logger) ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||
return []string{"RemoteFX Network", "RemoteFX Graphics"}, nil
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
func (c *Collector) Close(_ *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(log.Logger, *wmi.Client) error {
|
||||
func (c *Collector) Build(*slog.Logger, *wmi.Client) error {
|
||||
// net
|
||||
c.baseTCPRTT = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "net_base_tcp_rtt_seconds"),
|
||||
@@ -206,21 +205,30 @@ func (c *Collector) Build(log.Logger, *wmi.Client) error {
|
||||
[]string{"session_name"},
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
if err := c.collectRemoteFXNetworkCount(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting terminal services session count metrics", "err", err)
|
||||
logger.Error("failed collecting terminal services session count metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.collectRemoteFXGraphicsCounters(ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed collecting terminal services session count metrics", "err", err)
|
||||
logger.Error("failed collecting terminal services session count metrics",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -241,9 +249,10 @@ type perflibRemoteFxNetwork struct {
|
||||
RetransmissionRate float64 `perflib:"Percentage of packets that have been retransmitted"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectRemoteFXNetworkCount(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectRemoteFXNetworkCount(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
dst := make([]perflibRemoteFxNetwork, 0)
|
||||
|
||||
err := perflib.UnmarshalObject(ctx.PerfObjects["RemoteFX Network"], &dst, logger)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -336,6 +345,7 @@ func (c *Collector) collectRemoteFXNetworkCount(ctx *types.ScrapeContext, logger
|
||||
normalizeSessionName(d.Name),
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -352,9 +362,10 @@ type perflibRemoteFxGraphics struct {
|
||||
SourceFramesPerSecond float64 `perflib:"Source Frames/Second"`
|
||||
}
|
||||
|
||||
func (c *Collector) collectRemoteFXGraphicsCounters(ctx *types.ScrapeContext, logger log.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = log.With(logger, "collector", Name)
|
||||
func (c *Collector) collectRemoteFXGraphicsCounters(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
dst := make([]perflibRemoteFxGraphics, 0)
|
||||
|
||||
err := perflib.UnmarshalObject(ctx.PerfObjects["RemoteFX Graphics"], &dst, logger)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user