Skip to content

Commit 6c2380b

Browse files
authored
installer: disable config file creation, if CONFIG_FILE is set to a non default location. (#2162)
1 parent 5266f9e commit 6c2380b

File tree

2 files changed

+57
-57
lines changed

2 files changed

+57
-57
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ This can be useful for having different Prometheus servers collect specific metr
8282

8383
windows_exporter accepts flags to configure certain behaviours. The ones configuring the global behaviour of the exporter are listed below, while collector-specific ones are documented in the respective collector documentation above.
8484

85-
| Flag | Description | Default value |
86-
|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
87-
| `--web.listen-address` | host:port for exporter. | `:9182` |
88-
| `--telemetry.path` | URL path for surfacing collected metrics. | `/metrics` |
89-
| `--collectors.enabled` | Comma-separated list of collectors to use. Use `[defaults]` as a placeholder which gets expanded containing all the collectors enabled by default. | `[defaults]` |
90-
| `--scrape.timeout-margin` | Seconds to subtract from the timeout allowed by the client. Tune to allow for overhead or high loads. | `0.5` |
91-
| `--web.config.file` | A [web config][web_config] for setting up TLS and Auth | None |
92-
| `--config.file` | [Using a config file](#using-a-configuration-file) from path or URL | None |
93-
| `--log.file` | Output file of log messages. One of [stdout, stderr, eventlog, \<path to log file>]<br>**NOTE:** The MSI installer will add a default argument to the installed service setting this to eventlog | stderr |
85+
| Flag | Description | Default value |
86+
|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
87+
| `--web.listen-address` | host:port for exporter. | `:9182` |
88+
| `--telemetry.path` | URL path for surfacing collected metrics. | `/metrics` |
89+
| `--collectors.enabled` | Comma-separated list of collectors to use. Use `[defaults]` as a placeholder which gets expanded containing all the collectors enabled by default. | `[defaults]` |
90+
| `--scrape.timeout-margin` | Seconds to subtract from the timeout allowed by the client. Tune to allow for overhead or high loads. | `0.5` |
91+
| `--web.config.file` | A [web config][web_config] for setting up TLS and Auth | None |
92+
| `--config.file` | [Using a config file](#using-a-configuration-file) from path | None |
93+
| `--log.file` | Output file of log messages. One of [stdout, stderr, eventlog, \<path to log file>]<br>**NOTE:** The MSI installer will add a default argument to the installed service setting this to eventlog | stderr |
9494

9595
## Installation
9696

@@ -112,19 +112,19 @@ The configuration file
112112

113113
The following parameters are available:
114114

115-
| Name | Description |
116-
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
117-
| `ENABLED_COLLECTORS` | As the `--collectors.enabled` flag, provide a comma-separated list of enabled collectors |
118-
| `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 | |
119-
| `LISTEN_ADDR` | The IP address to bind to. Defaults to an empty string. (any local address) |
120-
| `LISTEN_PORT` | The port to bind to. Defaults to `9182`. |
121-
| `METRICS_PATH` | The path at which to serve metrics. Defaults to `/metrics` |
122-
| `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 |
123-
| `REMOTE_ADDR` | Allows setting comma separated remote IP addresses for the Windows Firewall exception (allow list). Defaults to an empty string (any remote address). |
124-
| `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` |
125-
| `ADDLOCAL` | Enables features within the windows_exporter installer. Supported values: `FirewallException` |
126-
| `REMOVE` | Disables features within the windows_exporter installer. Supported values: `FirewallException` |
127-
| `APPLICATIONFOLDER` | Directory to install windows_exporter. Defaults to `C:\Program Files\windows_exporter` |
115+
| Name | Description |
116+
|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
117+
| `ENABLED_COLLECTORS` | As the `--collectors.enabled` flag, provide a comma-separated list of enabled collectors |
118+
| `CONFIG_FILE` | Use the `--config.file` flag to specify a config file. If empty, default config file at install dir will be used. If set, the config file must be exist before the installation is started. | |
119+
| `LISTEN_ADDR` | The IP address to bind to. Defaults to an empty string. (any local address) |
120+
| `LISTEN_PORT` | The port to bind to. Defaults to `9182`. |
121+
| `METRICS_PATH` | The path at which to serve metrics. Defaults to `/metrics` |
122+
| `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 |
123+
| `REMOTE_ADDR` | Allows setting comma separated remote IP addresses for the Windows Firewall exception (allow list). Defaults to an empty string (any remote address). |
124+
| `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` |
125+
| `ADDLOCAL` | Enables features within the windows_exporter installer. Supported values: `FirewallException` |
126+
| `REMOVE` | Disables features within the windows_exporter installer. Supported values: `FirewallException` |
127+
| `APPLICATIONFOLDER` | Directory to install windows_exporter. Defaults to `C:\Program Files\windows_exporter` |
128128

129129
> [!NOTE]
130130
> The installer properties are always preferred over the values defined in the config file. If you prefer to configure via the config file, avoid using any of the properties listed above.

installer/main.wxs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,40 @@
4545
Property="OLDERVERSIONBEINGUPGRADED" />
4646
</Upgrade>
4747

48+
<Media Id="1" Cabinet="windows_exporter.cab" EmbedCab="yes" />
49+
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." AllowSameVersionUpgrades="yes" />
50+
51+
<Property Id="ENABLED_COLLECTORS" Secure="yes" />
52+
<SetProperty Id="CollectorsFlag" After="InstallFiles" Sequence="execute" Value="--collectors.enabled [ENABLED_COLLECTORS]" Condition="ENABLED_COLLECTORS" />
53+
54+
<Property Id="EXTRA_FLAGS" Secure="yes" />
55+
<SetProperty Id="ExtraFlags" After="InstallFiles" Sequence="execute" Value="[EXTRA_FLAGS]" Condition="EXTRA_FLAGS" />
56+
57+
<Property Id="CONFIG_FILE" Secure="yes" Value="config.yaml" />
58+
<SetProperty Id="ConfigFile_NonDefault" After="InstallFiles" Sequence="execute" Value="[CONFIG_FILE]" Condition="CONFIG_FILE AND CONFIG_FILE&lt;&gt;&quot;config.yaml&quot;" />
59+
<SetProperty Id="ConfigFile_Default" After="InstallFiles" Sequence="execute" Value="[APPLICATIONFOLDER]config.yaml" Condition="CONFIG_FILE=&quot;config.yaml&quot;" />
60+
<SetProperty Id="ConfigFileFlag" After="InstallFiles" Sequence="execute" Value="--config.file=&quot;[ConfigFile_NonDefault][ConfigFile_Default]&quot;" Condition="ConfigFile_NonDefault OR ConfigFile_Default" />
61+
62+
<Property Id="LISTEN_PORT" Secure="yes" Value="9182" />
63+
<SetProperty Id="ListenFlag" After="InstallFiles" Sequence="execute" Value="--web.listen-address=&quot;[LISTEN_ADDR]:[LISTEN_PORT]&quot;" Condition="LISTEN_ADDR&lt;&gt;&quot;&quot; OR LISTEN_PORT&lt;&gt;9182" />
64+
65+
<Property Id="METRICS_PATH" Secure="yes" />
66+
<SetProperty Id="MetricsPathFlag" After="InstallFiles" Sequence="execute" Value="--telemetry.path=&quot;[METRICS_PATH]&quot;" Condition="METRICS_PATH" />
67+
68+
<Property Id="REMOTE_ADDR" Secure="yes" />
69+
<SetProperty Id="RemoteAddressFlag" After="InstallFiles" Sequence="execute" Value="[REMOTE_ADDR]" Condition="REMOTE_ADDR" />
70+
71+
<Property Id="TEXTFILE_DIRS" Secure="yes" />
72+
<SetProperty Id="TextfileDirsFlag" After="InstallFiles" Sequence="execute" Value="--collector.textfile.directories=&quot;[TEXTFILE_DIRS]&quot;" Condition="TEXTFILE_DIRS" />
73+
74+
<Property Id="ARPHELPLINK" Value="https://github.com/prometheus-community/windows_exporter/issues" />
75+
<Property Id="ARPSIZE" Value="9000" />
76+
<Property Id="ARPURLINFOABOUT" Value="https://github.com/prometheus-community/windows_exporter" />
77+
<!--<Property Id="ARPNOMODIFY" Value="0" />-->
78+
<!--<Property Id="ARPNOREPAIR" Value="1" />-->
79+
<Property Id="START_MENU_FOLDER" Value="0" />
80+
<Property Id="NOSTART" Value="0" />
81+
4882
<CustomAction Id="CheckExtraFlags"
4983
Error="The parameter '--config.file' must not be included in EXTRA_FLAGS. Use CONFIG_FILE instead. Please remove it and try again." />
5084

@@ -100,47 +134,13 @@
100134
Condition="Installed AND (NOT REMOVE) AND (NOT UPGRADINGPRODUCTCODE)"/>
101135
<Custom Action="set_reinstall_all_property" Before="set_reinstallmode_property" Condition="MAINTENANCE"/>
102136
<Custom Action="set_reinstallmode_property" Before="LaunchConditions" Condition="MAINTENANCE"/>
103-
<Custom Action="CreateConfigFile" Before="InstallServices" Condition="ConfigFile_NonDefault OR ConfigFile_Default" />
137+
<Custom Action="CreateConfigFile" Before="InstallServices" Condition="ConfigFile_Default" />
104138
<Custom Action="KillProcess" Before="RemoveFiles" />
105139

106140
<Custom Action="CheckExtraFlags" Before="InstallInitialize"
107141
Condition="EXTRA_FLAGS AND (EXTRA_FLAGS&gt;&lt;&quot;--config.file&quot;)" />
108142
</InstallExecuteSequence>
109143

110-
<Media Id="1" Cabinet="windows_exporter.cab" EmbedCab="yes" />
111-
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." AllowSameVersionUpgrades="yes" />
112-
113-
<Property Id="ENABLED_COLLECTORS" Secure="yes" />
114-
<SetProperty Id="CollectorsFlag" After="InstallFiles" Sequence="execute" Value="--collectors.enabled [ENABLED_COLLECTORS]" Condition="ENABLED_COLLECTORS" />
115-
116-
<Property Id="EXTRA_FLAGS" Secure="yes" />
117-
<SetProperty Id="ExtraFlags" After="InstallFiles" Sequence="execute" Value="[EXTRA_FLAGS]" Condition="EXTRA_FLAGS" />
118-
119-
<Property Id="CONFIG_FILE" Secure="yes" Value="config.yaml" />
120-
<SetProperty Id="ConfigFile_NonDefault" After="InstallFiles" Sequence="execute" Value="[CONFIG_FILE]" Condition="CONFIG_FILE AND CONFIG_FILE&lt;&gt;&quot;config.yaml&quot;" />
121-
<SetProperty Id="ConfigFile_Default" After="InstallFiles" Sequence="execute" Value="[APPLICATIONFOLDER]config.yaml" Condition="CONFIG_FILE=&quot;config.yaml&quot;" />
122-
<SetProperty Id="ConfigFileFlag" After="InstallFiles" Sequence="execute" Value="--config.file=&quot;[ConfigFile_NonDefault][ConfigFile_Default]&quot;" Condition="ConfigFile_NonDefault OR ConfigFile_Default" />
123-
124-
<Property Id="LISTEN_PORT" Secure="yes" Value="9182" />
125-
<SetProperty Id="ListenFlag" After="InstallFiles" Sequence="execute" Value="--web.listen-address=&quot;[LISTEN_ADDR]:[LISTEN_PORT]&quot;" Condition="LISTEN_ADDR&lt;&gt;&quot;&quot; OR LISTEN_PORT&lt;&gt;9182" />
126-
127-
<Property Id="METRICS_PATH" Secure="yes" />
128-
<SetProperty Id="MetricsPathFlag" After="InstallFiles" Sequence="execute" Value="--telemetry.path=&quot;[METRICS_PATH]&quot;" Condition="METRICS_PATH" />
129-
130-
<Property Id="REMOTE_ADDR" Secure="yes" />
131-
<SetProperty Id="RemoteAddressFlag" After="InstallFiles" Sequence="execute" Value="[REMOTE_ADDR]" Condition="REMOTE_ADDR" />
132-
133-
<Property Id="TEXTFILE_DIRS" Secure="yes" />
134-
<SetProperty Id="TextfileDirsFlag" After="InstallFiles" Sequence="execute" Value="--collector.textfile.directories=&quot;[TEXTFILE_DIRS]&quot;" Condition="TEXTFILE_DIRS" />
135-
136-
<Property Id="ARPHELPLINK" Value="https://github.com/prometheus-community/windows_exporter/issues" />
137-
<Property Id="ARPSIZE" Value="9000" />
138-
<Property Id="ARPURLINFOABOUT" Value="https://github.com/prometheus-community/windows_exporter" />
139-
<!--<Property Id="ARPNOMODIFY" Value="0" />-->
140-
<!--<Property Id="ARPNOREPAIR" Value="1" />-->
141-
<Property Id="START_MENU_FOLDER" Value="0" />
142-
<Property Id="NOSTART" Value="0" />
143-
144144
<Feature
145145
Id="DefaultFeature"
146146
Level="1"

0 commit comments

Comments
 (0)