0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-05-17 22:52:21 +00:00

postgres module: connect via uri ()

* add connection via URI support

* update config

* update readme

* change link
This commit is contained in:
Ilya Mashchenko 2019-04-01 12:25:03 +03:00 committed by GitHub
parent 2b7bb1daee
commit 53fbf2eb9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions
collectors/python.d.plugin/postgres

View file

@ -23,6 +23,7 @@ DEFAULT_CONNECT_TIMEOUT = 2 # seconds
DEFAULT_STATEMENT_TIMEOUT = 5000 # ms
CONN_PARAM_DSN = 'dsn'
CONN_PARAM_HOST = 'host'
CONN_PARAM_PORT = 'port'
CONN_PARAM_DATABASE = 'database'
@ -824,6 +825,10 @@ class Service(SimpleService):
def build_conn_params(self):
conf = self.configuration
# connection URIs: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
if conf.get(CONN_PARAM_DSN):
return {'dsn': conf[CONN_PARAM_DSN]}
params = {
CONN_PARAM_HOST: conf.get(CONN_PARAM_HOST),
CONN_PARAM_PORT: conf.get(CONN_PARAM_PORT, DEFAULT_PORT),