Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions cmd/postgres_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ var (
Config: &config.Config{},
}

configFile = kingpin.Flag("config.file", "Postgres exporter configuration file.").Default("postgres_exporter.yml").String()
// Default is empty so you don't need a config file if using only DSN settings.
configFile = kingpin.Flag("config.file", "Postgres exporter configuration file.").Default("").String()
webConfig = kingpinflag.AddFlags(kingpin.CommandLine, ":9187")
webConfigFile = kingpin.Flag(
"web.config",
Expand Down Expand Up @@ -89,9 +90,13 @@ func main() {
return
}

if err := c.ReloadConfig(*configFile, logger); err != nil {
// This is not fatal, but it means that auth must be provided for every dsn.
level.Warn(logger).Log("msg", "Error loading config", "err", err)
// Load the config file if specified, otherwise use default/DSN settings
if *configFile != "" {
if err := c.ReloadConfig(*configFile, logger); err != nil {
level.Warn(logger).Log("msg", "Error loading config", "err", err)
}
} else {
level.Debug(logger).Log("msg", "No config file provided, using default/DSN settings")
}

dsns, err := getDataSources()
Expand All @@ -103,10 +108,6 @@ func main() {
excludedDatabases := strings.Split(*excludeDatabases, ",")
logger.Log("msg", "Excluded databases", "databases", fmt.Sprintf("%v", excludedDatabases))

// if *queriesPath != "" {
// level.Warn(logger).Log("msg", "The extended queries.yaml config is DEPRECATED", "file", *queriesPath)
// }

Comment on lines -106 to -109
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated 2 years ago, removing.

if *autoDiscoverDatabases || *excludeDatabases != "" || *includeDatabases != "" {
level.Warn(logger).Log("msg", "Scraping additional databases via auto discovery is DEPRECATED")
}
Expand Down