- Documentation
- Learning Hub
- Section 2 of 3 Set up Database Observability
How Database Observability works
How the data flows
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_statementsfor aggregate query statistics andpg_stat_activityfor active sessions. Thepg_stat_statementsextension 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.