mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-11 03:31:26 +00:00
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.
This commit is contained in:
parent
946aa5db45
commit
a52beb60cb
@ -32,9 +32,9 @@ import (
|
|||||||
var Version = "0.0.1"
|
var Version = "0.0.1"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9187").String()
|
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9187").OverrideDefaultFromEnvar("PG_EXPORTER_WEB_LISTEN_ADDRESS").String()
|
||||||
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String()
|
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").OverrideDefaultFromEnvar("PG_EXPORTER_WEB_TELEMETRY_PATH").String()
|
||||||
queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").Default("").String()
|
queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").Default("").OverrideDefaultFromEnvar("PG_EXPORTER_EXTEND_QUERY_PATH").String()
|
||||||
onlyDumpMaps = kingpin.Flag("dumpmaps", "Do not run, simply dump the maps.").Bool()
|
onlyDumpMaps = kingpin.Flag("dumpmaps", "Do not run, simply dump the maps.").Bool()
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1108,8 +1108,8 @@ func main() {
|
|||||||
|
|
||||||
http.Handle(*metricPath, promhttp.Handler())
|
http.Handle(*metricPath, promhttp.Handler())
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "Content-Type:text/plain; charset=UTF-8") // nolint: errcheck
|
w.Header().Set("Content-Type", "Content-Type:text/plain; charset=UTF-8") // nolint: errcheck
|
||||||
w.Write(landingPage) // nolint: errcheck
|
w.Write(landingPage) // nolint: errcheck
|
||||||
})
|
})
|
||||||
|
|
||||||
log.Infof("Starting Server: %s", *listenAddress)
|
log.Infof("Starting Server: %s", *listenAddress)
|
||||||
|
Loading…
Reference in New Issue
Block a user