PMM postgres_exporter returns database does not exist

Hello,

I’m using pmm2-client-2.0.1-5.el7.x86_64 under CentOS Linux release 7.6

When using pmm-admin to add a PostgreSQL Service, I execute:
pmm-admin add postgresql --username=dod_pmm --password=xxxxx pmm_config_test 127.0.0.1:6600

and this sets my postgres_exporter to a ‘running’ state and qan-postgresql-pgstatements-agent in ‘waiting’ state.

The problem is that, at the same time, I see in my PG log file messages like this:
[DB:dod_pmm] FATAL: database “dod_pmm” does not exist

Why is this? Does the postgres_exporter try to connect to a default database with the name of the pmm user (which I don’t have)? Shouldn’t just use postgres instead or let us specify a database in the ‘pmm-admin add’ command line?

Thanks

I’ll answer myself (this was not clear for me in documentation):

  • postgres_exporter connects to a DB with the same name as the one specified in --username. If it doesn’t exist, you should create it first. If our user is named ‘pmm’ (for instance):
    CREATE USER pmm WITH SUPERUSER PASSWORD ‘xxxxxxx’;
    CREATE DATABASE pmm WITH OWNER = pmm;

  • for the pg_hba.conf privileges, you should define something like this:
    host pmm pmm 127.0.0.1/32 md5
    host pmm pmm ::1/128 md5

On top of that, you should modify your postgres.conf as explained in the documentation:
[URL]https://www.percona.com/doc/percona-monitoring-and-management/2.x/manage/conf-postgres.html[/URL]