---
title: Install & configure NRDOT for PostgreSQL monitoring with Azure flexible server
source: https://docs.newrelic.com/docs/opentelemetry/db360/postgresql/azure
---

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 [#prerequisites]

Before you install, make sure you have:

-   PostgreSQL `14` and above
-   A New Relic [license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-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](https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp/)
-   Azure flexible server admin login credentials.

For supported PostgreSQL versions, required grants, and recommended server parameters, see [Compatibility and prerequisites](https://docs.newrelic.com/docs/opentelemetry/db360/postgresql/compatibility).

## Set up NRDOT Collector [#setup]

Install the NRDOT Collector on a system that can connect to your Azure Database for PostgreSQL flexible server instance:

**For AMD64 architecture**

-   For Debian/Ubuntu system, run:

    ```bash
    NRDOT_VERSION=$(curl -s https://api.github.com/repos/newrelic/nrdot-collector-releases/releases/latest | grep '"tag_name":' | awk -F'"' '{print $4}') && curl -L "https://github.com/newrelic/nrdot-collector-releases/releases/download/${NRDOT_VERSION}/nrdot-collector_${NRDOT_VERSION}_linux_amd64.deb" --output nrdot-collector.deb && sudo dpkg -i nrdot-collector.deb
    ```
-   For RHEL/CentOS/OEL system, run:

    ```bash
    NRDOT_VERSION=$(curl -s https://api.github.com/repos/newrelic/nrdot-collector-releases/releases/latest | grep '"tag_name":' | awk -F'"' '{print $4}') && curl -L "https://github.com/newrelic/nrdot-collector-releases/releases/download/${NRDOT_VERSION}/nrdot-collector_${NRDOT_VERSION}_linux_x86_64.rpm" --output nrdot-collector.rpm && sudo rpm -ivh nrdot-collector.rpm
    ```

**For ARM64 architecture**

-   For Debian/Ubuntu system, run:

    ```bash
    NRDOT_VERSION=$(curl -s https://api.github.com/repos/newrelic/nrdot-collector-releases/releases/latest | grep '"tag_name":' | awk -F'"' '{print $4}') && curl -L "https://github.com/newrelic/nrdot-collector-releases/releases/download/${NRDOT_VERSION}/nrdot-collector_${NRDOT_VERSION}_linux_arm64.deb" --output nrdot-collector.deb && sudo dpkg -i nrdot-collector.deb
    ```

-   For RHEL/CentOS/OEL system, run:

    ```bash
    NRDOT_VERSION=$(curl -s https://api.github.com/repos/newrelic/nrdot-collector-releases/releases/latest | grep '"tag_name":' | awk -F'"' '{print $4}') && curl -L "https://github.com/newrelic/nrdot-collector-releases/releases/download/${NRDOT_VERSION}/nrdot-collector_${NRDOT_VERSION}_linux_aarch64.rpm" --output nrdot-collector.rpm && sudo rpm -ivh nrdot-collector.rpm
    ```

## Configure database user and grants [#database-user]

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:

    ```shell
    psql --host=<YOUR_AZURE_ENDPOINT> --dbname=postgres --port=5432 --username=<YOUR_ADMIN_USERNAME>
    ```

2.  Create the monitoring user:

    ```sql
    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:

    ```sql
    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:

    ```sql
    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:

    ```sql
    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:

    ```shell
    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-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](https://docs.newrelic.com/docs/opentelemetry/db360/postgresql/config-reference/#azure-full).

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.

> #### 💡 TIP
>
> You can also:
>
> -   [Configure multiple receivers](https://docs.newrelic.com/docs/opentelemetry/db360/postgresql/multi-receiver): To monitor multiple PostgreSQL instances from one collector.
> -   [Link your PostgreSQL database with APM](https://docs.newrelic.com/docs/opentelemetry/db360/capabilities/db-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](https://docs.newrelic.com/docs/opentelemetry/db360/postgresql/optional#query): To collect query plans for locking or write statements without granting write access to the monitoring user.
> -   [Set up secret management](https://docs.newrelic.com/docs/opentelemetry/db360/capabilities/db-apm/#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 [#validate]

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 [#restart-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
```

> #### 💡 TIP
>
> Always restart the NRDOT Collector after making configuration changes to ensure the new settings take effect.

## Find and use your data [#find-use-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 [#azure-flexible]

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](#database-user).

-   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`.

## Related documentation [#related]

[Instrumentation in self-hosted environments](https://docs.newrelic.com/docs/opentelemetry/db360/postgresql/hosted)

Learn how to set up PostgreSQL monitoring in self-hosted environments with New Relic.

[Metrics reference](https://docs.newrelic.com/docs/opentelemetry/db360/postgresql/metrics-reference)

Learn about the available metrics collected by the NRDOT Collector.

[Troubleshooting guide](https://docs.newrelic.com/docs/opentelemetry/db360/postgresql/troubleshooting)

Learn how to troubleshoot common issues with PostgreSQL monitoring.
