You can monitor any version of PostgreSQL with Database Visibility. 

Connection Details

SectionFieldDescription
Create New CollectorDatabase TypeThe database type that you want to monitor.
AgentThe Database Agent that manages the collector.
Collector NameThe name you want to identify the collector by.
Connection DetailsHostname or IP AddressThe hostname or IP address of the machine that your database is running on.
Listener PortThe TCP/IP address of the port on which your database communicates with the Database Agent.
Custom JDBC Connection StringThe JDBC connection string generated by the database agent, for example, dbc:postgresql://. You can also specify a custom connection string, which is useful for setting custom authentication options.
Username and PasswordUsernameThe name of the user who is connecting to and monitoring the database through the Database Agent. The user should have the permissions described in User Permissions for PostgreSQL.
PasswordThe password of the user who is connecting to and monitoring the database through the Database Agent.
CyberArkClick to enable CyberArk for database username and password. When CyberArk is enabled, information about Application, Safe, Folder, and Object is required to fetch the username and password for your database. To use CyberArk with Database Visibility, you must download the JavaPasswordSDK.jar file from the CyberArk web site and rename the file to cyberark-sdk-9.5.jar. Then, you must copy the JAR file to the lib directory of the database agent zip file. 
Advanced OptionsSub-Collectors

Click to monitor multiple database instances in a consolidated view, and aggregate metrics of multiple databases. To monitor a custom cluster, you can add additional hostname or IP address, and port details for each sub-collector. You can add up to a total of 29 sub-collectors. Thereby, 30 databases can be monitored in a custom cluster. In addition to the licenses consumed by the main collector, each sub-collector consumes one or more licenses, depending on the database type.

  • All connection parameters other than the hostname or IP address, and port details of the sub-collector are the same as the main collector. If you want to specify different parameters for the sub–collectors, while creating or editing the collector configuration, you can do that only via the Create Collector API.

  • You cannot convert a custom cluster collector to a standalone collector. If you want to monitor a standalone database, delete the entire custom cluster collector and create a fresh standalone collector. However, note that deleting the custom cluster collector will delete all its historical data.
Connection PropertiesClick to add a new JDBC connection property or edit an existing property for relational databases.
EnterpriseDBClick if your PostrgreSQL database installation is an EnterpriseDB distribution. 
Exclude DatabasesThe databases that you want to exclude, separated by commas. 
Monitor Operating SystemSee Configure the Database Agent to Monitor Server Hardware.

Set up PostgreSQL for Monitoring

User Permissions

You must be a superuser to execute this section.

Create a non-superuser and grant monitoring permissions. To achieve this, perform the following steps to create a SECURITY DEFINER function. This allows non-superusers to view the contents of pg_stat_activity and pg_stat_statements.

  1. Call the get_sa() function:

    CREATE FUNCTION get_sa() 
    RETURNS SETOF pg_stat_activity LANGUAGE sql AS
    $$ SELECT * FROM pg_catalog.pg_stat_activity; $$
    VOLATILE
    SECURITY DEFINER;
     
    CREATE VIEW pg_stat_activity_allusers AS SELECT * FROM get_sa(); 
    GRANT SELECT ON pg_stat_activity_allusers TO public;
    CODE
  2. Call the get_querystats( ) function:

    CREATE FUNCTION get_querystats() 
    RETURNS SETOF pg_stat_statements LANGUAGE sql 	AS
    $$ SELECT * FROM pg_stat_statements; $$
    VOLATILE
    SECURITY DEFINER;
    CREATE VIEW pg_stat_statements_allusers AS SELECT * FROM get_querystats();
    GRANT SELECT ON pg_stat_statements_allusers TO public;
    CODE

The monitoring user must also be able to connect remotely to the PostgreSQL instance from AppDynamics for the database machine.

Enable the pg_stat_statements Section

You must be a superuser to execute this section.

Run the following command to create the pg_stat_statements extension:

create extension pg_stat_statements
CODE

Validate the Setup

Ensure that the newly created appduser (monitoring user) executes this section.

Run the following queries:

  1. SELECT * FROM pg_stat_activity_allusers
  2. SELECT * FROM pg_stat_statements_allusers

If the queries run successfully and you get an output, the setup is successful.