diff --git a/.editorconfig b/.editorconfig index 77b61139f..dd4715ef9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,4 +3,4 @@ root = true [*.wxs] indent_style = space -indent_size = 2 \ No newline at end of file +indent_size = 4 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f07f01a2..f7accd905 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,6 +62,7 @@ jobs: - 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 diff --git a/README.md b/README.md index 70b554239..81df33156 100644 --- a/README.md +++ b/README.md @@ -94,23 +94,33 @@ 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. + +The installer provides a configuration file to customize the exporter. + +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 | -| `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 `no`. | -| `ENABLE_V1_PERFORMANCE_COUNTERS` | Enables V1 performance counter on modern systems. Defaults to `yes`. | +| 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. | +| `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`. Example invocations: @@ -132,13 +142,7 @@ msiexec /i C:\Users\Administrator\Downloads\windows_exporter.msi ENABLED_COLLECT To install the exporter with creating a firewall exception, use the following command: ```powershell -msiexec /i ADD_FIREWALL_EXCEPTION=yes -``` - -To repair an installation, e.g force re-creating Windows service: - -```powershell -msiexec /fa +msiexec /i ADDLOCAL=FirewallException ``` diff --git a/installer/build.ps1 b/installer/build.ps1 index 11a56fd83..63b9df460 100644 --- a/installer/build.ps1 +++ b/installer/build.ps1 @@ -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 diff --git a/installer/files.wxs b/installer/files.wxs new file mode 100644 index 000000000..90794a97c --- /dev/null +++ b/installer/files.wxs @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/installer/main.wxs b/installer/main.wxs new file mode 100644 index 000000000..bfd8d18a8 --- /dev/null +++ b/installer/main.wxs @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/installer/windows_exporter.wxs b/installer/windows_exporter.wxs deleted file mode 100644 index 16a6c53f1..000000000 --- a/installer/windows_exporter.wxs +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -