database-observability

Grafana Cloud database observability: query-level performance insights for MySQL and PostgreSQL, covering configuration via Grafana Alloy, example queries, visualized execution plans, RED metrics, pg_stat_statements and Performance Schema integration, and linking database metrics with application traces. Intended for monitoring database performance, diagnosing slow queries, and setting up observability for self-hosted or cloud (RDS, Aurora, Azure, Cloud SQL) MySQL/PostgreSQL.

Last repository push
GitHub Stars
212
Forks
664
Issues / PRs
21

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "database-observability" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-61035a1090c2704011accb93a89a068d0767e137ba25c35de0b5fcb0c6a1861d. Verify the upstream source and version against https://github.com/Kilo-Org/kilo-marketplace before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Grafana Cloud database observability: query-level performance insights for MySQL and PostgreSQL, covering configuration via Grafana Alloy, example queries, visualized execution plans, RED metrics, pg_stat_statements and Performance Schema integration, and linking database metrics with application traces. Intended for monitoring database performance, diagnosing slow queries, and setting up observability for self-hosted or cloud (RDS, Aurora, Azure, Cloud SQL) MySQL/PostgreSQL.

0 Downloads

Introduction source: third_party · Kilo-Org · 0.0.1 Reference

SkillPi interpretation

Tasks
Docs**: https://grafana.com/docs/grafana-cloud/monitor-applications/database-observability/
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: database-observability
description: >
  Grafana Cloud Database Observability — query-level performance insights for
  MySQL and PostgreSQL. Covers setup with Grafana Alloy, query samples, visual
  explain plans, RED metrics, pg_stat_statements and Performance Schema
  integration, and correlation with application traces. Use when monitoring
  database performance, diagnosing slow queries, setting up database
  observability for MySQL or PostgreSQL (self-managed, RDS, Aurora, Azure, Cloud
  SQL), or correlating DB metrics with APM data.
metadata:
  category: observability
  source:
    repository: 'https://github.com/grafana/skills'
    path: skills/grafana-cloud/database-observability
    license_path: LICENSE
    commit: e8424d242290be2ae187a74b5fd854174f0c5411

Grafana Cloud Database Observability

Docs: https://grafana.com/docs/grafana-cloud/monitor-applications/database-observability/

Provides query-level insights (RED metrics, query samples, explain plans) for MySQL and PostgreSQL without application code changes. Generally Available as of April 2026.

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

Prerequisites

PostgreSQL

-- 1. Enable pg_stat_statements in postgresql.conf
-- shared_preload_libraries = 'pg_stat_statements'
-- Then restart PostgreSQL

-- 2. Create 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
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

MySQL

-- Create monitoring user with least-privilege permissions
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;

Alloy Configuration

PostgreSQL

database_observability.postgres "mydb" {
  data_source_name = "postgresql://grafana_monitoring:secret@localhost:5432/mydb?sslmode=disable"

  enable_collectors = ["pg_stat_statements", "query_samples", "schema_details"]

  forward_metrics_to = [prometheus.remote_write.cloud.receiver]
  forward_logs_to    = [loki.write.cloud.receiver]
}

prometheus.remote_write "cloud" {
  endpoint {
    url = sys.env("PROMETHEUS_URL")
    basic_auth {
      username = sys.env("PROMETHEUS_USER")
      password = sys.env("GRAFANA_CLOUD_API_KEY")
    }
  }
}

loki.write "cloud" {
  endpoint {
    url = sys.env("LOKI_URL")
    basic_auth {
      username = sys.env("LOKI_USER")
      password = sys.env("GRAFANA_CLOUD_API_KEY")
    }
  }
}

MySQL

database_observability.mysql "mydb" {
  data_source_name = "grafana_monitoring:secret@tcp(localhost:3306)/mydb"

  enable_collectors = ["query_samples", "explain_plans", "schema_details"]

  forward_metrics_to = [prometheus.remote_write.cloud.receiver]
  forward_logs_to    = [loki.write.cloud.receiver]
}

