mirror of
https://github.com/netdata/netdata.git
synced 2025-05-17 22:52:21 +00:00
postgres module: connect via uri (#5758)
* add connection via URI support * update config * update readme * change link
This commit is contained in:
parent
2b7bb1daee
commit
53fbf2eb9b
3 changed files with 13 additions and 3 deletions
collectors/python.d.plugin/postgres
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue