Skip to content

Suggest using pg_monitor role for PostgreSQL >= 10 #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ilmari opened this issue Mar 17, 2019 · 4 comments · Fixed by #590
Closed

Suggest using pg_monitor role for PostgreSQL >= 10 #258

ilmari opened this issue Mar 17, 2019 · 4 comments · Fixed by #590

Comments

@ilmari
Copy link

ilmari commented Mar 17, 2019

As of PostgreSQL 10, there are built-in roles that give access to extra statistics without needing to be superuser.

The documentation should suggest using creating an unprivileged user and granting the pg_monitor role to it.

@wrouesnel
Copy link
Contributor

If someone could test what works for this, I'd be happy to update.

@keithf4
Copy link

keithf4 commented Oct 31, 2019

The built in roles eliminate the need for having to make special SECURITY DEFINER functions to see all row data in views such as pg_stat_activity. We do this for the role we make for postgres_exporter and it makes a huge difference in simplicity for setup.

You can see the difference in what is required in our PG9.6 setup file for our monitoring platform

https://github.com/CrunchyData/pgmonitor/blob/master/exporter/postgres/setup_pg96.sql

vs our PG10+ setup file

https://github.com/CrunchyData/pgmonitor/blob/master/exporter/postgres/setup_pg10.sql

We're able to eliminate a bunch of functions that are no longer necessary.

@crimean-celica
Copy link

crimean-celica commented Aug 18, 2021

If someone could test what works for this, I'd be happy to update.

It works fine with 12.6
Seems, it would be nice to add that information into the readme

@ilmari
Copy link
Author

ilmari commented Aug 18, 2021

Assuming postgres_exporter runs as the OS user prometheus, either of the following will work.

In shell, as an OS user that has superuser or createrole access (e.g. postgres on most OSes):

createuser --role pg_monitor prometheus

or in psql, as a a similarly privileged user:

create user prometheus in role pg_monitor;

sysadmind added a commit that referenced this issue Jan 26, 2022
#258 Document running as non-superuser on PostgreSQL versions 10 or newer.
angaz pushed a commit to angaz/postgres_exporter that referenced this issue Mar 3, 2022
…SQL versions 10 or newer.

Signed-off-by: juris.greitans <[email protected]>
Signed-off-by: Angus Dippenaar <[email protected]>
angaz pushed a commit to angaz/postgres_exporter that referenced this issue Mar 3, 2022
…SQL versions 10 or newer.

Signed-off-by: juris.greitans <[email protected]>
Signed-off-by: Angus Dippenaar <[email protected]>
ritbl referenced this issue in heniek/postgres_exporter Mar 19, 2023
ritbl referenced this issue in heniek/postgres_exporter Mar 19, 2023
percona#258 Document running as non-superuser on PostgreSQL versions 10 or newer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants