# Monitor High-Availability Clusters

<div data-with-frame="true"><figure><img src="https://1072624949-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlcWi6G1jtNuyGT9C0pkc%2Fuploads%2F5Y3x6LT9znkLUD43q6Gr%2Fha-cluster-postgres-patroni.png?alt=media&#x26;token=78dcc9fd-a571-4c78-ae45-9fa6e8a335e4" alt=""><figcaption></figcaption></figure></div>

This guide explains how Datasentinel detects and manages HA clusters, how instances are grouped, and how to analyze workload and activity in highly available PostgreSQL environments.

## HA Cluster Detection

Datasentinel automatically detects the role of each PostgreSQL instance, identifying primary instances and read-only replicas based on runtime characteristics.

{% hint style="info" %}
If a failover occurs, Datasentinel updates instance roles automatically to reflect the new cluster topology.
{% endhint %}

## Using Tags with HA Clusters

[**Tags**](https://docs.datasentinel.io/manual/how-to-guides/organize-content-using-tags) can be applied to PostgreSQL instances that belong to an HA cluster.

When instances share the same tag (for example, `ha_cluster=sales-app`), you can:

* Analyze the consolidated workload of the cluster
* Apply[ **role-based access control (RBAC)**](https://docs.datasentinel.io/manual/how-to-guides/manage-users-and-role-based-access) at the cluster level
* [**Filter dashboards**](https://docs.datasentinel.io/manual/how-to-guides/organize-content-using-tags) and reports by cluster or application

Tags combined with HA awareness provide powerful grouping and access-control capabilities.

## Consolidated Cluster View

Datasentinel provides a **cluster-level view** that aggregates activity across all instances in the HA cluster.

This allows you to:

* Analyze total workload across the cluster
* Compare activity between primary and replicas
* Identify load distribution and imbalance

Cluster-level analysis removes the need to inspect each instance individually.

<div data-with-frame="true"><figure><img src="https://1072624949-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlcWi6G1jtNuyGT9C0pkc%2Fuploads%2FvK3sGex2WWA9flF1bK31%2Fha-home-postgres-patroni-en.png?alt=media&#x26;token=9bcb429e-d21b-471c-bf50-b62f939e2500" alt=""><figcaption></figcaption></figure></div>

## Workload Analysis Across HA Clusters

Using Datasentinel dashboards and analysis modules, you can:

* View [**Top Queries**](https://docs.datasentinel.io/manual/features/key-features/top-queries) across the entire cluster
* Analyze [**Session Activity**](https://docs.datasentinel.io/manual/features/key-features/session-history) on primary and replicas
* Identify queries executed on replicas only
* Detect replication-aware workload patterns

This is particularly useful for understanding how applications leverage read replicas.

<div data-with-frame="true"><figure><img src="https://1072624949-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlcWi6G1jtNuyGT9C0pkc%2Fuploads%2FBICy6JC0sz4eWSrzBYjm%2Fha-ash-postgres-patroni-en.png?alt=media&#x26;token=d805c492-3d20-43e6-b9ed-901761feabb4" alt=""><figcaption></figcaption></figure></div>

## Viewing Replication Statistics

Datasentinel collects and logs replication statistics for PostgreSQL read replicas, providing clear visibility into replication health.

For each replica, Datasentinel allows you to:

* View the **WAL delta size**, representing the amount of data remaining to be replicated
* Monitor **replication delay**, indicating how far replicas lag behind the primary instance

<div data-with-frame="true"><figure><img src="https://1072624949-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlcWi6G1jtNuyGT9C0pkc%2Fuploads%2Fum5uzK9T40BQHLLvaVDH%2Fha-replication-postgres-patroni.png?alt=media&#x26;token=d6df6c95-1876-46ca-bf2b-481f1326afdd" alt=""><figcaption></figcaption></figure></div>

## Common Use Cases

Typical HA cluster monitoring scenarios include:

* Analyzing total workload across primary and replicas
* Verifying that read traffic is correctly routed to replicas
* Comparing query patterns between instances
* Monitoring cluster behavior during failover events

## Best Practices

* Use consistent tags across all instances in an HA cluster
* Combine cluster-level analysis with instance-level dashboards
* Review workload distribution regularly
* Use tags to control access to entire clusters via RBAC

{% hint style="info" %}
Datasentinel is compatible with read replicas from managed PostgreSQL services offered by major public cloud providers, including Amazon RDS, Microsoft Azure, and Google Cloud.
{% endhint %}

## Conclusion

Datasentinel provides clear visibility into high-availability PostgreSQL environments by automatically detecting primary and replica roles and enabling consolidated activity analysis across instances.
