windows_exporter: 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 image

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 image

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: image

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?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (2 by maintainers)

Most upvoted comments

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?

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"""

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.

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