From 634095b289d6b1527c756baff6823fb5d30a82df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Ctvrtka?= Date: Thu, 26 Feb 2026 14:08:05 +0100 Subject: [PATCH] PMM-14857 Prevent warning. --- cmd/postgres_exporter/main.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/postgres_exporter/main.go b/cmd/postgres_exporter/main.go index 07f0e542a..5f91323b1 100644 --- a/cmd/postgres_exporter/main.go +++ b/cmd/postgres_exporter/main.go @@ -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", @@ -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() @@ -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) - // } - if *autoDiscoverDatabases || *excludeDatabases != "" || *includeDatabases != "" { level.Warn(logger).Log("msg", "Scraping additional databases via auto discovery is DEPRECATED") }