Key Metrics

# Query rate by database
rate(db_query_total{db_instance="mydb"}[5m])

# P95 query latency
histogram_quantile(0.95, rate(db_query_duration_seconds_bucket[5m]))

# Error rate
rate(db_query_errors_total[5m]) / rate(db_query_total[5m])

# Slow queries (over 1 second)
count(db_query_duration_seconds > 1) by (db_query_digest)

# Active connections
db_connections_active{db_instance="mydb"}

What You Get

Query Performance Dashboard (auto-provisioned):

  • Top queries by total time, call count, mean latency
  • Query samples with actual parameters and timing
  • Visual explain plans showing index usage, scan types, costs
  • RED metrics per query digest

Correlation with APM:

  • Link slow DB queries to the application traces that triggered them
  • db.statement, db.system, db.name OTel attributes connect DB spans to query samples
  • Drill from service latency spike → specific slow SQL query → explain plan

Alert Rules

groups:
  - name: database-observability
    rules:
      - alert: SlowQueryDetected
        expr: histogram_quantile(0.95, rate(db_query_duration_seconds_bucket[5m])) > 1
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "P95 query latency > 1s on {{ $labels.db_instance }}"

      - alert: HighDBErrorRate
        expr: rate(db_query_errors_total[5m]) / rate(db_query_total[5m]) > 0.05
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "DB error rate > 5% on {{ $labels.db_instance }}"

      - alert: TooManyConnections
        expr: db_connections_active / db_connections_max > 0.8
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "DB connection pool >80% on {{ $labels.db_instance }}"

Setup Checklist

  1. Enable pg_stat_statements (PostgreSQL) or Performance Schema (MySQL)
  2. Create least-privilege monitoring user
  3. Add database_observability.* block to Alloy config
  4. Verify metrics appear in Grafana Cloud → Database Observability
  5. Set up alerting on slow queries and error rates
  6. Enable trace correlation by ensuring app uses db.statement span attributes

Version history

  1. skills-20261103210927-6c1b454 GitHub ↗
    Original release notes

    Automated skills release from commit 6c1b4543cac1d45a80bf5904e4b69ac315117323

  2. skills-20260928190452-ff51758 GitHub ↗
    Original release notes

    Automated skills release from commit ff51758b06b8249007116184096765d47bdb7505

  3. skills-20260924105536-d31110d GitHub ↗
    Original release notes

    Automated skills release from commit d31110d62dc0bd00c22f1d6f6a630d1e702a0049

  4. skills-20260923085113-cea285e GitHub ↗
    Original release notes

    Automated skills release from commit cea285ef0e4d6ec47cd2fd9fdbca03813a3363c7

  5. skills-20260922193956-97d7333 GitHub ↗
    Original release notes

    Automated skills release from commit 97d7333d8200e5ac556c659c8669f3a83ba10866

Only the five most recent versions are shown. View full version history at the source ↗

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供完整的数据库可观测性解决方案,涵盖配置、监控、诊断、告警全流程
  • 支持主流数据库变体(自建/RDS/Aurora/Azure/Cloud SQL),适用性广
  • 面向专业用户解决数据库性能监控这一明确刚需
Trigger Precision90/100

Highlights

  • 触发描述完整覆盖多种使用场景和数据库类型
  • 边界清晰,不易与其他监控类 Skill 重叠
  • 明确指定适用场景和技术栈
Structure and Standards95/100

Highlights

  • 结构完整,包含从前置条件到告警规则的完整闭环
  • 提供端到端配置示例,便于用户直接执行
  • frontmatter 完整,文档长度适中
Execution Reliability90/100

Highlights

  • 工具来源明确,参数配置规范
  • 提供最小权限配置和异常处理机制
  • 环境变量使用合理,便于生产部署
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • github.com
  • grafana.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.