391043 Stack
📖 Tutorial

Accelerate Database Diagnostics with Grafana Assistant: A Step-by-Step Guide

Last updated: 2026-05-12 03:38:40 Intermediate
Complete guide
Follow along with this comprehensive guide

Accelerate Database Diagnostics with Grafana Assistant: A Step-by-Step Guide

When your database slows down, pinpointing the root cause can be like finding a needle in a haystack. You see latency spikes and error rates climbing, but translating raw metrics into actionable fixes often requires deep expertise. Grafana Cloud's Database Observability now includes a new Grafana Assistant integration that harnesses AI to cut through the noise. This guide walks you through using the assistant to diagnose and resolve performance issues faster — without manually assembling context or copying SQL into separate tools.

What You Need

  • A Grafana Cloud account with Database Observability enabled.
  • Access to a database (e.g., MySQL, PostgreSQL) that is experiencing slow queries or degraded performance.
  • Basic familiarity with Grafana's query analysis interface (RED metrics, execution samples, wait events).
  • No need to install any extra agents; the assistant works with your existing Prometheus and Loki data sources.

How to Troubleshoot a Slow Query

Follow these six steps to leverage the Grafana Assistant from identification to resolution.

Accelerate Database Diagnostics with Grafana Assistant: A Step-by-Step Guide

Step 1: Identify the Problematic Query

Open your Database Observability dashboard and navigate to the Overview tab. Look for queries where the P99 latency is spiking or the error rate is climbing. Click on any worrisome query to drill into its detailed view. Here you'll see time-series performance data, including RED metrics (Rate, Errors, Duration) and execution samples. This is your starting point — the assistant will use this exact time window and context.

Step 2: Open the Grafana Assistant

Within the query detail view, locate the Assistant button (usually a chat or lightbulb icon). Click it to open the assistant panel. The panel appears on the right side of the screen, already aware of the query you're investigating. You don't need to describe the problem — the assistant automatically pulls in the current time range, schema, indexes, and execution plans from your actual databases. It does not store or share your query text or metadata for model training; privacy is maintained.

Step 3: Select a Pre-Built Analysis Prompt

Instead of typing a generic question, use one of the purpose-built AI buttons provided by the assistant. These buttons are designed by database engineers to tackle common issues. For example, click "Why is this query slow?" or "Get recommendations for changes". Each prompt triggers a focused analysis using both your Prometheus and Loki data sources. The assistant synthesizes the data into a health assessment specific to your query and environment.

Step 4: Review the Health Assessment

After you select a prompt, the assistant processes the data and presents a clear analysis. For instance, it might report: "Duration is spiking because the number of rows examined is 50 times the number returned — most work is wasted on filtering. The P99 is 12x the median, indicating an intermittent problem. CPU time is healthy, but wait events consume 40% of execution time." This assessment converts raw metrics into a narrative you can act on.

Step 5: Interpret Wait Events and Metrics

The analysis often highlights wait events with cryptic names like wait/synch/mutex/innodb or io/table/sql/handler. The assistant translates these into plain language. For example, it might explain: "During this wait, the database is physically waiting for I/O to complete from the storage layer. Consider optimizing your query to reduce full table scans or adding an index." This interpretation saves you from researching obscure internal behaviors.

Step 6: Apply Recommendations

Based on the assistant's diagnosis, you can implement the suggested fixes. Recommendations may include rewriting joins, creating missing indexes, or adjusting database configuration parameters. The assistant provides specific, data-driven advice — not generic tips. Return to the query analysis after making changes to verify improvement using the same metrics and assistant feedback loop.

Tips for Effective Troubleshooting

  • Stick with pre-built prompts first. They are engineered to ask the most useful questions and reduce noise.
  • Don't manually copy context. The assistant already has full access; let it do the heavy lifting.
  • Use multiple prompts if the first analysis isn't enough. Try "Why is this query slow?" then follow with "Any index suggestions?"
  • Compare before and after. After implementing a change, re-run the same prompt to see if the assistant confirms improvement.
  • Remember privacy. Your query text and schema metadata are used only for the current analysis and are not stored or used for model training.
  • Keep an eye on wait events. Even if metrics look okay, a small percentage of wait time can indicate a hidden bottleneck.

With the Grafana Assistant, you no longer have to interpret raw wait events or guess at optimizations. The integration brings AI-powered diagnostics directly into your workflow, turning data into decisions. Start troubleshooting your next slow query with confidence.