Grafana is an open source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources.

You can connect as a Grafana data source to build web dashboards for your data.

Configuring as Grafana Datasource

In order to connect Grafana with as data source, you'll need to find your PosgreSQL connection credentials from the Connect Tab of the database to which you would like to connect. You can find everything you need to know about your PostgreSQL credentials here.

Go to your Grafana instance and on the sidebar click on "Integrations and Connections" menu:


Now proceed to find the PostgreSQL Data source integration and click on it


Then click on "Create a PostgreSQL data source" button


Now enter your credentials and database details into the "PostgreSQL Connection" Section of the Data source configuration form.



Don't for get to set TLS/SSL Mode to either "require" or "verify-full".

On the "PostgreSQL details" section set version to 12+



Min time interval is the lower limit for the auto group by time interval. Recommended to be set to write frequency, for example 1m if your data is written every minute.

Now click on Save & test button and you should see the "Database Connection OK" success message.


Using Grafana with

Once we've set up our connection, we can start creating dashboards to visualize our data. Now proceed to create a new dashboard by going to the Sidebar on Dashboards -> New dashboard.


Now click on Add a new panel


On the Panel edit form select your Datasource and fill in the details for the following fields:

  • FROM: The PostgreSQL database name on your database
  • Time Column: The time column from your table
  • Metric Column: (Optional) The column providing the name for your metrics (if multiple metrics provided)
  • SELECT: 1 or more value columns
  • WHERE: (Optional) Conditions to apply. Leave the pre-filled value for dynamic filtering based on selected time range.
  • GROUP BY: (Optional) Fields to group values by. Add the "time" field to group aggregated values by time.

Refer to the official postgres datasource docs on the grafana website for more options, variables, querying, and other options specific to this data source.