You've already forked postgres_exporter
mirror of
https://github.com/prometheus-community/postgres_exporter.git
synced 2025-08-14 01:02:26 +03:00
Add config module
The config module supports adding configuration to the exporter via a config file. This supports adding authentication details in a config file so that /probe requests can specify authentication for endpoints Signed-off-by: Joe Adams <github@joeadams.io>
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus-community/postgres_exporter/collector"
|
||||
"github.com/prometheus-community/postgres_exporter/config"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/prometheus/common/promlog"
|
||||
@@ -31,6 +32,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
c = config.ConfigHandler{
|
||||
Config: &config.Config{},
|
||||
}
|
||||
|
||||
configFile = kingpin.Flag("config.file", "Promehteus exporter configuration file.").Default("postres_exporter.yml").String()
|
||||
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9187").Envar("PG_EXPORTER_WEB_LISTEN_ADDRESS").String()
|
||||
webConfig = webflag.AddFlags(kingpin.CommandLine)
|
||||
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").Envar("PG_EXPORTER_WEB_TELEMETRY_PATH").String()
|
||||
@@ -85,6 +91,11 @@ 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.Error(logger).Log("msg", "Error loading config", "err", err)
|
||||
}
|
||||
|
||||
dsns, err := getDataSources()
|
||||
if err != nil {
|
||||
level.Error(logger).Log("msg", "Failed reading data sources", "err", err.Error())
|
||||
|
Reference in New Issue
Block a user