Out of the box PostgreSQL monitoring with InfluxDB and Grafana dashboards
Tags: grafana, monitoring, influxdb
Published: 2023-03-08 07:58:44

---
title: Out of the box PostgreSQL monitoring with InfluxDB and Grafana dashboards
published: true
date: 2023-03-07 11:00:20 UTC
tags: grafana,monitoring,influxdb
canonical_url: https://aiven.io/blog/monitor-aiven-influxdb-grafana-dashboards
---

Grafana® visualizes time series data as a graph, allowing you to observe how your application behaves over time. Grafana dashboards offer insights to all kinds of stakeholders, regardless of their technical skills. It's no surprise then that Grafana was built on the principle that data should be accessible to everyone in your organization. 

[Aiven for Grafana®](https://aiven.io/blog/what-is-grafana?utm_source=devto&utm_medium=organic&utm_campaign=blog_art) lets you monitor your stack with a number of prebuilt dashboards for many services! This gives you a head start in organizing your data for observability so you can get back to building your application.

Aiven lets you integrate with services in two different ways: 
* **External integrations** allow you to expose your service metrics and logs to external tools you might be already using like Datadog or AWS Cloudwatch
* **Internal integrations** allow you to use other Aiven services to build your monitoring platform

This allows you the flexibility to send your service metrics to monitoring and observability tools you might already be using, or to take advantage of the ease of configuration and management that Aiven provides. In this example, we'll be using an internal integration with Grafana to show you how quick and easy it is, but in reality Aiven offers you many 
options!

We'll set up monitoring for an Aiven for PostgreSQL® database using Aiven for InfluxDB® as back-end for our time series metrics, and Aiven for Grafana® as a metrics dashboard.

## Set up PostgreSQL

First we need to create the PostgreSQL database. Head over to the 
[Aiven Console](https://console.aiven.io/?utm_source=devto&utm_medium=organic&utm_campaign=blog_art) to create a new service 
with the following configuration:

- Cloud service provider: Any provider
- Service plan: Business-4. For this tutorial, we need a high availability pair. 
- Service name: `pg-to-be-monitored`

## Set up the metrics integration

The PostgreSQL instance takes time to initialize, but we can start our integration with InfluxDB while it finishes. On the `pg-to-be-monitored` service detail page, click on the **Integrations** tab and explore the list of available options.

Aiven integrations are divided into two main sections:
* **External integrations** allow you to expose your service metrics and logs to external tools you might be already using like Datadog or AWS Cloudwatch
* **Internal integrations** allow you to use other Aiven services to build your monitoring platform

Select the **Store Metrics** option, as this lets us use Aiven's preconfigured Grafana dashboards in the next step. In the popup window we then select the target backend and either reuse an existing service, or spin up a new service. 

In most cases, you should send your monitoring to a separate database and stack to prevent monitoring failures. 

![Store Metrics integration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ksfp39f0ytivyelaothm.png)

Aiven lets you create any new services needed for an internal integration from an existing service, with no need to navigate back out to the console home. Select the **New service** > **New InfluxDB service**.  Then we'll be able to chose the service name, Cloud provider, region and service plan. 

![New InfluxDB service for the metrics integration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hx15tpillv53dvj8u6kb.png)

Tip:  Using the same cloud provider and region you used for your PostgreSQL database when setting up your monitoring database and dashboard reduces overall latency.

## Set up Grafana

After sending our metrics to InfluxDB, we might want to perform some analytics and set up some dashboards for it. The good news is that Aiven can do all that for us. We can head to the newly created InfluxDB service, and click again on the *Integrations* tab, from which we can select **Grafana Metrics Dashboards**. 

![Grafana Metrics Dashboards integration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0cmbltsjsovnjl6izfud.png)

We can either reuse an existing Grafana service or create a new one. If you need to create a new Aiven for Grafana service, select it from the Dashboard homepage and select an appropriate cloud provider, region, service plan and name.

Now we can review the list of integrations in the Aiven for InfluxDB service.

![InfluxDB integrations with PostgreSQL and Grafana](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/82qjqwco8bd3kvq7fr4c.png)


## Check the pre-built dashboards

Once the Grafana instance is up and running, find the URI, username and password on the service homepage and log into your Grafana instance.

Do we need to hand craft a new dashboard? Absolutely not, that's time consuming! We can reuse what the Aiven engineers are using to monitor Aiven itself: the dashboard integration created at the previous step already set up a prebuilt visualization on all the most important metrics. 

To access the prebuilt dashboard we need to:

1. Login to Grafana
2. Navigate to **Dashboard** and then **Browse**
3. Under the **General** folder we can find a dashboard name `Aiven for PostgreSQL - <SERVICE_NAME> - Resources`
4. Click on it, and... Profit!

![Grafana dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ikyrugv58bq3sn1bqxh.png)

Tip: If you want to change the dashboard, create a copy of it and rename it, otherwise your changes will be lost when we upgrade. 

## New features in Grafana 9

At the time of this writing, Aiven supports Grafana 9.2.4. Grafana 9 is a major version bump with exciting new features, like new UI query builders for Prometheus and Loki, and a renewed heatmap panel. Hoang Minh Vo, Technical Product Manager at Aiven, [wrote about the Grafana 9 features he's excited about](https://aiven.io/blog/strengthen-your-monitoring-game-with-grafana-9?utm_source=devto&utm_medium=organic&utm_campaign=blog_art), and that [Grafana Alerting is now on by default](https://grafana.com/docs/grafana/latest/whatsnew/whats-new-in-v9-0/#grafana-alerting-is-the-default-in-grafana-9). 

Excited to try out Grafana Alerting? Use their [sandbox](https://play.grafana.org/alerting/list) to get a feel for the feature. 

You can set up other Aiven services as data sources for Grafana too, like MySQL, ClickHouse®, OpenSearch® and InfluxDB®. Try it out with your database today!