windows_exporter
windows_exporter copied to clipboard
Unable to start windows_exporter with a configuration file in the default location
Unable to start windows_exporter with a configuration file in the default location
Steps to reproduce:
OS: Win 10 Pro 10.0.19041 User with a Administrator privileges
First scenario: Default config
1)Create folder C:\Program Files\windows_exporter with the following files:
windows_exporter-0.15.0-amd64.msi config.yml
config.yml file content:
collectors:
enabled: service
collector:
service:
services-where: "Name='<any_existing_service>'"
log:
level: warn
2)Execute the following command in PowerShell (under Administrator)
msiexec /i C:\Program Files\windows_exporter\windows_exporter-0.15.0-amd64.msi
Expected result:
The windows_exporter is up and running with parameters from the C:\Program Files\windows_exporter\config.yml file
Actual result:
The windows installer popup like this
Second scenario: Explicitly add a path to the config file in the C:\Program Files\windows_exporter directory
1)Create folder C:\Program Files\windows_exporter with the following files:
windows_exporter-0.15.0-amd64.msi config.yml
config.yml file content:
collectors:
enabled: service
collector:
service:
services-where: "Name='<any_existing_service>'"
log:
level: warn
2)Execute the following command in PowerShell (under Administrator)
msiexec /i C:\Program Files\windows_exporter\windows_exporter-0.15.0-amd64.msi --% EXTRA_FLAGS="--config.file=C:\Program Files\windows_exporter\config.yml"
Expected result:
The windows_exporter is up and running with parameters from the C:\Program Files\windows_exporter\config.yml file
Actual result:
The windows installer popup like this
Third scenario: Explicitly add a path to the config file in the C:\Program Files\windows_exporter directory and locate windows_exporter-0.15.0-amd64.msi installation file in C:\windows_exporter folder
1)Create folder C:\windows_exporter with the following file:
windows_exporter-0.15.0-amd64.msi
Create folder C:\Program Files\windows_exporter with the following file:
config.yml
config.yml file content:
collectors:
enabled: service
collector:
service:
services-where: "Name='<any_existing_service>'"
log:
level: warn
2)Execute the following command in PowerShell (under Administrator)
msiexec /i C:\windows_exporter\windows_exporter-0.15.0-amd64.msi --% EXTRA_FLAGS="--config.file=C:\Program Files\windows_exporter\config.yml"
Expected result:
The windows_exporter is up and running with parameters from the C:\Program Files\windows_exporter\config.yml file
Actual result:
Error popup:
Fourth scenario: Explicitly add a path to the config file in the C:\windows_exporter directory
1)Create folder C:\windows_exporter with the following files:
windows_exporter-0.15.0-amd64.msi config.yml file content:
collectors:
enabled: service
collector:
service:
services-where: "Name='<any_existing_service>'"
log:
level: warn
3)Execute the following command in PowerShell (under Administrator)
msiexec /i C:\windows_exporter\windows_exporter-0.15.0-amd64.msi --% EXTRA_FLAGS="--config.file=C:\windows_exporter\config.yml"
Expected result:
windows_exporter is up and running with parameters from the C:\windows_exporter\config.yml file
Actual result: The windows_exporter is up and running
Question: How to start windows_exporter with a configuration file in the default location?
Hi @qmonitoring, It looks to me like the first two cases are caused by not properly quoting the path to the msi file, causing msiexec to pop the help dialog since it couldn't figure out what to do. In the third case, it looks like a similar problem, you haven't quoted the path to the config file. The fourth case works because you do not have any spaces that need to be escaped.
@carlpett Thank you very much for such a quick response! Indeed, if the path is correct, windows_exporter is up and running, but no default configuration has been applied:
Scenario: 1)Create folder C:\Program Files\windows_exporter with the following files:
windows_exporter-0.15.0-amd64.msi config.yml
Execute the following command in PowerShell (under Administrator) msiexec /i "C:\Program Files\windows_exporter\windows_exporter-0.15.0-amd64.msi"
Actual result: Scraping of all default metrics, not just those specified in the config file
Yes, you need to specify that you want to use the file. Currently, we do not read the file unasked, as a way to simplify the feature and get it finished. We might add it later, but for now you have to use the --config.file
flag.
The "Second scenario" with correct path quotation also doesn't work:
1)Create folder C:\Program Files\windows_exporter with the following files:
windows_exporter-0.15.0-amd64.msi config.yml
2)Execute the following command in PowerShell (under Administrator) msiexec /i "C:\Program Files\windows_exporter\windows_exporter-0.15.0-amd64.msi" --% EXTRA_FLAGS="--config.file=C:\Program Files\windows_exporter\config.yml"
Actual result:
Error popup
Yes, you need to specify that you want to use the file. Currently, we do not read the file unasked, as a way to simplify the feature and get it finished. We might add it later, but for now you have to use the
--config.file
flag.
Could you please clarify how to use this flag with an example of a full command?
You should be seeing logs in the event viewer that says why it is going wrong when it is getting this far. In this case, I'd guess they'll indicate you also need to quote the config.file
path.
Could you please clarify how to use this flag with an example of a full command? There's a bit of nested quoting required, I think this would be it (I don't have a test environment available right now):
msiexec /i "C:\Program Files\windows_exporter\windows_exporter-0.15.0-amd64.msi" --% EXTRA_FLAGS="--config.file=""C:\Program Files\windows_exporter\\config.yml""
But since it's in the working directory of the executable, msiexec /i "C:\Program Files\windows_exporter\windows_exporter-0.15.0-amd64.msi" --% EXTRA_FLAGS="--config.file=.\config.yml"
should work, I believe.
@carlpett thank you for your reply! With your help I have found the solution.
Eventually I have found that the appropriate command is
msiexec /i "C:\Program Files\windows_exporter\windows_exporter-0.15.0-amd64.msi" --% EXTRA_FLAGS="--config.file=""C:\Program Files\windows_exporter\config.yml"""
Unfortunately, none of the combinations of the relative path quoting led to the desired result.
Hi,
I have the same need to use a config file and the same issue with the msi installer:
msiexec /i C:\Users\Administrator\Downloads\windows_exporter-0.15.0-amd64.msi /log msiexec.log EXTRA_FLAGS="--config.file=config.yml"
This ends up in the message mentioned above "Can't start the service"...
The logfile:
msiexec.log
The lines with the error:
Error 1920. Service 'windows_exporter' (windows_exporter) failed to start. Verify that you have sufficient privileges to start system services. MSI (s) (C0:2C) [19:30:32:327]: Product: windows_exporter -- Error 1920. Service 'windows_exporter' (windows_exporter) failed to start. Verify that you have sufficient privileges to start system services.
btw.
Property(C): EXTRA_FLAGS = --config.file=config.yml
looks good, right?
Asking Dr. Google for 1920 is not really helpful but one hint I found: Ask the application event log and there I found the following:
could not load config file: CreateFile config.yml: Das System kann die angegebene Datei nicht finden.
uhhh. ok, now I copied the config.yml to C:\Temp etc... but no, it's C:\Windows\System32 where the config.yml (in my case) must exists. (Path where the "system services" starts.)
I think it's a kind of race condition that the config.yml must exist while the installer is running and if not the installer can't proceed.
Hope that helps, Kai
@Ka-Hen I ran into the same issue. If you use "unix style" in the parameter for config file, it works. ImagePath example from registry : "C:\Program Files\windows_exporter\windows_exporter.exe" --log.format logger:eventlog?name=windows_exporter --config.file=c:/winexporter/winexp.yml Maybe, you have to escape the backslashes otherwise. Windows :=) Anyway, why does config.file require "=" instead of ":" ?
@Ka-Hen
it's C:\Windows\System32 where the config.yml (in my case) must exists.
Interesting, I'd expected the working directory to the be installation dir. We'll need to see if that can be adjusted.
I think it's a kind of race condition that the config.yml must exist while the installer is running and if not the installer can't proceed.
This is a good point, which I think we didn't take into account. The expectation was perhaps that users who need the configuration file approach would be doing custom installations using some 3rd party tool rather than using the msi file. What would you consider a reasonable approach? I do not believe that we should start the exporter if the specified configuration file is not in place, and I do think we want to start the service automatically. Which seems hard to resolve, unless we say that the user must have pre-created the installation directory and placed the configuration file there? @breed808 what do you think?
@frank2b All flags use = to separate flag name and value. Perhaps you are comparing with the log.format flag, where the : is actually part of the value? --log.format logger:eventlog?name=windows_exporter
is equivalent to --log.format=logger:eventlog?name=windows_exporter
@carlpett Hej Calle, my bad :=), sorry. If I my list my wish list, I would like the following (I use Ansible to install the service) :
- when parameter --config.file is given, the config file must exist (like it is implemented right now)
- config file should be given by either absolute path (my favourite in Windows but ...) or relative to the "windows_exporter home dir", i.ex "config.yml" or "config\win_exp.yml" where config is subdir in home dir
- backslash should be supported without need for escaping
- plus https support but that is another thing :=)
@carlpett I'm inclined to agree. The configuration file seems best suited where dynamic configuration of the exporter is desired. Custom tools (Ansible, Puppet, scripts, etc) are best placed to handle this situation, as the configuration file will need to be set before running the exporter, and changes to the configuration will need to trigger a restart of the exporter. Static installations where configuration changes are not made could be done via the MSI, with SCCM or another method of MSI installation.
Treating a missing configuration file as a soft-fail would violate the principal of least surprise. Users expecting particular metrics from an exporter that is running successfully might be confused as to why their configuration has not applied.
it's C:\Windows\System32 where the config.yml (in my case) must exists. Interesting, I'd expected the working directory to the be installation dir. We'll need to see if that can be adjusted.
I would expect the directory where the executable is located or the LOCAL_APPDATA directory (Environment.SpecialFolder.LocalApplicationData) . AFAIK for services it's something like C:\WINDOWS\system32\config\systemprofile\AppData\Local + AppName. The path differs from OS.
I think it's a kind of race condition that the config.yml must exist while the installer is running and if not the installer can't proceed. This is a good point, which I think we didn't take into account. The expectation was perhaps that users who need the configuration file approach would be doing custom installations using some 3rd party tool rather than using the msi file. What would you consider a reasonable approach? I do not believe that we should start the exporter if the specified configuration file is not in place, and I do think we want to start the service automatically. Which seems hard to resolve, unless we say that the user must have pre-created the installation directory and placed the configuration file there? @breed808 what do you think?
My personal recommendation is to remove the "--config-file" from EXTRA_FLAGS and use a common default path. If the config file exits, is readable, etc. it is used by the services. If not use the default / command line arguments. A message in the event look is helpful to be transparent. From which path the config file is used or not because it was not found.
Maybe I'm too late but this command is working for me (Win10)
msiexec /i "c:\Scripts\windows_exporter\windows_exporter.msi" --% EXTRA_FLAGS="--config.file=c:\Scripts\windows_exporter\config.yml"
I thought I had it, but I was wrong. Command I'm using, seemingly like the others listed:
msiexec /i "C:\windows_exporter\windows_exporter-0.15.0-amd64.msi" TEXTFILE_DIR="C:\windows_exporter\custom_metrics" --% EXTRA_FLAGS="--config.file=C:\windows_exporter\config.yml"
I opted to forgo the config file, which is frustrating.
msiexec /i "C:\windows_exporter\windows_exporter-0.15.0-amd64.msi" ENABLED_COLLECTORS=cpu,cs,logical_disk,net,os,service,system,textfile,thermalzone,process,memory LISTEN_PORT=9182
Hi @jehanalvani,
I will test the install with config file and it's doesn't work when i set the config file on the native repository (C:\Program Files\windows_exporter\config.yml) the installer say me that :
ExecFirewallExceptions: Installing firewall exception2 windows_exporter (HTTP 9182) (C:\Program Files\windows_exporter\windows_exporter.exe) Error 1920. Service 'windows_exporter' (windows_exporter) failed to start. Verify that you have sufficient privileges to start system services. MSI (s) (B8:04) [17:35:04:995]: Product: windows_exporter -- Error 1920. Service 'windows_exporter' (windows_exporter) failed to start. Verify that you have sufficient privileges to start system services.
You need to setup this on another file i push this on my salt repository (C:\salt) and it's work like this :
msiexec /i windows_exporter-0.15.0-amd64.msi EXTRA_FLAGS="--config.file=C:\salt\config.yml /qn
My config file if you want in attachement. config.yml.txt
This works for me when run from cmd.exe:
msiexec.exe /i "C:\Users\me\AppData\Local\Temp\windows_exporter-0.16.0-amd64.msi" TEXTFILE_DIR="""C:\Program Files\windows_exporter\textfile_inputs""" EXTRA_FLAGS="--config.file=""C:\Program Files\windows_exporter\config.yml"""
needed to do extra single quotes to get it to work:
msiexec.exe /i '"C:\windows\temp\windows_exporter.msi" EXTRA_FLAGS="--config.file=""C:\Program Files\windows_exporter\config.yml"""'
I think this can be closed.
why do we need to run an MSI with a bunch of custom args? Why doesnt the installer deliver a config.yml to the installed directory and set the service to use that file?
-or- have windows_exporter.exe look in its own directory for a conventionally named config.yml file?
Many of the attempts above include --%. That's not valid syntax for msiexec, so will throws an msiinstall error. It looks like someone then also used to this to create the Chocolatey package which also doesn't install for the same reason. Readme.md should read
msiexec /i
not
msiexec /i
I have managed to add the configuration file as follows:
msiexec.exe /i C:\monit\windows_exporter.msi EXTRA_FLAGS="--config.file=""C:\monit\config.yml"""
why do we need to run an MSI with a bunch of custom args? Why doesnt the installer deliver a config.yml to the installed directory and set the service to use that file?
The configuration file isn't intended to be used with the MSI, but rather with the EXE and some form of configuration management.
The MSI is intended for deployments lacking configuration management, such as SCCM, which allow setting installation options but not management of files outside the MSI.
have windows_exporter.exe look in its own directory for a conventionally named config.yml file?
This could be done. If --config-file
is not specified but a file exists in a default location, such as C:\windows_exporter\config.yml
we could read it.
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.