Preview
We're still working on this feature, but we'd love for you to try it out!
This feature is currently provided as part of a preview pursuant to our pre-release policies.
Set up PostgreSQL monitoring using the NRDOT Collector for AWS RDS PostgreSQL instances. RDS environments have specific considerations for extensions and parameter groups.
Prerequisites
Before you install, make sure you have:
- PostgreSQL
14and above - A New Relic license key.
- Network connectivity between the host where you install the NRDOT Collector and your RDS PostgreSQL instance.
- Network connectivity to New Relic OTLP endpoints documentation
- RDS master user credentials.
- This integration is available as a part of New Relic public preview program. Check with your Organization Manager to opt in from the Previews & Trials page.
For supported PostgreSQL versions, required grants, and recommended server parameters, see Compatibility and prerequisites.
Set up NRDOT Collector
Install the NRDOT Collector on a system that can connect to your RDS instance:
Configure database user and grants
Create a monitoring user with the necessary privileges for your RDS PostgreSQL instance.
To create the monitoring user and grants:
Connect to your RDS instance as the master user:
bash$psql --host=<YOUR_RDS_ENDPOINT> --dbname=postgres --port=5432 --username=<YOUR_MASTER_USERNAME>Create the monitoring user:
CREATE USER <YOUR_DB_USERNAME> WITH LOGIN PASSWORD '<YOUR_DB_PASSWORD>';Grant the monitoring user role membership as needed:
If you're on PostgreSQL 15 and above, assign role to inherit privileges:
ALTER ROLE <YOUR_DB_USERNAME> INHERIT;Tip
If you're on PostgreSQL 14, the monitoring user inherits privileges by default, so you can skip this step.
Create the following schema and grants in every database you want to monitor:
CREATE SCHEMA IF NOT EXISTS otel;GRANT USAGE ON SCHEMA otel TO <YOUR_DB_USERNAME>;GRANT USAGE ON SCHEMA public TO <YOUR_DB_USERNAME>;GRANT SELECT ON ALL TABLES IN SCHEMA public TO <YOUR_DB_USERNAME>;GRANT pg_monitor TO <YOUR_DB_USERNAME>;CREATE EXTENSION IF NOT EXISTS pg_stat_statements;(Optional) To collect vector metrics, create the
pgvectorextension in each database:CREATE EXTENSION IF NOT EXISTS vector;The
l1,hamming, andjaccarddistance functions requirepgvectorversion0.7.0or above.(Optional) To verify the connection and grants, run:
bash$psql --username=<YOUR_DB_USERNAME> --host=<YOUR_RDS_ENDPOINT> --port=5432 --dbname=<YOUR_DATABASE_NAME> --command '\conninfo'$psql --username=<YOUR_DB_USERNAME> --host=<YOUR_RDS_ENDPOINT> --port=5432 --dbname=<YOUR_DATABASE_NAME> \>-c "SELECT * FROM pg_stat_database LIMIT 1;" && echo "pg_stat_database OK">psql --username=<YOUR_DB_USERNAME> --host=<YOUR_RDS_ENDPOINT> --port=5432 --dbname=<YOUR_DATABASE_NAME> \>-c "SELECT * FROM pg_stat_activity LIMIT 1;" && echo "pg_stat_activity OK">psql --username=<YOUR_DB_USERNAME> --host=<YOUR_RDS_ENDPOINT> --port=5432 --dbname=<YOUR_DATABASE_NAME> \>-c "SELECT * FROM pg_stat_statements LIMIT 1;" && echo "pg_stat_statements OK"If each command completes without an error, the monitoring user, host, and port are all correct.
Configure NRDOT Collector
Configure the NRDOT Collector with your RDS PostgreSQL-specific settings. Select your configuration type based on your monitoring needs:
Configuration parameters
The following table describes the key configuration parameters for the nrpostgresql receiver:
| Parameter | Description |
|---|---|
<YOUR_RDS_ENDPOINT> | Enter your RDS instance endpoint hostname. |
<YOUR_DB_PORT> | Enter your PostgreSQL Database port. |
<YOUR_DB_USERNAME> | Enter your database username. |
<YOUR_DB_PASSWORD> | Enter your database password. |
<YOUR_DATABASE_NAME> | Enter the name of the database you want to monitor. |
<YOUR_NEWRELIC_OTLP_ENDPOINT> | Enter the New Relic OTLP endpoint. For more information, see New Relic OTLP endpoints. |
<YOUR_NEWRELIC_LICENSE_KEY> | Enter your New Relic license key. |
collection_interval | Enter the interval between metric scrapes. Default: 15s. |
Tip
You can also:
- Configure multiple receivers: To monitor multiple PostgreSQL instances from one collector.
- Link your PostgreSQL database with APM: To correlate your application performance with database operations. This allows you to see exactly which applications are generating specific database workloads.
- EXPLAIN plan permissions: To collect query plans for locking or write statements without granting write access to the monitoring user.
- Set up secret management: To securely manage sensitive information, such as database credentials. This helps to enhance the security of your monitoring setup by avoiding hardcoding sensitive data in configuration files.
Validate NRDOT Collector configuration
Update the config path to point to your new
postgresql-config.yamlfile:bash$OTELCOL_OPTIONS="/etc/nrdot-collector/postgresql-config.yaml"Validate the NRDOT Collector configuration to ensure it's correctly formatted and will work properly:
bash$sudo /usr/bin/nrdot-collector validate --config=/etc/nrdot-collector/postgresql-config.yaml
Restart NRDOT Collector
After configuring the collector, restart the NRDOT Collector service to apply the changes:
$sudo systemctl restart nrdot-collectorTo verify that the collector is running properly, check the service status:
$sudo systemctl status nrdot-collectorTip
Always restart the NRDOT Collector after making configuration changes to ensure the new settings take effect.
Find and use your data
Query samples and top queries arrive as log events (event.name = 'db.server.query_sample' / 'db.server.top_query', db.system.name = 'postgresql'). Metrics arrive under the postgresql.* namespace.
To find your RDS PostgreSQL database entity in New Relic:
- Go to https://one.newrelic.com > All Capabilities > Databases.
- From the Entity type dropdown, select PostgreSQL instance, then click Apply.
- Select your RDS PostgreSQL database from the list of entities.
Related documentation
Instrumentation in self-hosted environments
Learn how to set up PostgreSQL monitoring in self-hosted environments with New Relic.
Metrics reference
Learn about the available metrics collected by the NRDOT Collector.
Troubleshooting guide
Learn how to troubleshoot common issues with PostgreSQL monitoring.