PostgreSQL plugin

PostgreSQL is an object-relational database management system available for many platforms including Linux, FreeBSD, Solaris, Microsoft Windows, and macOS. For more information visit

This functionality is only available for agents running on Linux. It is not available on Windows.


Even if the PostgreSQL plugin is not configured, Cloud Monitoring discovers PostgreSQL services running in your Google Cloud project by:

  • Searching instance names for postgresql
  • Checking for ports opened to 5432 via firewall rules

The services discovered are displayed on the PostgreSQL Services page in the Resources menu. After you install the Monitoring agent and configure the PostgreSQL plugin on your instances, Monitoring populates the PostgreSQL Services page with inventory and metrics.

Configuring Monitoring to monitor PostgreSQL

After you install the Monitoring agent, use the following instructions to configure the PostgreSQL plugin on your instances.


For PostgreSQL collection you must create a user/role with minimal privileges that can connect to the database using password or md5 authentication. This user and password are referred to as STATS_USER and STATS_PASS in the following config file. Some installations set access controls to ident authentication by default. You need to edit your pg_hba.conf file to enable access for the agent role. Assuming you have named your rolestackdriver-agent, you might need to add one of these lines to your pg_hba.conf file and restart PostgreSQL:

  • For connecting through unix domain sockets:

    local all stackdriver-agent md5

  • For connecting through TCP/IP to localhost:

    host all stackdriver-agent md5

Enabling the PostgreSQL monitoring plugin

PostgreSQL is configured per database on your system. At the moment, no drop-in configuration is available. The following configuration file shows how to configure one database, named DATABASE_NAME. You would need to use that configuration as a template for your databases.

On your VM instance, download postgresql.conf from the GitHub configuration repository and place it in the directory /etc/stackdriver/collectd.d/:

(cd /etc/stackdriver/collectd.d/ && sudo curl -O

As root, edit the downloaded configuration file and add information about your databases. Inline comments point out where you need to add configuration for additional databases. Wherever you see DATABASE_NAME, substitute the name of your database.

After editing the configuration file, restart the monitoring agent by running the following command:

sudo service stackdriver-agent restart

For more information on the collectd postgresql plugin, see Plugin:PostgreSQL.

What is monitored

The full list of metrics the PostreSQL plugin monitors is at Agent metrics: postgresql.