Slide 2 of 6

How Database Observability works

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.

Script

Here’s how all of this works under the hood. Grafana Alloy runs alongside your database and collects two types of telemetry.

First, it collects metrics: query counts, latency, errors, and resource usage. These go to Grafana Cloud Metrics, the metrics backend. Second, it collects detailed logs: query samples, explain plans, schema details, and wait events. These go to Grafana Cloud Logs, the logs backend.

The important thing is that this data comes from built-in database statistics, not from intercepting your queries. PostgreSQL uses pg_stat_statements and pg_stat_activity. MySQL uses Performance Schema, which is enabled by default in MySQL 8.0 and later.

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.