Atatus Database Monitoring offers comprehensive insights into your PostgreSQL databases, revealing key metrics such as query performance, query samples, execution plans, connection details, system statistics, and InnoDB storage engine telemetry. To enable Database Monitoring, the Agent gathers telemetry by accessing the database as a read-only user. Follow these steps to configure Database Monitoring for your PostgreSQL database:

Before You Begin

Enable and Configure PostgreSQL Monitoring Settings

Update the following parameters in your postgresql.conf file to enable performance monitoring with Atatus. After making these changes, restart the PostgreSQL server for them to take effect. For detailed information on each parameter, refer to the PostgreSQL documentation.

Setup Database Access for the Agent

  • To connect to the database, use a superuser account (or one with the necessary privileges). For example, for the postgres database, connect as the postgres superuser using psql:

Postgres ≥ 15

  1. Create the atatus user and grant basic permissions:
  2. Give the atatus user permission to relevant tables:
  3. Create the following schema in every database:
    To collect data or custom metrics that require querying additional tables, you may need to grant the SELECT permission on those tables to the atatus user. For example: grant SELECT on TABLE_NAME to atatus;. Refer to the PostgreSQL custom metric collection documentation for more details.
  4. Create the function in every database to enable the Agent to collect explain plans.

Postgres ≥ 10

  1. Create the atatus user and grant basic permissions:
  2. Create the following schema in every database:
    To collect data or custom metrics that require querying additional tables, you may need to grant the SELECT permission on those tables to the atatus user. For example: grant SELECT on TABLE_NAME to atatus;. Refer to the PostgreSQL custom metric collection documentation for more details.
  3. Create the function in every database to enable the Agent to collect explain plans.

Postgres 9.6

  1. Create the atatus user and grant basic permissions:
  2. Create the following schema in every database:
  3. Create functions in every database to enable the Agent to read the full contents of pg_stat_activity and pg_stat_statements:
    To collect data or custom metrics that require querying additional tables, you may need to grant the SELECT permission on those tables to the atatus user. For example: grant SELECT on TABLE_NAME to atatus;. Refer to the PostgreSQL custom metric collection documentation for more details.
  4. Create the function in every database to enable the Agent to collect explain plans.

Verify

To verify the permissions are correct, run the following commands to confirm the Agent user is able to connect to the database and read the core tables:

Configure Atatus Infrastructure Agent

  1. To enable Database Monitoring for your databases, You should install the Atatus Infrastructure agent in your host machine.
  2. Copy the PostgreSQL example configuration file.
  3. Update PostgreSQL Configuration File:
Add the following configuration to /etc/atatus-infra-agent/conf.d/postgresql.d/postgresql.yml:
  1. Restart the atatus infrastructure agent and PostgreSQL service.

Collecting Schemas (Optional)

To collect schema information from PostgreSQL databases, enable the collect_schemas option in your configuration. Use the auto_discovery option to automatically detect and collect from all logical databases, no need to specify them individually.

Collecting Custom Metrics (Optional)

To collect custom metrics from PostgreSQL, configure the custom_queries section in your postgresql.d/postgresql.yml file.