Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Pgscv ignores databases regular expression when tries to discover pg_stat_statements extension #45

Open
nazipov opened this issue Nov 17, 2022 · 2 comments

Comments

@nazipov
Copy link

nazipov commented Nov 17, 2022

Describe the bug
Pgscv ignores databases regular expression when tries to discover pg_stat_statements extension. https://github.com/lesovsky/pgscv/blob/master/internal/collector/config.go#L185

Steps to reproduce
Add aws rds to dictionary services.

Expected behavior
Pgscv should check that database match with regex on pg_stat_statements discovering before connecting to this database.

pgSCV startup options
Config file

listen_address: 127.0.0.1:9890
autoupdate: off
no_track_mode: false
databases: "^(app_database_1|app_database_2)$"
services:
  "aws_rds":
    service_type: "postgres"
    conninfo: "postgres://pgscv:XXXXXX@rds-host/postgres"

Errors and Logs
Aws rds logs

2022-11-12 17:00:54 UTC:10.2.10.20(49376):pgscv@rdsadmin:[28030]:FATAL: pg_hba.conf rejects connection for host "X.X.X.X", user "pgscv", database "rdsadmin", SSL on

Pgscv logs

{"level":"warn","service":"pgscv","time":"2022-11-17T14:00:55Z","message":"connect to database 'rdsadmin' failed: failed to connect to `host=rds-host user=pgscv database=rdsadmin`: server error (FATAL: pg_hba.conf rejects connection for host \"X.X.X.X\", user \"pgscv\", database \"rdsadmin\", SSL on (SQLSTATE 28000)); skip"}

Additional context
It's not critical issue, but such kind of behavior creates a lot of flood in aws rds logs and it's not possible to fix it.

@lesovsky
Copy link
Owner

lesovsky commented Nov 17, 2022

The error means you use invalid credentials to connect to Postgres. Check the conninfo.

upd. Could you paste more pgscv logs immediately after start?

@nazipov
Copy link
Author

nazipov commented Nov 22, 2022

Yes, It's related to invalid credentials, but in AWS RDS (I use pgscv to monitor our AWS RDS instances) no one can access to rdsadmin database, except RDS system users.

app_database_1=> \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
.............
 postgres  | root     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 rdsadmin  | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 | rdsadmin=CTc/rdsadmin+
           |          |          |             |             | rdstopmgr=Tc/rdsadmin
.............

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants