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:
- Install and activate the integration.
- Configure the integration.
- PostgreSQL users and permissions.
- Find and use data.
- Optionally, see PostgreSQL's configuration settings.
Our integration is compatible with PostgreSQL until version 15.
- Amazon RDS
- Azure Flexible
For a comprehensive list of specific Windows and Linux versions, check the table of compatible operating systems.
- A New Relic account. Don't have one? Sign up for free! No credit card required.
- If PostgreSQL is not running on Kubernetes or Amazon ECS, you can install the infrastructure agent on a Linux or Windows OS host or on a host capable of remotely accessing where PostgreSQL is installed. Otherwise:
To install the PostgreSQL integration, follow the instructions for your environment.
Install the infrastructure agent, and replace the
Change directory to the integrations configuration folder by running:bash$cd /etc/newrelic-infra/integrations.d
Copy the sample configuration file by running:bash$sudo cp postgresql-config.yml.sample postgresql-config.yml
postgresql-config.ymlconfiguration file with your favorite editor. Check out some configuration file examples..
Before you restart the infrastructure agent, create a user with
READpermissions on the required functions.
Restart the infrastructure agent. See how to restart the infrastructure agent in different Linux environments.
To enable automatic Postgresql parsing and forwarding, copy or rename the
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$```
- Advanced: Integrations are also available in tarball format to allow for install outside of a package manager.
- On-host integrations do not automatically update. For best results, regularly update the integration package and the infrastructure agent.
Did this doc help with your installation?
There are several ways to configure the integration, depending on how you installed it:
- If enabled via Kubernetes, see Monitor services running on Kubernetes.
- If enabled via Amazon 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
inventory_source. To read all about these common settings, refer to our Configuration Format document.
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.
Create a user with
SELECT permissions on:
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 (
GRANT pg_read_all_stats TO new_relic;
pg_stat_statements extension may require you to manually create it from a query prompt:
CREATE EXTENSION pg_stat_statements;
For more about the general structure of on-host integration configuration, see Configuration.
For more on how to find and use your data, see PostgreSQL's configuration settings.
Data from this service is reported to an integration dashboard.
Metrics are attached to these event types:
- PostgresqlDatabaseSample metrics
- PostgresqlIndexSample metrics
- PostgresqlInstanceSample metrics
- PostgresqlTableSample metrics
- PgBouncerSample metrics
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.
The PostgreSQL integration collects the following metrics. Some metric names are prefixed with a category indicator and a period, such as