# Grafana MCP

> Grafana MCP Server gives your AI agent full control over your observability stack. Use it to search dashboards by tag or title, inspect precise PromQL, LogQL, or SQL queries, list all connected data sources (Prometheus, Loki, CloudWatch, SQL), and monitor live alert states—all from a single chat interface.

## Overview
- **Category:** loved-by-devs
- **Price:** Free
- **Tags:** dashboards, metrics, logs, traces, alerting, data-visualization

## Description

Your AI agent gets full control over your whole observability stack. You'll use this server to search dashboards by tag or title, check specific PromQL, LogQL, or SQL queries, list every connected data source—whether it's Prometheus, Loki, or SQL—and monitor live alert statuses. You do all that from a single chat window.

**Search and locate dashboards**

You can use `search_dashboards` to find dashboards by title or tag. It spits out the basic info and the unique UID you need to look at it later.

**Extract full dashboard queries**

Need to know what a dashboard's doing? You use `get_dashboard` with a dashboard UID to pull the entire config. This gives you the exact PromQL, LogQL, or SQL queries and every panel detail.

**Audit connected data sources**

Want to know what data you're actually monitoring? `list_datasources` lists every data source configured in your Grafana instance, confirming all the connections like Prometheus, Loki, or SQL.

**Check active alert rules**

Use `firing_alerts` to get a list of all alerting rules that are currently reporting a 'firing' status, including their labels and annotations. This lets you see what's actively breaking right now.

**Analyze monitoring variables**

You can analyze specific localized variables to decode active monitoring routes and understand the structural constraints within your Grafana environment.

## Tools

### firing_alerts
Retrieves a list of alerting rules that are currently reporting a 'firing' status, including their labels and annotations.

### get_dashboard
Fetches the full configuration of a dashboard, requiring a dashboard UID to return all panels and their associated queries.

### list_datasources
Lists every data source configured within the Grafana instance, confirming all available connections.

### search_dashboards
Searches Grafana dashboards by title or tag, returning basic info and the necessary UID for further inspection.

## Prompt Examples

**Prompt:** 
```
Search for dashboards tagged with 'production'
```

**Response:** 
```
Searching dashboards... I found 3 matching dashboards: 'K8s Cluster Overview' (UID: abc-123), 'HTTP Response Metrics' (UID: def-456), and 'Database Performance'. Which one would you like me to inspect for panels?
```

**Prompt:** 
```
Show me the queries for dashboard 'abc-123'
```

**Response:** 
```
Retrieving dashboard 'abc-123'... I found 5 panels. Highlights: 'CPU Usage' uses PromQL `sum(rate(node_cpu_seconds_total...))`, and 'Request Latency' uses `histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket...)))`. Would you like the full JSON or more queries?
```

**Prompt:** 
```
Are there any firing alerts right now?
```

**Response:** 
```
Checking alert rules... Yes, I found 1 firing alert: 'High Error Rate' on service 'API-v1'. It has been firing for 15 minutes. All other 12 alert rules are currently in 'Normal' state.
```

## Capabilities

### Search and locate dashboards
Find dashboards by title or tag to retrieve their unique identifiers (UIDs) and basic metadata in the chat.

### Extract full dashboard queries
Get the complete configuration of a dashboard, pulling out the exact PromQL, LogQL, or SQL queries and panel details.

### Audit connected data sources
List all data sources configured in the Grafana instance, verifying connectivity boundaries like Prometheus, Loki, or SQL.

### Check active alert rules
List all active alert rules and check which ones are currently in a 'firing' state for immediate incident status.

### Analyze monitoring variables
Analyze specific localized variables to decode active monitoring routes and understand structural constraints within the Grafana environment.

## Use Cases

### Troubleshooting a sudden spike in database errors
The ops engineer notices a spike and asks their agent to check the status. The agent first runs `search_dashboards` for 'Database Performance', gets the UID, then uses `get_dashboard` to pull the specific SQL query. Finally, it calls `firing_alerts` to see if the high error rate triggered an active alert, giving a full picture of the incident.

### Verifying a new data connection for a project
A cloud architect needs to confirm if a new type of database is connected. They ask the agent to run `list_datasources`. The agent returns the full list, allowing the architect to confirm the presence and status of the new connector without touching the Grafana UI.

