Database Observability
Grafana LabsOfficialPublished by Grafana Labs
- Skill
- Workflow
- Cloud and DevOps
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a comprehensive guide to setting up Grafana Cloud Database Observability for MySQL and PostgreSQL databases. It covers the necessary database-level configurations, such as enabling pg_stat_statements or Performance Schema, creating least-privilege monitoring users, and configuring Alloy components to ship metrics, logs, and query samples. By integrating these components, users can monitor database performance, analyze slow queries with visual explain plans, and correlate database activity with application traces using OpenTelemetry attributes.
What it does
- Enables database-level performance tracking via pg_stat_statements or Performance Schema.
- Configures Alloy components to collect and forward query samples, metrics, and schema details.
- Provides automated dashboards for query performance, including RED metrics and latency analysis.
- Enables trace correlation between application spans and database queries using OTel attributes.
- Includes pre-defined alert rules for query latency, error rates, and connection pool saturation.
When to use it
- When you need to diagnose slow database queries in MySQL or PostgreSQL environments.
- When setting up monitoring for RDS, Aurora, Cloud SQL, Azure Database, or self-managed instances.
- When you want to correlate database performance metrics with application-level traces.
- When you need to implement alerting for database connection saturation or high query error rates.
Advantages
- Provides deep visibility into query performance without requiring application code changes.
- Supports a wide range of managed and self-managed database environments.
- Facilitates rapid troubleshooting by linking application traces directly to slow SQL queries.
- Includes ready-to-use configurations for metrics, logs, and alerting.
Usage examples
- “How do I set up database observability for my PostgreSQL instance?”
- The agent provides the steps to enable pg_stat_statements, create a monitoring user, and configure the Alloy component for PostgreSQL.
- “My database is slow, how can I find the problematic queries?”
- The agent guides you through configuring query samples and explain plans, which populate the Query Performance dashboard to identify high-latency queries.
- “How do I link my application traces to database queries?”
- The agent explains how to ensure your application emits OTel attributes like db.statement and db.system to enable drill-down from traces to database query samples.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/grafana/database-observability/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip database-observability.zip -d .agents/skills
Documentation by Grafana Labs
Grafana Cloud Database Observability
Docs: https://grafana.com/docs/grafana-cloud/monitor-applications/database-observability/
Query-level insights (RED metrics, query samples, explain plans) for MySQL and PostgreSQL without application code changes. GA since April 2026.
Common Workflows
PostgreSQL setup
-- 1. Enable pg_stat_statements (requires restart)
-- In postgresql.conf: shared_preload_libraries = 'pg_stat_statements'
-- Then restart PostgreSQL.
-- 2. Create a least-privilege monitoring user
CREATE USER grafana_monitoring WITH PASSWORD 'secret';
GRANT pg_monitor TO grafana_monitoring;
GRANT CONNECT ON DATABASE mydb TO grafana_monitoring;
-- 3. Enable the extension on each monitored DB
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
-- 4. Verify
SELECT count(*) FROM pg_stat_statements;
-- Should return >= 0 (not an error). If "relation does not exist": step 3 didn't run.Add the Alloy config block from references/alloy-config.md § PostgreSQL
Restart Alloy and wait ~60s for first scrape
Verify in Grafana Cloud → Database Observability — the instance should appear with non-empty
db_query_total{db_instance="mydb"}series. If empty after 2 minutes: check Alloy logs for connection errors, then re-verify pg_stat_statements permissions.
MySQL setup
-- 1. Create least-privilege monitoring user
CREATE USER 'grafana_monitoring'@'%' IDENTIFIED BY 'secret';
GRANT SELECT, PROCESS, REPLICATION CLIENT ON *.* TO 'grafana_monitoring'@'%';
GRANT SELECT ON performance_schema.* TO 'grafana_monitoring'@'%';
FLUSH PRIVILEGES;
-- 2. Verify performance_schema is enabled (default in MySQL 8+)
SELECT @@performance_schema;
-- Returns 1 → enabled. 0 → set performance_schema=ON in my.cnf + restart.Add the Alloy config block from references/alloy-config.md § MySQL
Restart Alloy, wait ~60s, verify the instance appears in Grafana Cloud → Database Observability
Supported databases
| Database | Variants |
|---|---|
| MySQL | Self-managed, RDS MySQL, Aurora MySQL, Cloud SQL MySQL, Azure Database for MySQL |
| PostgreSQL | Self-managed, RDS PostgreSQL, Aurora PostgreSQL, Cloud SQL PostgreSQL, Azure Database for PostgreSQL |
For managed databases (RDS / Cloud SQL / Azure), pg_stat_statements is preinstalled but disabled — enable it via the parameter group / flag, then re-create the extension at the DB level.
What you get
Query Performance dashboard (auto-provisioned): top queries by total time / call count / mean latency, sampled query texts with parameters, visual explain plans, RED metrics per query digest
APM correlation: drill from a slow service-latency span to the specific slow SQL via
db.statement/db.system/db.nameOTel attributes — see references/queries-alerts.md § Trace correlationAlerting on query latency, error rate, and connection-pool saturation — full alert YAML in references/queries-alerts.md § Alert rules
References
references/alloy-config.md— full Alloydatabase_observability.postgres/database_observability.mysqlconfig blocks + collector reference (pg_stat_statements,query_samples,schema_details,explain_plans)references/queries-alerts.md— key PromQL queries, alert rule YAML, and trace-correlation setup
Files
- ATTRIBUTION.mdAdded by AutoGineer865 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md4.4 KiB
- references/alloy-config.md1.6 KiB
- references/queries-alerts.md1.8 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Grafana Labs
- Publisher
- Grafana Labs (Official)
- Source
- grafana/skills · skills/grafana-cloud/database-observability · commit 8fb72a5
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Grafana Labs.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download database-observability.zip