Skip to content

Commit a52beb6

Browse files
committed
Add environment variable control for most command line options.
Adds the following environment variables for overriding defaults: * `PG_EXPORTER_WEB_LISTEN_ADDRESS` * `PG_EXPORTER_WEB_TELEMETRY_PATH` * `PG_EXPORTER_EXTEND_QUERY_PATH` Closes #150.
1 parent 946aa5d commit a52beb6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: postgres_exporter.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ import (
3232
var Version = "0.0.1"
3333

3434
var (
35-
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9187").String()
36-
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String()
37-
queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").Default("").String()
35+
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9187").OverrideDefaultFromEnvar("PG_EXPORTER_WEB_LISTEN_ADDRESS").String()
36+
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").OverrideDefaultFromEnvar("PG_EXPORTER_WEB_TELEMETRY_PATH").String()
37+
queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").Default("").OverrideDefaultFromEnvar("PG_EXPORTER_EXTEND_QUERY_PATH").String()
3838
onlyDumpMaps = kingpin.Flag("dumpmaps", "Do not run, simply dump the maps.").Bool()
3939
)
4040

@@ -1108,8 +1108,8 @@ func main() {
11081108

11091109
http.Handle(*metricPath, promhttp.Handler())
11101110
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
1111-
w.Header().Set("Content-Type", "Content-Type:text/plain; charset=UTF-8") // nolint: errcheck
1112-
w.Write(landingPage) // nolint: errcheck
1111+
w.Header().Set("Content-Type", "Content-Type:text/plain; charset=UTF-8") // nolint: errcheck
1112+
w.Write(landingPage) // nolint: errcheck
11131113
})
11141114

11151115
log.Infof("Starting Server: %s", *listenAddress)

0 commit comments

Comments
 (0)