### Investigating a suspected performance regression
A developer suspects a query change broke a dashboard. They ask the agent to run `get_dashboard` on the relevant UID. The agent pulls all panel configurations, allowing the developer to compare the exact PromQL query now running against a known-good baseline.

### Reviewing system readiness before deployment
The incident responder needs a quick status check. They ask the agent to run `firing_alerts`. The agent immediately returns a list of active alerts, allowing the team to prioritize system health checks before the deployment window closes.

## Benefits

- Check alert status instantly. Use `firing_alerts` to see which rules are actively firing. This eliminates the need to navigate to the alert list and manually filter for active incidents.
- Extract complex queries fast. Run `get_dashboard` to pull the precise PromQL, LogQL, or SQL query behind any panel. This saves time when validating metrics or debugging data definitions.
- Audit connectivity at scale. `list_datasources` provides a complete list of all configured data sources (Prometheus, Loki, SQL, etc.), giving immediate visibility into your system's data boundaries.
- Find dashboards without clicking. Use `search_dashboards` to locate the right dashboard by title or tag, getting the UID needed for subsequent deep inspections.
- Speed up incident response. You can combine `search_dashboards` and `firing_alerts` in one conversation—find the dashboard, then check its related alerts—without leaving the chat.
- Maintain a single source of truth. By querying the data directly, your agent acts as a unified interface, preventing reliance on multiple manual dashboards or UI sections.

## How It Works

The bottom line is that you treat your entire observability platform like a database, querying it using plain language.

1. Subscribe to the Grafana MCP Server and provide your Grafana Instance URL and Service Account Token.
2. Use your AI client to ask a question, like 'List all data sources' or 'Show me the queries for the K8s dashboard'.
3. The server executes the required tool, returning the data (e.g., a list of data source names or a specific PromQL query) directly into the chat.

## Frequently Asked Questions

**How do I use the `search_dashboards` tool with Grafana MCP Server?**
Just tell the agent what you're looking for—by tag or title. The agent returns a list of matching dashboards and their UIDs, which you then use to proceed with other inspections.

**Can I use `get_dashboard` to find the query for a panel?**
Yes, you must first get the dashboard UID using `search_dashboards`. Then, pass that UID to `get_dashboard` and specify the panel name. The tool returns the full query details.

**What does the `list_datasources` tool do?**
It provides a list of every configured data source in your Grafana instance. This is useful for auditing to ensure all expected connections (like Prometheus or SQL) are present and configured.

**How does `firing_alerts` work?**
The `firing_alerts` tool checks the Grafana Unified Alerting system and reports only the rules that are currently in an active, 'firing' state. It ignores all rules in 'Normal' status.

**Can I use the Grafana MCP Server to find alerts and dashboards?**
Yes. You can first use `search_dashboards` to find the dashboard UID, and then use that context to check related alerts using `firing_alerts`.

**How do I use the `list_datasources` tool to check which data types are supported?**
It lists every configured data source in your Grafana instance. This includes types like Prometheus, Loki, CloudWatch, and standard SQL databases, showing exactly what data you can query.

**Does `search_dashboards` help me find dashboards by tags or titles?**
Yes, it searches dashboards using both title and tag parameters. This lets you narrow down results quickly, for example, finding all dashboards related to 'production'.

**What happens if I need the full configuration of a dashboard using `get_dashboard`?**
The `get_dashboard` tool retrieves the complete JSON configuration for a given UID. This includes the layout, all panels, and the precise underlying queries (PromQL, LogQL, or SQL) used.

**Can my agent search for specific dashboards in my Grafana instance?**
Yes. Use the 'search_dashboards' tool. You can provide an optional query string to match titles or tags. The agent will return basic info including the unique UID required for deeper inspection.

**How do I extract the PromQL or SQL queries from a dashboard panel via chat?**
Use the 'get_dashboard' tool with the dashboard UID. Your agent will retrieve the full JSON configuration, including all panels and their underlying data queries, enabling you to review the exact metrics logic natively.

**Can I see firing alerts through the agent?**
Absolutely. Use the 'list_alerts' tool. The agent retrieves all configured alert rules and their current statuses, allowing you to identify which monitors are currently in a firing state synchronousy.