Fix exporter failing to start without config flag

Signed-off-by: Ben Reedy <breed808@breed808.com>
This commit is contained in:
Ben Reedy 2020-11-03 17:07:23 +10:00
parent f623c0ed89
commit f616589c5f
No known key found for this signature in database
GPG Key ID: 235C15B6086C9D7E
2 changed files with 16 additions and 16 deletions

View File

@ -154,8 +154,6 @@ An example configuration file can be found [here](docs/example_config.yml).
#### Configuration file notes
If the `--config.file` flag is not specified, `windows_exporter` will look for a file located at `%programfiles\windows_exporter\config.yml` by default. If no file is found, CLI flags are processed as per normal.
Configuration file values can be mixed with CLI flags. E.G.
`.\windows_exporter.exe --collectors.enabled=cpu,logon`

View File

@ -273,8 +273,8 @@ func main() {
app = kingpin.New("windows_exporter", "")
configFile = app.Flag(
"config.file",
"YAML configuration file to use. Values set in this file will override flags.",
).Default(os.ExpandEnv("$ProgramFiles\\windows_exporter\\config.yml")).String()
"YAML configuration file to use. Values set in this file will be overriden by CLI flags.",
).String()
listenAddress = app.Flag(
"telemetry.addr",
"host:port for exporter.",
@ -311,6 +311,7 @@ func main() {
if err != nil {
log.Fatalf("%v\n", err)
}
if *configFile != "" {
resolver, err := config.NewResolver(*configFile)
if err != nil {
log.Fatalf("could not load config file: %v\n", err)
@ -324,6 +325,7 @@ func main() {
if err != nil {
log.Fatalf("%v\n", err)
}
}
if *printCollectors {
collectors := collector.Available()