Section 2 · Set up Database Observability

Set up Database Observability for PostgreSQL

Estimated time: 2 min

PostgreSQL with Database Observability

Database Observability gives you deep visibility into PostgreSQL query performance. This slide’s path is for a database you run yourself.

What it monitorsQuery performance, explain plans, wait events, query samples, table schemas
How it worksGrafana Alloy reads from pg_stat_statements and pg_stat_activity
What you seeTop queries by duration, explain plans with cost highlighting, wait events, query samples
This pathSelf-managed PostgreSQL 14 or later
Managed servicesAmazon RDS, Amazon Aurora, Google Cloud SQL, and Azure Database each have a setup guide

What you’ll get

  • Queries Overview dashboard showing RED metrics for tracked queries
  • Explain plans with visual graphs showing scan types, join strategies, and cost distribution
  • Wait events categorized by I/O, lock, and network waits from pg_stat_activity
  • Query samples with individual execution timing. Parameters are redacted by default.
  • Table schemas showing structures, indexes, and constraints

Before you start

A few things to keep in mind:

  • PostgreSQL 14 or later is required.
  • Load pg_stat_statements in shared_preload_libraries. Changing that setting requires a restart. Then create the extension in each database you want to monitor.
  • Query statistics need the pg_monitor and pg_read_all_stats roles.
  • Schema details and explain plans also need USAGE on each schema and SELECT on all tables in that schema, or the pg_read_all_data role if you want every object.
  • Amazon RDS, Amazon Aurora, Google Cloud SQL, and Azure Database use a separate setup guide, not this path.

The path below walks you through each step.


Learning path

PostgreSQL Database Observability

Set up Grafana Cloud Database Observability for PostgreSQL to monitor query performance, explain plans, wait events, and query samples.

15 min
Intermediate
Docs & blog posts

Open in Grafana Cloud

Complete this learning path directly in your Grafana Cloud stack with an interactive learning experience.

Path completed