---
title: "Troubleshoot PostgreSQL | Database Observability documentation"
description: "Troubleshoot PostgreSQL setup steps for Database Observability and validate configuration."
---

# Troubleshoot PostgreSQL

Identify and resolve issues from each step of the PostgreSQL get started guide. Use these checks to verify your database configuration and confirm that Grafana Alloy is wired correctly. These steps do not repeat setup. If a setting is incorrect, refer back to the corresponding step in the get started article to apply the change.

## What you’ll achieve

In this article, you:

- Validate PostgreSQL extensions, user permissions, and object access.
- Confirm `track_activity_query_size`.
- Troubleshoot Alloy configuration for logs and metrics forwarding.

## Before you begin

Make sure you can connect to your PostgreSQL server and have sufficient privileges to run validation queries. Keep the PostgreSQL get started article open to reapply any missing configuration.

## Verify `pg_stat_statements` is enabled

Check that the extension exists in each monitored database:

SQL ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```sql
SELECT * FROM pg_extension WHERE extname = 'pg_stat_statements';
```

- If it’s missing, refer to the [Enable `pg_stat_statements`](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#enable-pg_stat_statements) section in the setup guide.

## Confirm `pg_stat_statements.track` value

Check the value of `pg_stat_statements.track`:

SQL ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```sql
show pg_stat_statements.track;
```

Expected result: Value is `all`.

- If the value differs, refer to the [Set `pg_stat_statements.track`](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#set-pg_stat_statements.track) section in the setup guide.
- Do not set `pg_stat_statements.track` to `none` because it will disable statement statistics collection. Refer to the [documentation](https://www.postgresql.org/docs/current/pgstatstatements.html#PGSTATSTATEMENTS-CONFIG-PARAMS) for more details.

## Confirm `track_activity_query_size` value

Check the size of SQL text in `pg_stat_activity`:

SQL ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```sql
show track_activity_query_size;
```

Expected result: `4kB` (4096).

- If the value differs, refer to the [Increase `track_activity_query_size`](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#increase-track_activity_query_size) section in the setup guide.

## Validate monitoring user and base privileges

Verify that the monitoring user can query `pg_stat_statements`:

SQL ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```sql
-- run with the `db-o11y` user
SELECT * FROM pg_stat_statements LIMIT 1;
```

- If this query fails, refer to the [Create a monitoring user and grant required privileges](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#create-a-monitoring-user-and-grant-required-privileges) section in the setup guide.

Verify that the monitoring user has `pg_monitor` and `pg_read_all_stats` roles:

SQL ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```sql
SELECT pg_has_role('db-o11y', 'pg_monitor', 'MEMBER');
SELECT pg_has_role('db-o11y', 'pg_read_all_stats', 'MEMBER');
```

Expected result: `t` (`true`).

- If the user is not a member of these roles, refer to the [Create a monitoring user and grant required privileges](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#create-a-monitoring-user-and-grant-required-privileges) section in the setup guide.

## Check object-level access for detailed data

Verify that the monitoring user has `pg_read_all_data` role, which grants access to all objects:

SQL ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```sql
SELECT pg_has_role('db-o11y', 'pg_read_all_data', 'MEMBER');
```

Expected result: `t` (`true`).

Alternatively, ensure the monitoring user has `USAGE` and `SELECT` on relevant schemas and tables:

SQL ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```sql
SELECT has_database_privilege('db-o11y', 'your_database_name', 'CONNECT');

\c your_database_name

SELECT has_schema_privilege('db-o11y', 'your_schema_name', 'USAGE');
SELECT has_table_privilege('db-o11y', 'your_table_name', 'SELECT');
```

- If a schema lacks detailed data, refer to the [Grant object privileges for detailed data](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#grant-object-privileges-for-detailed-data) section in the setup guide.

## Check that tracking of monitoring user queries is disabled

Confirm that the `db-o11y` user has statements tracking disabled:

SQL ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```sql
select rolname, rolconfig from pg_roles where rolname = 'db-o11y';

 rolname |            rolconfig
---------+---------------------------------
 db-o11y | {pg_stat_statements.track=none}
```

- If the setting is not present or is not `none`, refer to the [Disable tracking of monitoring user queries](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#disable-tracking-of-monitoring-user-queries) section in the setup guide.

## Troubleshoot Alloy configuration

Validate component wiring, labels, scrape targets, and write endpoints. For guidance on exporters, components, relabeling, scrape jobs, and remote writes, refer to [Troubleshoot Alloy components](/docs/grafana-cloud/monitor-applications/database-observability/troubleshoot/alloy/).

## Next steps

For setup instructions, refer to [Set up PostgreSQL](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/).
