Skip to content

Commit

Permalink
add web.listenAddress param, from --web.listenAddress or PG_EXPORTER_…
Browse files Browse the repository at this point in the history
…WEB_LISTEN_ADDRESS env get value
  • Loading branch information
yanboer committed Jun 5, 2023
1 parent 9422d8b commit 925a782
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/postgres_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var (
Config: &config.Config{},
}

listenAddress = kingpin.Flag("web.listenAddress", "Address to listen on for web interface and telemetry.").Default(":9187").Envar("PG_EXPORTER_WEB_LISTEN_ADDRESS").Strings()
configFile = kingpin.Flag("config.file", "Postgres exporter configuration file.").Default("postgres_exporter.yml").String()
webConfig = kingpinflag.AddFlags(kingpin.CommandLine, ":9187")
metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").Envar("PG_EXPORTER_WEB_TELEMETRY_PATH").String()
Expand Down Expand Up @@ -156,6 +157,8 @@ func main() {

http.HandleFunc("/probe", handleProbe(logger, excludedDatabases))

// set WebListenAddresses from PG_EXPORTER_WEB_LISTEN_ADDRESS env or --web.listenAddress param
webConfig.WebListenAddresses = listenAddress
srv := &http.Server{}
if err := web.ListenAndServe(srv, webConfig, logger); err != nil {
level.Error(logger).Log("msg", "Error running HTTP server", "err", err)
Expand Down

0 comments on commit 925a782

Please sign in to comment.