What grants need Qan postgresql pgstatements agent?

Hi. By the doсs i need to use this grants:

CREATE USER pmm WITH ENCRYPTED PASSWORD '******';
GRANT rds_superuser TO pmm;

But i found this very dangerous, and manually give this roles to user:

  • pg_read_all_settings
  • pg_monitor
  • pg_read_all_stats
  • pg_stat_scan_tables
  • pg_read_all_stats
  • pg_read_all_settings

And have this error after 20-30 sec after connection:

.

Can you please say what grants need this agent?

On the test database I grant rds_superuser and all works fine.
I use postgresql 14.7 on AWS RDS. Percona installed on k8s by helm chart.

Hello,
Thanks for reaching out!
Yes, that is true that rds_superuser or superuser permissions are dangerous to use, this recommendation is there because of legacy PostgreSQL versions. Thanks for pointing this out! It should be updated in the documentation.
The role pg_monitor is all the PMM user needs to have currently.

About the error, could you please pass the error from the QAN exporter logs? It will be easier to find the root cause of your problem.
One possibility could be that pg_stat_statements is not fully enabled, i.e. extension was created, but libraries were not loaded with shared_preload_libraries.

Thanks!

Here example of working QAN for PMM user with pg_monitor role only.


The pmm-agent.log (cannot upload file as new user).
I see error pg_stat_monitor_version() does not exist, but I use PG Stat Statements as Stat tracking options.

It looks like you have chosen pg_stat_monitor then for your QAN source instead of pg_stat_statements when you added the service in PMM.

Blockquote
e[36magentIDe[0m=/agent_id/d74747a6-2ae7-47df-9f7c-8de920ad3ec4 e[36mcomponente[0m=agent-builtin e[36mtypee[0m=qan_postgresql_pgstatmonitor_agent
e[31mERROe[0m[2023-07-10T17:22:01.256+00:00] failed to get pg_stat_monitor version from DB: pq: function pg_stat_monitor_version() does not exist e[31magentIDe[0m=/agent_id/d74747a6-2ae7-47df-9f7c-8de920ad3ec4 e[31mcomponente[0m=agent-builtin e[31mtypee[0m=qan_postgresql_pgstatmonitor_agent
e[36mINFOe[0m[2023-07-10T17:22:01.256+00:00] Sending status: WAITING. e[36magentIDe[0m=/agent_id/d74747a6-2ae7-47df-9f7c-8de920ad3ec4 e[36mcomponente[0m=agent-builtin e[36mtypee[0m=qan_postgresql_pgstatmonitor_agent

Please try to remove your agent and add it again, using pmm-admin or via GUI.

pmm-admin add postgresql \
--username=pmm \
--password=password \
--server-url=https://admin:password@X.X.X.X:443 \
--server-insecure-tls \
--service-name=pg1 \
--query-source="pgstatements"