From b8747045cedb2cd549f46df9e3383617450ddac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sun, 12 May 2024 00:24:52 +0200 Subject: [PATCH] Enable process V1 performance counters by default (#1477) --- .github/workflows/release.yml | 2 -- Makefile | 4 ++++ README.md | 26 +++++++++++++++++--------- installer/build.ps1 | 3 +++ installer/windows_exporter.wxs | 26 ++++++++++++++++++++++++-- 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a2d9bf39..603fcc7e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,8 +77,6 @@ jobs: $ErrorActionPreference = "Stop" $BuildVersion = Get-Content VERSION $TagName = $env:GITHUB_REF -replace 'refs/tags/', '' - # The MSI version is not semver compliant, so just take the numerical parts - $MSIVersion = $TagName -replace '^v?([0-9\.]+).*$','$1' foreach($Arch in "amd64", "arm64") { Write-Verbose "Building windows_exporter $MSIVersion msi for $Arch" .\installer\build.ps1 -PathToExecutable .\output\windows_exporter-$BuildVersion-$Arch.exe -Version $MSIVersion -Arch "$Arch" diff --git a/Makefile b/Makefile index 2fe867f0..f9a3b546 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,10 @@ crossbuild: generate GOARCH=amd64 promu build --prefix=output/amd64 GOARCH=arm64 promu build --prefix=output/arm64 +.PHONY: package +package: crossbuild + powershell -NonInteractive -ExecutionPolicy Bypass -File .\installer\build.ps1 -PathToExecutable .\output\amd64\windows_exporter.exe -Version $(shell git describe --tags --abbrev=0) + build-image: crossbuild $(DOCKER) build --build-arg=BASE=$(BASE_IMAGE):$(OS) -f Dockerfile -t local/$(DOCKER_IMAGE_NAME):$(VERSION)-$(OS) . diff --git a/README.md b/README.md index c2ebab24..f9a4aed4 100644 --- a/README.md +++ b/README.md @@ -100,15 +100,17 @@ Each release provides a .msi installer. The installer will setup the windows_exp 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: -| 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 0.0.0.0 | -| `LISTEN_PORT` | The port to bind to. Defaults to 9182. | -| `METRICS_PATH` | The path at which to serve metrics. Defaults to `/metrics` | -| `TEXTFILE_DIRS` | As the `--collector.textfile.directories` flag, provide a directory to read text files with metrics from | -| `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. | +| 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` | As the `--collector.textfile.directories` flag, provide a directory to read text files with metrics from | +| `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`. | Parameters are sent to the installer via `msiexec`. Example invocations: @@ -133,6 +135,12 @@ To install the exporter with creating a firewall exception, use the following co msiexec /i ADD_FIREWALL_EXCEPTION=yes ``` +To repair an installation, e.g force re-creating Windows service: + +```powershell +msiexec /fa +``` + 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`: diff --git a/installer/build.ps1 b/installer/build.ps1 index 62606a49..69c4a245 100644 --- a/installer/build.ps1 +++ b/installer/build.ps1 @@ -10,6 +10,9 @@ Param ( ) $ErrorActionPreference = "Stop" +# The MSI version is not semver compliant, so just take the numerical parts +$Version = $Version -replace '^v?([0-9\.]+).*$','$1' + # Get absolute path to executable before switching directories $PathToExecutable = Resolve-Path $PathToExecutable # Set working dir to this directory, reset previous on exit diff --git a/installer/windows_exporter.wxs b/installer/windows_exporter.wxs index d3479fcc..e993a02f 100644 --- a/installer/windows_exporter.wxs +++ b/installer/windows_exporter.wxs @@ -5,7 +5,9 @@ - + + + @@ -16,7 +18,8 @@ - + + @@ -47,6 +50,25 @@ + + + + + + +