adding db auto discovery support to postgres
When using PostgreSQL, if the connection specifies exclude or include (only one can be specified), the exporter will create connections to the jobs based on the required databases. This parameter accepts a list of databases that can also be specified using regex, like so:
'postgres://postgres@localhost/exclude:postgres,test_db*?sslmode=disable'
Exactly what we need 👍🏼
@rezonick Do you have capacity to try this PR? I don't have availability to test it, but if it works for two people we can merge it.
@dewey i can confirm that this PR is working...
@dewey to elaborate more i took @noapinsler branch, build the dockerfile as is, and deploy it instead of the original sql exporter docker image with same config and values.
i then used this configmap for connecting to my postgres:
postgres://{{POSTGRES_USER}}:{{POSTGRES_PASSWORD}}@{{POSTGRES_URL}}:5432/include:org_*?sslmode=disable
postgres://{{POSTGRES_USER}}:{{POSTGRES_PASSWORD}}@{{POSTGRES_URL}}:5432/exclude:postgres?sslmode=disable
few logs example of top-tables logs that run with the second connection excluding the posgres db:
{"caller":"job.go:389","job":"top-tables","level":"debug","msg":"Running Query","query":"top_tables","ts":"2024-06-24T20:08:32.161510244Z"} {"caller":"job.go:389","job":"top-tables","level":"debug","msg":"Running Query","query":"top_tables","ts":"2024-06-24T20:08:32.161640149Z"} {"caller":"job.go:389","job":"top-tables","level":"debug","msg":"Running Query","query":"top_tables","ts":"2024-06-24T20:08:32.16169112Z"} {"caller":"job.go:389","job":"top-tables","level":"debug","msg":"Running Query","query":"top_tables","ts":"2024-06-24T20:08:32.163286563Z"}
its being working for few days now and works good!
@noapinsler Would you have time to replace the print statements with logging statements like in the rest of the file? Once that's done I can merge and create a release.
@orilani Thanks for taking the time to test it, sounds good!
@dewey , I changed the printf to logger as in the rest of the file.
Thanks!
A new release is out, the Docker image is still being pushed but will be available shortly. Thanks for the contribution!