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

@ -49,6 +49,8 @@ Following charts are drawn:
### configuration
For all available options please see module [configuration file](postgres.conf).
```yaml
socket:
name : 'socket'

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),

View file

@ -63,6 +63,10 @@
#
# Connections can be configured with the following options:
#
# dsn : 'connection URI' # see https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
#
# OR
#
# database : 'example_db_name'
# user : 'example_user'
# password : 'example_pass'
@ -70,14 +74,14 @@
# port : 5432
# connect_timeout : 2 # in seconds, default is 2
# statement_timeout : 2000 # in ms, default is 2000
#
# SSL connection parameters (https://www.postgresql.org/docs/current/libpq-ssl.html)
# sslmode : mode # one of [disable, allow, prefer, require, verify-ca, verify-full]
# sslrootcert : path/to/rootcert # the location of the root certificate file
# sslcrl : path/to/crl # the location of the CRL file
# sslcert : path/to/cert # the location of the client certificate file
# sslkey : path/to/key # the location of the client key file
#
# SSL connection parameters description: https://www.postgresql.org/docs/current/libpq-ssl.html
#
# Additionally, the following options allow selective disabling of charts
#
# table_stats : false
@ -128,4 +132,3 @@ tcpipv6:
user : 'postgres'
host : '::1'
port : 5432