Monitoring PostgreSQL Databases using Postgres exporter along with Prometheus and Grafana.

Photos via Pexels

Introduction

In my previous articles , i have covered monitoring using Prometheus along with Grafana. and alerting using the AlertManager integrated to Prometheus.

In today’s article, i will mainly cover the topic of integrating the Postgres exporter to Prometheus in order to get PostgreSQL databases metrics for a monitoring purpose.

Setting up the Postgres exporter

First, you need to download the postgres exporter binary tar archive and untar it as follows

Then, you need to prepare an env file for the postgres exporter where we will set a variable known as DATA_SOURCE_NAME.

Metrics from all defined databases in DATA_SOURCE_NAME will be collected.

First, create the user postgres

Then the service

Next, put the following inside

Finally, enable and start the service

Integrate the Postgres exporter to Prometheus

First, you need to edit prometheus.yml configuration file.

Then, add the new targets to scrape

Finally, reload the service

Display the metrics on Grafana Dashboard

There is plenty of interessting Grafana Dashboard for PostgreSQL monitoring:

Choose the Prometheus datasource and get your result.

Grafana Dashboard

References

All databases on the eyes. Postgres exporter + Prometheus + Grafana.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store