• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

PostgreSQL monitoring integration

The New Relic PostgreSQL on-host integration receives and sends inventory metrics from your PostgreSQL instance to the New Relic platform, where you can aggregate and visualize key performance metrics. Data from instances, databases, and clusters helps you find the source of problems.

To install the PostgreSQL monitoring integration, you must run through the following steps:

  1. Install and activate the integration.
  2. Configure the integration.
  3. PostgreSQL users and permissions.
  4. Find and use data.
  5. Optionally, see PostgreSQL's configuration settings.

Important

For best results, regularly update the integration package and the infrastructure agent.

Compatibility and requirements

PostgreSQL versions

Our integration is compatible with PostgreSQL v17 and lower.

Supported managed services

  • Amazon RDS
  • Azure Flexible

Supported operating systems

  • Windows Windows
  • Linux Linux

For a comprehensive list of specific Windows and Linux versions, check the table of compatible operating systems.

System requirements

Install and activate the integration

To install the PostgreSQL integration, follow the instructions for your environment.

Linux installation

  1. Install the infrastructure agent, and replace the INTEGRATION_FILE_NAME variable with nri-postgresql.

  2. Change directory to the integrations configuration folder by running:

    bash
    $
    cd /etc/newrelic-infra/integrations.d
  3. Create a user with READ permissions on the required functions.

  4. Copy the sample configuration file by running:

    bash
    $
    sudo cp postgresql-config.yml.sample postgresql-config.yml
  5. Edit the postgresql-config.yml configuration file with your favorite editor. Check out some configuration file examples..

  6. To enable automatic Postgresql parsing and forwarding, copy or rename the postgresql-log.yml.example file to postgresql-log.yml. You don't need to restart the agent but you may need to update the YML file with the location of your postgresql log files, if you aren't using the default locations.

    For example:

    bash
    $
    sudo cp /etc/newrelic-infra/logging.d/postgresql-log.yml.example /etc/newrelic-infra/logging.d/postgresql-log.yml
    $
    ```

Other environments

Additional notes:

Did this doc help with your installation?

Configure the integration

There are several ways to configure the integration, depending on how you installed it:

  • If enabled via KubernetesKubernetes, see Monitor services running on Kubernetes.
  • If enabled via ECSAmazon ECS, see Monitor services running on ECS.
  • If installed on-host, edit the config in the integration's YAML config file, postgresql-config.yml. An integration's YAML-format configuration is where you can place required login credentials and configure how data is collected. Which options you change depend on your setup and preference. The configuration file has common settings applicable to all integrations, such as interval, timeout, inventory_source. To read all about these common settings, refer to our Configuration Format document.

Important

If you are still using our legacy configuration or definition files, check the standard configuration format.

Specific settings related to PostgreSQL are defined using the env section of the configuration file. These settings control the connection to your PostgreSQL instance as well as other security settings and features. The list of valid settings is described in the next section of this document.

PostgreSQL users and permissions

Create a user with SELECT permissions on:

  • pg_stat_database
  • pg_stat_database_conflicts
  • pg_stat_bgwriter

To create the user for the PostgreSQL integration:

CREATE USER new_relic WITH PASSWORD MY_PASSWORD;
GRANT SELECT ON pg_stat_database TO new_relic;
GRANT SELECT ON pg_stat_database_conflicts TO new_relic;
GRANT SELECT ON pg_stat_bgwriter TO new_relic;

This will allow the integration to gather global metrics related to the PostgreSQL instance.

If you also want to obtain table and index-related metrics (for example, table size and index size), the PostgreSQL role used by the integration (new_relic) also needs SELECT permissions on the tables from which it will gather metrics from. For example, to allow the integration to collect metrics from all the tables and indexes present in the database (in the public schema), use the following:

GRANT SELECT ON ALL TABLES IN SCHEMA public TO new_relic;

If you also want to obtain query-level metrics from the PostgreSQL custom query config file, the PostgreSQL role used by the integration (new_relic) needs to be added to the (pg_read_all_stats) role. This is due to the user leveraging the (pg_stat_statements) extension.

GRANT pg_read_all_stats TO new_relic;

Enabling the pg_stat_statements extension may require you to manually create it from a query prompt:

CREATE EXTENSION pg_stat_statements;

postgresql-config.yml sample files

For more about the general structure of on-host integration configuration, see Configuration.

Configuration options for the integration

For more on how to find and use your data, see PostgreSQL's configuration settings.

Find and use data

Data from this service is reported to an integration dashboard.

Metrics are attached to these event types:

You can query this data for troubleshooting purposes or to create custom charts and dashboards.

For more on how to find and use your data, see how to understand integration data.

Metrics collected by the integration

The PostgreSQL integration collects the following metrics. Some metric names are prefixed with a category indicator and a period, such as db. or index..

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.