Monitoring a PostgreSQL Patroni Cluster
source link: https://www.percona.com/blog/monitoring-a-postgresql-patroni-cluster/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Monitoring a PostgreSQL Patroni Cluster
June 9, 2023
Percona Monitoring and Management (PMM) boasts many functionalities that support its extension, be it by using Custom Queries, Custom Scripts, or by collecting data from already available External Exporters.
In this short blog post, we will see how to quickly (and easily) monitor a PostgreSQL cluster managed by Patroni. I will assume you already have an environment set up and running in which the PMM client is already monitoring the PostgreSQL database. I will assume a three-node PostgreSQL cluster, but it will, of course, work with other setups. If needed, refer to the online documentation on this:
https://docs.percona.com/percona-monitoring-and-management/setting-up/client/postgresql.html
Adding the Patroni metrics to PMM
Since version 2.1.0, Patroni exposes metrics in a Prometheus-compatible way via the /metrics endpoint:
https://patroni.readthedocs.io/en/latest/releases.html#version-2-1-0
This means that we can instantly benefit from them by using the PMM External Exporters feature:
https://docs.percona.com/percona-monitoring-and-management/setting-up/client/external.html
In a nutshell, we just need to run the following in each client node:
shell> pmm-admin add external --listen-port=8008 --service-name=pg-nodeX-patroni |
Where –service-name can be whatever naming scheme you want that lets you easily know which Patroni node it refers to.
After running these commands and waiting some seconds, we should see metrics incoming in the Advanced Data Exploration dashboard, like the patroni_primary one:
Up to now, no Patroni dashboard would use these metrics. So I took the chance while working on a customer ticket to improve this and created my own dashboard (which is proof of the power behind PMM’s extensibility, in my opinion).
Importing the new Patroni Dashboard
I have uploaded the dashboard to Grafana Labs so it’s easy for everyone to import and use. You can use the ID 18870 to do so in three easy steps.
1- Click on the Import dashboard button in PMM:
2- Select the ID:
3- Select the PostgreSQL folder, and Metrics, and import it:
After this, you should be able to see all the information available from the Patroni /metrics endpoint in your PMM! (Actually, all but patroni_xlog_replayed_timestamp, patroni_cluster_unlocked, and patroni_failsafe_mode_is_active). The dashboard is split into three main sections:
In the headers, we can see information about a node in particular (the one selected in the service_name drop-down list):
- Patroni information like version, communication with the DCS, if it’s the current leader, etc.
- PostgreSQL information like version, if it’s running, its timeline number, etc.
Then we have the Patroni section, with graphs showing which were the Patroni primary and replica nodes at any time.
Finally, we have a PostgreSQL section, with graphs showing which were the PostgreSQL primary and replica nodes at any time and information on WAL generation and application.
The following two screenshots show this more clearly:
Conclusion
Adding new information to PMM is easy, and in this case, it’s even easier because all the moving parts are already developed, and it’s a matter of simply knowing how to connect them.
Percona Monitoring and Management is a best-of-breed open source database monitoring solution. It helps you reduce complexity, optimize performance, and improve the security of your business-critical database environments, no matter where they are located or deployed.
Download Percona Monitoring and Management Today
Share This Post!
Recommend
-
60
In this blog, we will see how to configure Percona Monitoring and Management (PMM) monitoring for a MongoDB cluster. It’s very simple, like adding a replica set or standalone instances to PMM Monitoring. For th...
-
6
Enterprise Application Monitoring and Management for Akka.NET OSS
-
2
Ganglia Cluster Monitoring: monitoring spark cluster Reading Time: 3 minutesGanglia is cluster monitoring tool to monitor...
-
7
Uncategorized Monitoring a Cassandra Database Cluster with vReal...
-
8
How Patroni Addresses the Problem of the Logical Replication Slot Failover in a PostgreSQL Cluster Back to the Blog Failover of the logical replication slot has al...
-
1
Securing Patroni REST API End Points Back to the Blog In recent years, Patroni emerged as the number one HA framework for PostgreSQL, currently...
-
1
In the first part of the article, we discussed how to achieve minimum security by adding a username and password to Patroni REST API and switch...
-
3
Rebuild Patroni Replica Using pgBackRest Back to the Blog Patroni is one of the most used high availability (HA) solutions with the PostgreSQL d...
-
3
因环境有限,本文在一台机器上实现基于Patroni的PostgreSQL高可用服务测试。1、安装软件包[root@lee ~]# yum -y install https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/yum/reporpms/EL-7-x86_64/pgdg...
-
1
Release notes¶ Version 3.0.2
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK