prometheus-community / pgbouncer_exporter

Prometheus exporter for PgBouncer
MIT License
140 stars 49 forks source link

Allow configuration through config file and from args #153

Open SoulKyu opened 4 months ago

SoulKyu commented 4 months ago

Hello,

Ive implemented a little piece of code that allow to use a configFile for configuration.

Actually you can still provide configuration from args and now from configFile also.

It doesn't do anything if you didn't provide the --config.file so its safe for existing deployment.

A configuration can look like :

{
  "pgBouncer.connectionString": "postgres://username:password@hostname:port/dbname?sslmode=disable",
  "web.telemetry-path": "/metrics",
  "pgBouncer.pid-file": "/path/to/pgbouncer.pid"
}

Its a small modification, actually i think another config / args implementation like viper / kong should be used instead of kingpin which is not realy maintained anymore. (in my point of view, using a lib for a little project like this is overkill and maybe a simple implementation could be better).

For security consideration, i think my PR would be very benefit as now credentials would be in a config-file instead of args.

Hope you will agree to merge :)

Thanks you

stanhu commented 2 months ago

Thanks! Could you resolve the conflicts and add some documentation to README.md?