Section 2 · Set up Database Observability

Architecture and data flow for Database Observability

Estimated time: 1 min

How the data flows

Database Observability architecture

Grafana Alloy runs alongside your database and reads its built-in statistics, so it never intercepts or rewrites your queries. Where those statistics come from depends on the database:

  • PostgreSQL: pg_stat_statements for aggregate query statistics and pg_stat_activity for active sessions. The pg_stat_statements extension must be installed and enabled.
  • MySQL: Performance Schema, which is enabled by default in MySQL 8.0 and later

Alloy splits that data into two streams and forwards each to a different Grafana Cloud backend:

  • Metrics (query counts, latency, errors, and resource usage) are scraped by database exporters and sent to Grafana Cloud Metrics.
  • Logs (query samples, explain plans, schema details, and wait events) are collected by the Database Observability components and sent to Grafana Cloud Logs.

Grafana Cloud provides Database Observability dashboards that bring the metrics and logs together into a single view of query performance, starting with the Queries Overview dashboard.

Collecting this data is safe to run in production. To capture an explain plan, Database Observability asks the database how it would run a query rather than actually running it, so it adds minimal overhead.