1. Beyond server metrics #
What Database Observability sees.
The principle #
A Prometheus exporter says the database is slow; Database Observability says which query, with which execution plan and which locks. The database_observability.mysql and database_observability.postgres components collect these details and send them to Loki; the Grafana Cloud Database Observability app presents them.
MySQL collectors #
| Collector | Default | Role |
|---|---|---|
| query_details | yes, 1 min | Normalized queries (250 max) |
| query_samples | yes, 10 s | Samples of real executions |
| schema_details | yes, 1 min | Tables and columns |
| explain_plans | yes, 1 min | Execution plans (EXPLAIN) |
| locks | no, 30 s | Lock waits over 1 s |
| table_stats, index_stats | no | Table and index statistics |
2. The configuration #
MySQL to Loki and Mimir.
config.alloy #
local.file "mysql_dsn" {
filename = "/etc/alloy/secrets/mysql-dsn"
is_secret = true
}
prometheus.exporter.mysql "orders" {
data_source_name = local.file.mysql_dsn.content
}
database_observability.mysql "orders" {
data_source_name = local.file.mysql_dsn.content
forward_to = [loki.write.default.receiver]
targets = prometheus.exporter.mysql.orders.targets
enable_collectors = ["locks", "table_stats"]
}
prometheus.scrape "orders" {
targets = database_observability.mysql.orders.targets
forward_to = [prometheus.remote_write.mimir.receiver]
}
loki.write "default" {
endpoint {
url = "http://loki:3100/loki/api/v1/push"
}
}
prometheus.remote_write "mimir" {
endpoint {
url = "http://mimir:9009/api/v1/push"
}
}Configuration validated with alloy validate (Alloy v1.21.3, November 2026).
- The DSN is a secret: read by
local.filewithis_secret = true, it does not appear in the Alloy UI or logs. targets: reuses those ofprometheus.exporter.mysqlto link details and metrics of the same instance.allow_update_performance_schema_settings(false by default): needed forquery_samplesandsetup_actorsto adjust performance_schema themselves.
Database side #
Create a dedicated read-only user with access to performance_schema (MySQL) or pg_stat_statements and pg_monitor (PostgreSQL). Exact grants depend on the version: follow Grafana's setup guide for your engine.
Not run here: without a MySQL server in our environment, the configuration was validated, not run.
