Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions content/en/database_monitoring/setup_postgres/azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Database Monitoring runs as an integration on top of the base Agent ([see benchmarks][1]).

Proxies, load balancers, and connection poolers
: The Datadog Agent must connect directly to the host being monitored. For self-hosted databases, `127.0.0.1` or the socket is preferred. The Agent should not connect to the database through a proxy, load balancer, or connection pooler such as `pgbouncer`. If the Agent connects to different hosts while it is running (as in the case of failover, load balancing, and so on), the Agent calculates the difference in statistics between two hosts, producing inaccurate metrics.
: The Datadog Agent must connect directly to the host being monitored. For self-hosted databases, use `127.0.0.1` or the socket. The Agent should not connect to the database through a proxy, load balancer, or connection pooler such as `pgbouncer`. If the Agent connects to different hosts while it is running (as in the case of failover, load balancing, and so on), the Agent calculates the difference in statistics between two hosts, producing inaccurate metrics.

Check notice on line 38 in content/en/database_monitoring/setup_postgres/azure.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.sentencelength

Suggestion: Try to keep your sentence length to 25 words or fewer.

Data security considerations
: See [Sensitive information][2] for information about what data the Agent collects from your databases and how to ensure it is secure.
Expand Down Expand Up @@ -73,11 +73,11 @@

## Grant the Agent access

The Datadog Agent requires read-only access to the database server in order to collect statistics and queries.
The Datadog Agent requires read-only access to the database server to collect statistics and queries.

The following SQL commands should be executed on the **primary** database server (the writer) in the cluster if Postgres is replicated. Choose a PostgreSQL database on the database server for the Agent to connect to. The Agent can collect telemetry from all databases on the database server regardless of which one it connects to, so a good option is to use the default `postgres` database. Choose a different database only if you need the Agent to run [custom queries against data unique to that database][5].
Run the following SQL commands on the **primary** database server (the writer) in the cluster if Postgres is replicated. The Agent can collect telemetry from all databases on the server regardless of which database it connects to. Use the default `postgres` database unless you need the Agent to run [custom queries against data unique to a different database][5].

Connect to the chosen database as a superuser (or another user with sufficient permissions). For example, if your chosen database is `postgres`, connect as the `postgres` user using [psql][6] by running:
Connect to your chosen database as a superuser (or another user with sufficient permissions). For example, to connect to the `postgres` database using [psql][6]:

```bash
psql -h mydb.example.com -d postgres -U postgres
Expand All @@ -89,7 +89,7 @@
CREATE USER datadog WITH password '<PASSWORD>';
```

**Note:** Microsoft Entra ID managed identity authentication is also supported. Please see [the guide][13] on how to configure this for your Azure instance.
**Note:** Microsoft Entra ID managed identity authentication is also supported. See [the guide][13] on how to configure this for your Azure instance.


{{< tabs >}}
Expand Down Expand Up @@ -163,7 +163,9 @@

<div class="alert alert-info">For data collection or custom metrics that require querying additional tables, you may need to grant the <code>SELECT</code> permission on those tables to the <code>datadog</code> user. Example: <code>grant SELECT on &lt;TABLE_NAME&gt; to datadog;</code>. See <a href="https://docs.datadoghq.com/integrations/faq/postgres-custom-metric-collection-explained/">PostgreSQL custom metric collection</a> for more information. </div>

Create the function **in every database** to enable the Agent to collect explain plans.
### Create the explain plan function

Create the following function **in every database** to enable the Agent to collect explain plans:

```SQL
CREATE OR REPLACE FUNCTION datadog.explain_statement(
Expand Down Expand Up @@ -193,7 +195,7 @@
### Securely store your password
{{% dbm-secret %}}

### Verify
### Verify database permissions

To verify the permissions are correct, run the following commands to confirm the Agent user is able to connect to the database and read the core tables:
{{< tabs >}}
Expand Down Expand Up @@ -222,11 +224,11 @@
&& echo -e "\e[0;32mPostgres connection - OK\e[0m" \
|| echo -e "\e[0;31mCannot connect to Postgres\e[0m"
psql -h mydb.example.com -U datadog postgres -A \
-c "select * from pg_stat_activity limit 1;" \
-c "select * from datadog.pg_stat_activity() limit 1;" \
&& echo -e "\e[0;32mPostgres pg_stat_activity read OK\e[0m" \
|| echo -e "\e[0;31mCannot read from pg_stat_activity\e[0m"
psql -h mydb.example.com -U datadog postgres -A \
-c "select * from pg_stat_statements limit 1;" \
-c "select * from datadog.pg_stat_statements() limit 1;" \
&& echo -e "\e[0;32mPostgres pg_stat_statements read OK\e[0m" \
|| echo -e "\e[0;31mCannot read from pg_stat_statements\e[0m"
```
Expand Down Expand Up @@ -529,11 +531,13 @@

See the [Postgres integration spec][7] for additional information on setting `deployment_type` and `name` fields.

### Validate
### Verify Agent setup

[Run the Agent's status subcommand][9] and look for `postgres` under the Checks section. Or visit the [Databases][10] page to get started!

## Example Agent Configurations
{{% dbm-postgres-agent-config-examples %}}

## Install the Azure PostgreSQL Integration

To collect more comprehensive database metrics from Azure, install the [Azure PostgreSQL integration][11] (optional).
Expand Down
Loading