{"id":32615,"date":"2024-05-15T16:37:58","date_gmt":"2024-05-15T14:37:58","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=32615"},"modified":"2024-05-15T16:38:01","modified_gmt":"2024-05-15T14:38:01","slug":"setting-up-prometheus-and-grafana-for-a-patroni-cluster","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/","title":{"rendered":"Setting Up Prometheus and Grafana for a Patroni cluster"},"content":{"rendered":"\n<p>In today&#8217;s data-driven world, monitoring and visualizing the health and performance of your database clusters is a must. With tools like Prometheus and Grafana, you can gain valuable insights into your PostgreSQL Patroni setup, ensuring its smooth operation and proactive maintenance. In this guide, we&#8217;ll walk you through the steps of installing and configuring Prometheus and Grafana to monitor your PostgreSQL Patroni cluster effectively.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-existing-setup\">Existing Setup<\/h2>\n\n\n\n<p>Before we dive into installation, let&#8217;s take a quick look at my existing setup. I have a Patroni cluster composed of three openSUSE 15.5 servers with etcd version 3.5.13. Two nodes are running with PostgreSQL instances, version 16.2, and Patroni version 3.3.0. All binaries are stored in <code>\/u01<\/code> and data in <code>\/u02<\/code>.<\/p>\n\n\n\n<p>The setup of Prometheus and Grafana will be made from the first node of my cluster, patroni1 (192.168.56.125).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@patroni1:\/home\/postgres &#091;pg162] patronictl list\n+ Cluster: joan-cluster (7360609570873002877) ----+----+-----------+\n| Member   | Host           | Role    | State     | TL | Lag in MB |\n+----------+----------------+---------+-----------+----+-----------+\n| patroni1 | 192.168.56.125 | Leader  | running   |  1 |           |\n| patroni2 | 192.168.56.126 | Replica | streaming |  1 |         0 |\n+----------+----------------+---------+-----------+----+-----------+\n\npostgres=# select version();\n                                                version                               &gt;\n--------------------------------------------------------------------------------------------&gt;\n PostgreSQL 16.2 dbi services build on x86_64-pc-linux-gnu, compiled by gcc (SUSE Linux) 7.5&gt;\n(1 row)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-1-installing-prometheus\">1. Installing Prometheus<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-1-download-prometheus\">1.1. Download Prometheus<\/h3>\n\n\n\n<p>Grab the latest release from the <a href=\"https:\/\/prometheus.io\/download\/\">official website<\/a> or use wget:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/github.com\/prometheus\/prometheus\/releases\/download\/v2.51.2\/prometheus-2.51.2.linux-amd64.tar.gz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-2-extract-and-move-files\">1.2. Extract and Move Files<\/h3>\n\n\n\n<p>Extract the downloaded file and move it to the desired location:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar xzf prometheus-2.51.2.linux-amd64.tar.gz\nmv prometheus-2.51.2.linux-amd64 \/u01\/app\/postgres\/product\/\nrm prometheus-2.51.2.linux-amd64.tar.gz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-3-create-configuration-file\">1.3. Create Configuration File<\/h3>\n\n\n\n<p>Create or edit the <code>prometheus.yml<\/code> file to define scrape configurations:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@patroni1:\/home\/postgres\/ &#091;pg162] vi \/u01\/app\/postgres\/product\/prometheus-2.51.2.linux-amd64\/prometheus.yml\n\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] cat \/u01\/app\/postgres\/product\/prometheus-2.51.2.linux-amd64\/prometheus.yml\n# my global config\nglobal:\n  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.\n  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.\n  # scrape_timeout is set to the global default (10s).\n\n# Alertmanager configuration\nalerting:\n  alertmanagers:\n  - static_configs:\n    - targets:\n      # - alertmanager:9093\n\n# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.\nrule_files:\n  # - \"first_rules.yml\"\n  # - \"second_rules.yml\"\n\n# A scrape configuration containing exactly one endpoint to scrape:\n# Here it's Prometheus itself.\nscrape_configs:\n  - job_name: 'prometheus'\n    static_configs:\n    - targets: &#091;'192.168.56.125:9090']\n\n  - job_name: 'postgres_exporter_PG1'\n    metrics_path: '\/metricsRestart=always'\n    static_configs:\n    - targets: &#091;'192.168.56.125:9187']\n\n  - job_name: 'patroni'\n    metrics_path: '\/metrics'\n    static_configs:\n    - targets: &#091;'192.168.56.125:8008']<\/code><\/pre>\n\n\n\n<p>In this case, we are only going to monitor the PostgreSQL instance on the server 192.168.56.125 but you could also modify Prometheus configuration and integrate the PostgreSQL exporter for the server 192.168.56.126.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-4-create-prometheus-service-file\">1.4. Create Prometheus Service File<\/h3>\n\n\n\n<p>Define a systemd service for Prometheus:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@patroni1:\/home\/postgres\/ &#091;pg162] sudo vi \/etc\/systemd\/system\/prometheus.service\n\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] cat \/etc\/systemd\/system\/prometheus.service\n&#091;Unit]\nDescription=Prometheus Server\nDocumentation=https:\/\/prometheus.io\/docs\/introduction\/overview\/\nAfter=network-online.target\n\n&#091;Service]\nUser=postgres\nRestart=on-failure\n#Type=simple\nExecStart=\/u01\/app\/postgres\/product\/prometheus-2.51.2.linux-amd64\/prometheus --storage.tsdb.path=\/u02\/pgdata\/prometheus\/ --web.external-url=http:\/\/192.168.56.125:9090 --config.file=\/u01\/app\/postgres\/product\/prometheus-2.51.2.linux-amd64\/prometheus.yml\nRestart=always\nRestartSec=10s\nLimitNOFILE=40000\nKillMode=process\n\n&#091;Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-5-start-and-check-prometheus-service\">1.5. Start and Check Prometheus Service<\/h3>\n\n\n\n<p>Don&#8217;t forget to open port 9090 if your firewall is enable.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl daemon-reload\nsudo systemctl enable --now prometheus.service\nsudo systemctl status prometheus.service<\/code><\/pre>\n\n\n\n<p>Go to the URL: http:\/\/192.168.56.125:9090\/<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"923\" height=\"434\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-23.png\" alt=\"\" class=\"wp-image-32809\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-23.png 923w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-23-300x141.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-23-768x361.png 768w\" sizes=\"auto, (max-width: 923px) 100vw, 923px\" \/><\/figure>\n\n\n\n<p>In the appbar, click on the menu <strong>Status <\/strong>and then <strong>Targets <\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"923\" height=\"321\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-24.png\" alt=\"\" class=\"wp-image-32811\" style=\"width:840px;height:auto\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-24.png 923w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-24-300x104.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-24-768x267.png 768w\" sizes=\"auto, (max-width: 923px) 100vw, 923px\" \/><\/figure>\n\n\n\n<p>We have an alert because we still need to setup postgres_exporter, but this is normal, so here comes the next step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-2-integration-of-postgresql-exporter\">2. Integration of PostgreSQL Exporter<\/h2>\n\n\n\n<p>The PostgreSQL Exporter allows us to gather PostgreSQL metrics for Prometheus. It\u2019s developed by the Prometheus community and available on their github: <a href=\"https:\/\/github.com\/prometheus-community\/postgres_exporter.\">https:\/\/github.com\/prometheus-community\/postgres_exporter<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-1-download-postgresql-exporter\">2.1. Download PostgreSQL Exporter<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@patroni1:\/home\/postgres\/ &#091;pg162] wget https:\/\/github.com\/prometheus-community\/postgres_exporter\/releases\/download\/v0.15.0\/postgres_exporter-0.15.0.linux-amd64.tar.gz\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] tar xvf postgres_exporter-0.15.0.linux-amd64.tar.gz\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] mv postgres_exporter-0.15.0.linux-amd64 \/u01\/app\/postgres\/product\/\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] rm postgres_exporter-0.15.0.linux-amd64.tar.gz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-2-create-service-file\">2.2. Create Service File<\/h3>\n\n\n\n<p>Define a systemd service for the PostgreSQL Exporter:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@patroni1:\/home\/postgres\/ &#091;pg162] sudo vi \/etc\/systemd\/system\/postgres-exporter-pg1.service \npostgres@patroni1:\/home\/postgres\/ &#091;pg162] sudo cat \/etc\/systemd\/system\/postgres-exporter-pg1.service \n&#091;Unit]\nDescription=Prometheus exporter for Postgresql\nWants=network-online.target\nAfter=network-online.target\n\n&#091;Service]\nUser=postgres\nGroup=postgres\nWorkingDirectory=\/u01\/app\/postgres\/product\/postgres_exporter-0.15.0.linux-amd64\nEnvironmentFile=\/u01\/app\/postgres\/product\/postgres_exporter-0.15.0.linux-amd64\/postgres-exporter-PG1.env\nExecStart=\/u01\/app\/postgres\/product\/postgres_exporter-0.15.0.linux-amd64\/ --web.listen-address=:9187 --web.telemetry-path=\/metricsRestart=always\n\n&#091;Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n<p>Create the necessary env file and open the necessary firewall port:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@patroni1:\/home\/postgres\/ &#091;pg162] sudo vi \/u01\/app\/postgres\/product\/postgres_exporter-0.15.0.linux-amd64\/postgres-exporter-PG1.env\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] sudo cat \/u01\/app\/postgres\/product\/postgres_exporter-0.15.0.linux-amd64\/postgres-exporter-PG1.env\nDATA_SOURCE_NAME=\"postgresql:\/\/postgres:postgres@192.168.56.125:5432\/?sslmode=disable\"\n\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] sudo firewall-cmd --zone=public --add-port=9187\/tcp --permanent\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] sudo firewall-cmd --reload<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-3-start-service-and-check-targets\">2.3. Start Service and Check Targets<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable postgres-exporter-pg1.service\nsudo systemctl start postgres-exporter-pg1.service<\/code><\/pre>\n\n\n\n<p>The error has now disappeared and Prometheus is able to collect metrics for PostgreSQL.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"923\" height=\"316\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-25.png\" alt=\"\" class=\"wp-image-32815\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-25.png 923w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-25-300x103.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-25-768x263.png 768w\" sizes=\"auto, (max-width: 923px) 100vw, 923px\" \/><\/figure>\n\n\n\n<p>It\u2019s time to put in lights our metrics thanks to some Graphs, let\u2019s install Grafana.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-3-installing-and-configuring-grafana\">3. Installing and Configuring Grafana<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-1-download\">3.1. Download<\/h3>\n\n\n\n<p>Download Grafana:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@patroni1:\/home\/postgres\/ &#091;pg162] wget https:\/\/dl.grafana.com\/oss\/release\/grafana-10.4.2.linux-amd64.tar.gz\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] tar -zxvf grafana-10.4.2.linux-amd64.tar.gz\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] mv grafana-10.4.2.linux-amd64 \/u01\/app\/postgres\/product\/\npostgres@patroni1:\/home\/postgres\/ &#091;pg162] rm grafana-10.4.2.linux-amd64.tar.gz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-2-create-service-file\">3.2. Create Service File:<\/h3>\n\n\n\n<p>Define a systemd service for Grafana:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>15:45:16 postgres@patroni1:\/home\/postgres\/ &#091;pg162] sudo vi \/etc\/systemd\/system\/grafana.service\n15:45:16 postgres@patroni1:\/home\/postgres\/ &#091;pg162] sudo cat \/etc\/systemd\/system\/grafana.service\n&#091;Unit]\nDescription=Grafana Server\nAfter=prometheus.service\n\n&#091;Service]\nUser=postgres\nRestart=on-failure\nWorkingDirectory=\/u01\/app\/postgres\/product\/grafana-10.4.2.linux-amd64\/\n#Type=simple\nExecStart=\/u01\/app\/postgres\/product\/grafana-10.4.2.linux-amd64\/bin\/grafana-server\nRestart=always\nRestartSec=10s\nLimitNOFILE=40000\nKillMode=process\n\n&#091;Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-3-start-and-access-grafana\">3.3. Start and Access Grafana<\/h3>\n\n\n\n<p>You can now start Grafana but don&#8217;t forget to open the necessary firewall port:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo firewall-cmd --zone=public --add-port=3000\/tcp --permanent\nsudo firewall-cmd --reload\nsudo systemctl daemon-reload\nsudo systemctl enable grafana.service \nsudo systemctl start grafana.service<\/code><\/pre>\n\n\n\n<p>You can access Grafana via the URL: <a href=\"http:\/\/192.168.56.125:3000\/login\">http:\/\/192.168.56.125:3000\/<\/a><br>On the first prompt, you will be asked for a user name and password, you can use Username: admin, Password: admin.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-4-add-a-data-source\">3.4. Add a data source<\/h3>\n\n\n\n<p>Before to import a Dashboard, you first have to add a data source. Go to <strong><em>Home <\/em><\/strong>&gt; <strong><em>Connections <\/em><\/strong>&gt; <strong><em>Data <\/em><\/strong><em><strong>sources<\/strong> <\/em>and click <strong><em>Add data source<\/em><\/strong>.<br>Select Prometheus and then change the Prometheus server URL<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"923\" height=\"201\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-26.png\" alt=\"\" class=\"wp-image-32825\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-26.png 923w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-26-300x65.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-26-768x167.png 768w\" sizes=\"auto, (max-width: 923px) 100vw, 923px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-5-import-your-first-dashboard\">3.5. Import your first Dashboard<\/h3>\n\n\n\n<p>In the Dashboard page, click on the <strong><em>New <\/em><\/strong>menu and select <strong><em>import<\/em><\/strong>. You can import your first PostgreSQL dashboard thanks to the ID 9628, that will use the PostgreSQL exporter to monitor our leader instance. On the next screen, be sure to select the data source we just created, <strong>prometheus<\/strong>.<\/p>\n\n\n\n<p>You can now access your first Grafana dashboard \ud83d\ude04<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"483\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-27-1024x483.png\" alt=\"\" class=\"wp-image-32829\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-27-1024x483.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-27-300x142.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-27-768x363.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-27-1536x725.png 1536w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-27.png 1917w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-6-import-a-dashboard-to-monitor-patroni\">3.6. Import a dashboard to monitor Patroni<\/h3>\n\n\n\n<p>Patroni provides a REST API accessible with the port 8008 by default. It allows us to request and collect information related to Patroni cluster and nodes status (<a href=\"https:\/\/patroni.readthedocs.io\/en\/latest\/rest_api.html\">https:\/\/patroni.readthedocs.io\/en\/latest\/rest_api.html<\/a>). <br>As we configured Prometheus to have access to this API, we are now able to use it in Grafana to create some Dashboard.<br>I found a blog on the Percona website that provides an ID to import a Patroni Dashboard (<a href=\"https:\/\/www.percona.com\/blog\/monitoring-a-postgresql-patroni-cluster\/\">https:\/\/www.percona.com\/blog\/monitoring-a-postgresql-patroni-cluster\/<\/a>), <em>18870<\/em>. Thanks a lot to the author !<\/p>\n\n\n\n<p>Though this dashboard is made to work with a service from pmm, it still works with our setup ! In my case, I edited some of the tiles and even add one to know if Patroni is paused or not.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"484\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/Capture-decran-2024-04-24-085721-1024x484.png\" alt=\"\" class=\"wp-image-32832\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/Capture-decran-2024-04-24-085721-1024x484.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/Capture-decran-2024-04-24-085721-300x142.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/Capture-decran-2024-04-24-085721-768x363.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/Capture-decran-2024-04-24-085721-1536x726.png 1536w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/Capture-decran-2024-04-24-085721.png 1911w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It&#8217;s now your turn to create and edit nice dashboard, as per your needs. Even without a lot of knowledge on Grafana, it is quite easy to create nice and useful dashboards, and that is what I like.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-4-conclusion\">4. Conclusion<\/h2>\n\n\n\n<p>With Prometheus for data collection, PostgreSQL Exporter and Patroni API for metrics extraction, and Grafana for visualization, you now have a comprehensive monitoring setup for your PostgreSQL Patroni cluster. By utilizing these tools effectively, you can ensure the stability, performance, and health of your database environment. Happy monitoring! \ud83d\ude04<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In today&#8217;s data-driven world, monitoring and visualizing the health and performance of your database clusters is a must. With tools like Prometheus and Grafana, you can gain valuable insights into your PostgreSQL Patroni setup, ensuring its smooth operation and proactive maintenance. In this guide, we&#8217;ll walk you through the steps of installing and configuring Prometheus [&hellip;]<\/p>\n","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229],"tags":[2257,143,2247,1543,77,2234],"type_dbi":[3124,3347,3335,3060,2749,3346],"class_list":["post-32615","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring","tag-grafana","tag-monitoring","tag-opensuse","tag-patroni","tag-postgresql","tag-prometheus","type-grafana","type-monitoring","type-opensuse","type-patroni","type-postgresql","type-prometheus"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Setting Up Prometheus and Grafana for a Patroni cluster - dbi Blog<\/title>\n<meta name=\"description\" content=\"Learn how to effectively monitor and visualize your Patroni cluster using Prometheus and Grafana. Follow step-by-step instructions to install and configure these powerful tools, ensuring the smooth operation and proactive maintenance of your database environment.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting Up Prometheus and Grafana for a Patroni cluster\" \/>\n<meta property=\"og:description\" content=\"Learn how to effectively monitor and visualize your Patroni cluster using Prometheus and Grafana. Follow step-by-step instructions to install and configure these powerful tools, ensuring the smooth operation and proactive maintenance of your database environment.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-05-15T14:37:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-15T14:38:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-23.png\" \/>\n<meta name=\"author\" content=\"Joan Frey\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joan Frey\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/\"},\"author\":{\"name\":\"Joan Frey\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/c03c47649664fe73b27ce457e99f5b06\"},\"headline\":\"Setting Up Prometheus and Grafana for a Patroni cluster\",\"datePublished\":\"2024-05-15T14:37:58+00:00\",\"dateModified\":\"2024-05-15T14:38:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/\"},\"wordCount\":755,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/04\\\/image-23.png\",\"keywords\":[\"Grafana\",\"Monitoring\",\"OpenSUSE\",\"Patroni\",\"PostgreSQL\",\"Prometheus\"],\"articleSection\":[\"Database Administration &amp; Monitoring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/\",\"name\":\"Setting Up Prometheus and Grafana for a Patroni cluster - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/04\\\/image-23.png\",\"datePublished\":\"2024-05-15T14:37:58+00:00\",\"dateModified\":\"2024-05-15T14:38:01+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/c03c47649664fe73b27ce457e99f5b06\"},\"description\":\"Learn how to effectively monitor and visualize your Patroni cluster using Prometheus and Grafana. Follow step-by-step instructions to install and configure these powerful tools, ensuring the smooth operation and proactive maintenance of your database environment.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/04\\\/image-23.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/04\\\/image-23.png\",\"width\":923,\"height\":434},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Setting Up Prometheus and Grafana for a Patroni cluster\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/c03c47649664fe73b27ce457e99f5b06\",\"name\":\"Joan Frey\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g\",\"caption\":\"Joan Frey\"},\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/joanfrey\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Setting Up Prometheus and Grafana for a Patroni cluster - dbi Blog","description":"Learn how to effectively monitor and visualize your Patroni cluster using Prometheus and Grafana. Follow step-by-step instructions to install and configure these powerful tools, ensuring the smooth operation and proactive maintenance of your database environment.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/","og_locale":"en_US","og_type":"article","og_title":"Setting Up Prometheus and Grafana for a Patroni cluster","og_description":"Learn how to effectively monitor and visualize your Patroni cluster using Prometheus and Grafana. Follow step-by-step instructions to install and configure these powerful tools, ensuring the smooth operation and proactive maintenance of your database environment.","og_url":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/","og_site_name":"dbi Blog","article_published_time":"2024-05-15T14:37:58+00:00","article_modified_time":"2024-05-15T14:38:01+00:00","og_image":[{"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-23.png","type":"","width":"","height":""}],"author":"Joan Frey","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Joan Frey","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/"},"author":{"name":"Joan Frey","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c03c47649664fe73b27ce457e99f5b06"},"headline":"Setting Up Prometheus and Grafana for a Patroni cluster","datePublished":"2024-05-15T14:37:58+00:00","dateModified":"2024-05-15T14:38:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/"},"wordCount":755,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-23.png","keywords":["Grafana","Monitoring","OpenSUSE","Patroni","PostgreSQL","Prometheus"],"articleSection":["Database Administration &amp; Monitoring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/","url":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/","name":"Setting Up Prometheus and Grafana for a Patroni cluster - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-23.png","datePublished":"2024-05-15T14:37:58+00:00","dateModified":"2024-05-15T14:38:01+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c03c47649664fe73b27ce457e99f5b06"},"description":"Learn how to effectively monitor and visualize your Patroni cluster using Prometheus and Grafana. Follow step-by-step instructions to install and configure these powerful tools, ensuring the smooth operation and proactive maintenance of your database environment.","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-23.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/04\/image-23.png","width":923,"height":434},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/setting-up-prometheus-and-grafana-for-a-patroni-cluster\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Setting Up Prometheus and Grafana for a Patroni cluster"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c03c47649664fe73b27ce457e99f5b06","name":"Joan Frey","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g","caption":"Joan Frey"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/joanfrey\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/32615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=32615"}],"version-history":[{"count":48,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/32615\/revisions"}],"predecessor-version":[{"id":32864,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/32615\/revisions\/32864"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=32615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=32615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=32615"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=32615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}