> For the complete documentation index, see [llms.txt](https://docs.datasentinel.io/manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datasentinel.io/manual/getting-started/postgresql-clusters.md).

# PostgreSQL clusters

How to prepare a PostgreSQL cluster for Datasentinel: the extensions, the monitoring user, the connection, and the optional internal function.

Datasentinel can monitor hundreds of PostgreSQL clusters. One connection per cluster is enough: it covers all the databases of the cluster.

Preparing a cluster takes three steps, and a fourth optional one. They are the same with the agent-based and the agentless methods.

{% hint style="info" %}
**Prerequisites.** PostgreSQL version 9.4 or later, with the [pg\_stat\_statements](https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/extensions/pg_stat_statements.md) extension installed in the internal database named `postgres`.
{% endhint %}

## Steps

{% stepper %}
{% step %}

### Install the extensions

`pg_stat_statements` is required. The other extensions are optional and each adds a capability.

See [Extensions](https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/extensions.md).
{% endstep %}

{% step %}

### Create the monitoring user

Datasentinel connects with a dedicated PostgreSQL user. It only reads metrics and writes no data.

See [Monitoring User](https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/monitoring-user.md).
{% endstep %}

{% step %}

### Add the connection

Declare the cluster, with its [tags](https://docs.datasentinel.io/manual/features/tips-and-hints/tags.md): through the agent, or on the platform for an agentless connection.

See [Adding Connection](https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/adding-connection.md).
{% endstep %}

{% step %}

### Install the internal function (optional)

The `datasentinel_analytics` function gives access to planner statistics and execution plans, with no SELECT privilege on your tables.

See [Internal Function](https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/internal-function.md).
{% endstep %}
{% endstepper %}

## Extensions at a glance

| Extension                                                                                                                        | Required           | Install in              | What it brings                                                                                                                   |
| -------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| [pg\_stat\_statements](https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/extensions/pg_stat_statements.md) | Yes                | The `postgres` database | Query statistics, used by [Top Queries](https://docs.datasentinel.io/manual/features/key-features/top-queries.md)                |
| [pg\_store\_plans](https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/extensions/pg_store_plans.md)         | No                 | The `postgres` database | [Execution plans](https://docs.datasentinel.io/manual/features/other-features/execution-plans.md) and their statistics over time |
| [system\_stats](https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/extensions/system_stats.md)              | No, agentless only | The `postgres` database | [System metrics](https://docs.datasentinel.io/manual/features/key-features/cluster-and-system-metrics.md) without a local agent  |
| [pg\_buffercache](https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/extensions/pg_buffercache.md)          | No                 | Every database          | Cache usage in [Live360](https://docs.datasentinel.io/manual/features/key-features/live360.md#cache-usage)                       |

Datasentinel detects the optional extensions on its own and uses them when they are installed.

## Monitoring user at a glance

| PostgreSQL version | What the user needs                                                    |
| ------------------ | ---------------------------------------------------------------------- |
| 10 and later       | The roles `pg_monitor`, `pg_read_all_settings` and `pg_read_all_stats` |
| Before 10          | The superuser role                                                     |

Two additions are optional:

* The `pg_signal_backend` role, to terminate a session from [Live360](https://docs.datasentinel.io/manual/features/key-features/live360.md).
* The `monitor_system_stats` role, when the `system_stats` extension is used.

The user must also be allowed to connect to all the databases in `pg_hba.conf`.

## Internal function at a glance

The function is optional and is installed in each application database. With it, Datasentinel adds:

* Table and index bloat estimates.
* Column statistics and extended statistics.
* Live execution plans, in Live360 and AI Connector.

With local agents, it needs agent version 4.0.0 or later. Every other metric works without it.

## Pages

<table data-view="cards"><thead><tr><th data-type="content-ref"></th></tr></thead><tbody><tr><td><a href="https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/extensions.md">Extensions</a></td></tr><tr><td><a href="https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/monitoring-user.md">Monitoring User</a></td></tr><tr><td><a href="https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/adding-connection.md">Adding Connection</a></td></tr><tr><td><a href="https://docs.datasentinel.io/manual/getting-started/postgresql-clusters/internal-function.md">Internal Function</a></td></tr></tbody></table>

## See also

* [Installation](https://docs.datasentinel.io/manual/getting-started/installation.md): the platform and the agents.
* [Agentless Monitoring](https://docs.datasentinel.io/manual/features/other-features/agentless-monitoring.md): connections declared on the platform.
* [FAQs](https://docs.datasentinel.io/manual/getting-started/faqs.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.datasentinel.io/manual/getting-started/postgresql-clusters.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
