• /
  • EnglishEspañolFrançais日本語한국어Português
  • ログイン今すぐ開始

Install & configure NRDOT for PostgreSQL monitoring with Azure flexible server

|View as Markdown (English)

Set up PostgreSQL monitoring using the NRDOT Collector for Azure Database for PostgreSQL flexible server instances. Azure flexible server environments have specific considerations for extensions and server parameters.

Prerequisites

Before you install, make sure you have:

  • PostgreSQL 14 and above
  • A New Relic license key.
  • Network connectivity between the host where you install the NRDOT Collector and your Azure Database for PostgreSQL flexible server instance.
  • Network connectivity to New Relic OTLP endpoints documentation
  • Azure flexible server admin login credentials.

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 Azure Database for PostgreSQL flexible server instance:

Configure database user and grants

Create a monitoring user with the necessary privileges for your Azure Database for PostgreSQL flexible server instance.

To create the monitoring user and grants:

  1. Connect to your Azure Database for PostgreSQL flexible server instance as the admin login:

    bash
    $
    psql --host=<YOUR_AZURE_ENDPOINT> --dbname=postgres --port=5432 --username=<YOUR_ADMIN_USERNAME>
  2. Create the monitoring user:

    CREATE USER <YOUR_DB_USERNAME> WITH LOGIN PASSWORD '<YOUR_DB_PASSWORD>';
  3. 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;

    ヒント

    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 pgvector extension in each database:

    CREATE EXTENSION IF NOT EXISTS vector;

    The l1, hamming, and jaccard distance functions require pgvector version 0.7.0 or above.

  • (Optional) To verify the connection and grants, run:

    bash
    $
    psql --username=<YOUR_DB_USERNAME> --host=<YOUR_AZURE_ENDPOINT> --port=5432 --dbname=<YOUR_DATABASE_NAME> --command '\conninfo'
    $
    psql --username=<YOUR_DB_USERNAME> --host=<YOUR_AZURE_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_AZURE_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_AZURE_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 Azure Database for PostgreSQL flexible server-specific settings.

This configuration focuses on essential PostgreSQL monitoring with the nrpostgresql receiver only.

full configuration

This baseline configuration captures essential metrics. To see the complete metric catalog, refer to the configuration reference.

  1. Create a configuration file named as postgresql-config.yaml:

    bash
    $
    sudo nano /etc/nrdot-collector/postgresql-config.yaml
  2. Add the following configuration to the postgresql-config.yaml file you created in the previous step.

postgresql-config.yaml
1
receivers:
2
nrpostgresql:
3
endpoint: "myserver.postgres.database.azure.com:5432"
4
username: "newrelic"
5
password: "YOUR_PASSWORD"
6
databases:
7
- YOUR_DATABASE_NAME
8
collection_interval: 15s
9
events:
10
db.server.top_query:
11
enabled: true
12
db.server.query_sample:
13
enabled: true
14
db.server.query_plan:
15
enabled: true
16
top_query_collection:
17
max_rows_per_query: 1000
18
top_n_query: 200
19
collection_interval: 60s
20
allowed_comment_keys: [nr_service_guid]
21
query_sample_collection:
22
max_rows_per_query: 1000
23
allowed_comment_keys: [nr_service_guid]
24
resource_attributes:
25
db.system.version:
26
enabled: true
27
# Metrics needed for the out-of-the-box dashboard but disabled by default:
28
# see "Available metrics" below for the full default-on/default-off breakdown.
29
metrics:
30
postgresql.database.locks:
31
enabled: true
32
postgresql.deadlocks:
33
enabled: true
34
postgresql.function.calls:
35
enabled: true
36
postgresql.query.conflicts:
37
enabled: true
38
postgresql.sequential_scans:
39
enabled: true
40
postgresql.temp.io:
41
enabled: true
42
postgresql.temp_files:
43
enabled: true
44
# Azure Database for PostgreSQL flexible server enforces TLS by default (require_secure_transport).
45
tls:
46
insecure: false
47
ca_file: <PATH_TO_AZURE_CA_CERTIFICATE>
48
processors:
49
batch:
50
batch/metrics:
51
send_batch_size: 8192
52
send_batch_max_size: 8192
53
timeout: 10s
54
exporters:
55
otlp/newrelic:
56
endpoint: "https://otlp.nr-data.net:4318"
57
headers:
58
api-key: "YOUR_LICENSE_KEY"
59
compression: gzip
60
sending_queue:
61
enabled: true
62
sizer: bytes
63
queue_size: 100_000_000
64
num_consumers: 10
65
batch:
66
sizer: bytes
67
max_size: 1_000_000
68
min_size: 0
69
flush_timeout: 5s
70
retry_on_failure:
71
enabled: true
72
initial_interval: 5s
73
max_interval: 30s
74
max_elapsed_time: 300s
75
service:
76
telemetry:
77
metrics:
78
level: none
79
pipelines:
80
metrics:
81
receivers: [nrpostgresql]
82
processors: [batch/metrics]
83
exporters: [otlp/newrelic]
84
logs:
85
receivers: [nrpostgresql]
86
processors: [batch]
87
exporters: [otlp/newrelic]

ヒント

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.
  • Query plans for write statements: 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

  1. Update the config path to point to your new postgresql-config.yaml file:

    bash
    $
    sudo sed -i 's|OTELCOL_OPTIONS="--config=/etc/nrdot-collector/config.yaml"|OTELCOL_OPTIONS="--config=/etc/nrdot-collector/postgresql-config.yaml"|' /etc/nrdot-collector/nrdot-collector.conf
  2. 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:

bash
$
sudo systemctl restart nrdot-collector

To verify that the collector is running properly, check the service status:

bash
$
sudo systemctl status nrdot-collector

ヒント

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 Azure Database for PostgreSQL flexible server entity in New Relic:

  1. Go to https://one.newrelic.com > All Capabilities > Databases.
  2. From the Entity type dropdown, select PostgreSQL instance, then click Apply.
  3. Select your Azure Database for PostgreSQL flexible server instance from the list of entities.

Azure Database for PostgreSQL flexible server behavior

When you monitor an Azure Database for PostgreSQL flexible server instance, behaviors differ from self-managed PostgreSQL or Amazon RDS due to Azure platform architecture rather than the receiver. All standard PostgreSQL metrics remain available on Azure.

  • Azure preloads pg_stat_statements (populates postgresql.query.execution.time) and pgvector (populates postgresql.vector.*) extensions on the server, but you must add them to the azure.extensions server parameter before CREATE EXTENSION succeeds. For configuration steps, see Configure database user and grants.

  • Replication metrics (postgresql.replication.data_delay, postgresql.wal.lag, and postgresql.wal.delay) populate from either an explicit read replica or Azure's built-in high availability (HA) standby, distinguished by sync_state (async or sync). Additionally, postgresql.wal.delay requires the postgresqlreceiver.preciselagmetrics feature gate, which the baseline configuration on this page doesn't enable.

  • track_functions defaults to none (standard PostgreSQL behavior, not specific to Azure). Set it to pl or all to enable postgresql.function.calls.

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.

Copyright © 2026 New Relic株式会社。

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