G

Grafana MCP Server

Search dashboards, query datasources, and analyze metrics from Grafana directly in Claude Code. Essential for SREs and developers who need to investigate production metrics, build dashboard queries, and correlate monitoring data during incident response.

MCPCommunitymonitoringv1.0.0AGPL-3.0
0 views0 copies

MCP Server Configuration

{ "mcpServers": { "grafana": { "command": "npx", "args": ["-y", "@grafana/mcp-server-grafana"], "env": { "GRAFANA_URL": "http://localhost:3000", "GRAFANA_API_KEY": "<your-service-account-token>" } } } }

Available Tools

ToolDescription
search_dashboardsSearch for dashboards by name or tag
get_dashboardGet full dashboard JSON including panels
list_datasourcesList all configured datasources
query_datasourceExecute queries against Prometheus, Loki, etc.
list_alertsList active and pending alerts
get_alert_rulesGet alert rule definitions
query_lokiQuery Loki logs with LogQL
query_prometheusQuery Prometheus metrics with PromQL

Setup

  1. In Grafana, go to Administration > Service Accounts
  2. Create a new service account with Viewer role (or Editor for write access)
  3. Generate a token for the service account
  4. Replace the URL and token in the configuration

Usage Examples

  • "Show me dashboards related to the payments service"
  • "Query CPU usage for the api-server pod over the last 6 hours"
  • "List all firing alerts and their severity"
  • "Search Loki logs for 500 errors in the auth service"
  • "Get the PromQL query from the latency panel on the SLA dashboard"

Query Examples

# Request rate by status code sum(rate(http_requests_total{service="api"}[5m])) by (status_code) # P99 latency histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m])) # Error rate percentage sum(rate(http_requests_total{status_code=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) * 100

Security Notes

  • Use Viewer role service accounts for read-only access
  • Metrics may contain sensitive operational data
  • Store tokens in .claude/settings.local.json (gitignored)
  • For Grafana Cloud, use your cloud instance URL
Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates