agentleFS
sirdavidhuangsirdavidhuang/claude-code-skills/skills/grafana-skill/SKILL.md

grafana-skill

Skill0 starsChanged 9 months agoMITView on GitHub

Comprehensive skill for interacting with Grafana's HTTP API to manage dashboards, data sources, folders, alerting, annotations, users, teams, and organizations. Use when Claude needs to (1) Create, read, update, or delete Grafana dashboards, (2) Manage data sources and connections, (3) Configure alerting rules, contact points, and notification policies, (4) Work with folders and permissions, (5) Manage users, teams, and service accounts, (6) Create or query annotations, (7) Execute queries against data sources, or any other Grafana automation task via API.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    [Annotations](References/Annotations.md): Create, query, update annotations

    line 111
  2. Very specific:

    Use overwrite: true carefully: Only when you want to force-update

    line 177

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

grafana-skill

Programmatically manage Grafana resources using TypeScript tools and HTTP API workflows.

Workflow Routing

WorkflowTriggerFile
DashboardCrud"create dashboard", "update dashboard", "delete dashboard", "list dashboards", "export dashboard"Tools/DashboardCrud.ts
GrafanaClient"grafana API", "grafana client", "TypeScript grafana"Tools/GrafanaClient.ts
ApiReference"grafana API reference", "grafana endpoints"References/

Tools

DashboardCrud CLI

# Set environment variables
export GRAFANA_URL="https://grafana.example.com"
export GRAFANA_TOKEN="your-service-account-token"

# List dashboards
bun run Tools/DashboardCrud.ts list
bun run Tools/DashboardCrud.ts list --query production --tag monitoring

# Get dashboard by UID
bun run Tools/DashboardCrud.ts get abc123

# Export dashboard to JSON
bun run Tools/DashboardCrud.ts export abc123 --output dashboard.json

# Create dashboard from JSON file
bun run Tools/DashboardCrud.ts create --file dashboard.json --folder my-folder

# Update dashboard
bun run Tools/DashboardCrud.ts update abc123 --file updated.json --message "Updated panels"

# Clone dashboard
bun run Tools/DashboardCrud.ts clone abc123 --title "Production Copy" --folder prod-folder

# View version history
bun run Tools/DashboardCrud.ts versions abc123

# Restore to previous version
bun run Tools/DashboardCrud.ts restore abc123 --version 5

# Delete dashboard
bun run Tools/DashboardCrud.ts delete abc123

GrafanaClient TypeScript Library

import { GrafanaClient, createGrafanaClient } from './Tools/GrafanaClient';

// Initialize from environment variables
const client = createGrafanaClient();

// Or with explicit config
const client = new GrafanaClient({
  baseUrl: 'https://grafana.example.com',
  token: 'your-service-account-token',
  orgId: 1, // optional
});

// Dashboard operations
const dashboards = await client.searchDashboards({ query: 'production', tag: 'monitoring' });
const dashboard = await client.getDashboardByUid('abc123');
const saved = await client.saveDashboard({ dashboard: myDashboard, folderUid: 'folder-uid' });
await client.deleteDashboard('abc123');

// Version management
const versions = await client.getDashboardVersions('abc123');
await client.restoreDashboardVersion('abc123', 5);

// Folders, Data sources, Alerting, Annotations also available

Authentication

# Service Account Token (Recommended)
export GRAFANA_TOKEN="glsa_xxxxxxxxxxxxxxxxxxxx"

# Multi-Organization Header
curl -H "Authorization: Bearer $GRAFANA_TOKEN" \
     -H "X-Grafana-Org-Id: 2" \
     https://grafana.example.com/api/org

Quick API Reference

ResourceListGetCreateUpdateDelete
DashboardsGET /api/searchGET /api/dashboards/uid/:uidPOST /api/dashboards/dbPOST /api/dashboards/dbDELETE /api/dashboards/uid/:uid
FoldersGET /api/foldersGET /api/folders/:uidPOST /api/foldersPUT /api/folders/:uidDELETE /api/folders/:uid
Data SourcesGET /api/datasourcesGET /api/datasources/uid/:uidPOST /api/datasourcesPUT /api/datasources/uid/:uidDELETE /api/datasources/uid/:uid
Alert RulesGET /api/v1/provisioning/alert-rulesGET /api/v1/provisioning/alert-rules/:uidPOST /api/v1/provisioning/alert-rulesPUT /api/v1/provisioning/alert-rules/:uidDELETE /api/v1/provisioning/alert-rules/:uid

Reference Documentation

  • Dashboards: Complete dashboard CRUD, versions, permissions
  • DataSources: Data source management, queries, health checks
  • Alerting: Alert rules, contact points, notification policies
  • Folders: Folder management and permissions
  • Annotations: Create, query, update annotations
  • UsersTeams: User management, team operations
  • CommonPatterns: Error handling, pagination, utilities

Examples

Example 1: List and export dashboards

User: "List all production dashboards and export them"
→ bun run Tools/DashboardCrud.ts list --tag production
→ For each: bun run Tools/DashboardCrud.ts export <uid>
→ Returns list of exported JSON files

Example 2: Create dashboard from JSON

User: "Create a new dashboard from this JSON file"
→ bun run Tools/DashboardCrud.ts create --file dashboard.json --folder monitoring
→ Returns new dashboard UID and URL

Example 3: Clone dashboard to another folder

User: "Clone the CPU dashboard to the production folder"
→ bun run Tools/DashboardCrud.ts clone cpu-uid --title "CPU Prod" --folder prod-folder
→ Returns cloned dashboard details

Example 4: Restore dashboard version

User: "Restore dashboard abc123 to version 5"
→ bun run Tools/DashboardCrud.ts versions abc123
→ bun run Tools/DashboardCrud.ts restore abc123 --version 5
→ Dashboard restored, new version created

Example 5: Programmatic bulk update

User: "Write TypeScript to bulk update dashboard tags"
→ Uses GrafanaClient library:
   const client = createGrafanaClient();
   const dashboards = await client.searchDashboards({ tag: 'old-tag' });
   for (const dash of dashboards) {
     const full = await client.getDashboardByUid(dash.uid);
     full.dashboard.tags = full.dashboard.tags.filter(t => t !== 'old-tag');
     full.dashboard.tags.push('new-tag');
     await client.saveDashboard({ dashboard: full.dashboard, message: 'Updated tags' });
   }

Error Handling

CodeDescription
200Success
400Bad request (invalid JSON, missing required fields)
401Unauthorized (invalid/missing token)
403Forbidden (insufficient permissions)
404Not found
409Conflict (resource already exists)
412Precondition failed (version mismatch)

Tips

  1. Use UIDs over IDs: UIDs are portable across Grafana instances
  2. Include version for updates: Prevents overwriting concurrent changes
  3. Use overwrite: true carefully: Only when you want to force-update
  4. Service accounts over API keys: API keys are deprecated in newer Grafana versions

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.