You can use the OpenTelemetry Collector Contrib for PostgreSQL to monitor your instance. The OpenTelemetry Collector Contrib is a community-supported project that collects telemetry data from PostgreSQL and sends it to New Relic.
By default, the OpenTelemetry Collector Contrib collects limited metrics from PostgreSQL. To send query performance, wait-event, session, and client metrics, you'll need to configure the OpenTelemetry Collector Contrib. This guide shows you how to configure it to collect advanced metrics from PostgreSQL and send them to New Relic.
Note
This page covers the community postgresql receiver shipped in the standard otelcol-contrib binary. If you're using New Relic's distribution (NRDOT), see Introduction to PostgreSQL monitoring instead.
Prerequisites
OpenTelemetry Collector Contrib (
otelcol-contrib) installed and configured on your system. You can download the latest release from the OpenTelemetry Collector releases page.pg_stat_statementsenabled viashared_preload_librarieson the monitored PostgreSQL instance. This is required for query performance, wait-event, session, and client data. See Recommended server parameters.The collector started in semantic-convention mode using the
receiver.postgresql.useOTelSemconvfeature gate.If you're running
otelcol-contribas an RPM/Debian package (systemd service), the service file imports environment variables viaEnvironmentFile=/etc/otelcol-contrib/otelcol-contrib.conf. In that file, append the flag toOTELCOL_OPTIONS:bash$OTELCOL_OPTIONS="--config=/etc/otelcol-contrib/config.yaml --feature-gates=receiver.postgresql.useOTelSemconv"After saving the file, restart the service to apply the gate:
bash$sudo systemctl restart otelcol-contrib
Enable UI metrics
You can enrich your New Relic platform experience by adding and enabling metrics in your otelcol-contrib configuration file. Using the configuration provided in this section, you can populate data for the following pages in the New Relic platform:
Overview
Query performance
Wait events
Sessions
Clients
Restart the OpenTelemetry Collector
Restart the OpenTelemetry Collector to apply the configuration changes:
$sudo systemctl restart otelcol-contrib