Issue
I would like to use a monitoring service like Datadog and I need to grant my Heroku Postgres user the pg_monitor role.
Resolution
For production plans (standard-*, premium-*, private-* and shield-*), the default credential for Heroku Postgres databases has pg_monitor privileges and it can grant this membership to other credentials/users in the database.
To grant the pg_monitor role to a custom credential, connect to the database with your default credential, and run:
GRANT pg_monitor TO <credential_name>;
When granting the pg_monitor role to a credential it will also inherit the pg_read_all_settings, pg_read_all_stats and pg_stat_scan_tables roles - see "Predefined Roles" in the PostgreSQL documentation.
Note: Due to the multi-tenancy setup of Heroku Postgres Essential databases, pg_monitor permissions (neither pg_read_all_settings, pg_read_all_stats or pg_stat_scan_tables) aren't granted on these plans for security and privacy reasons.