dashboarding — скилл для Claude Code: Grafana-дашборды через API
Скилл собирает и правит JSON дашбордов Grafana и отправляет их в HTTP API. Пригодится, когда панели нужно описать кодом, а не мышкой в UI.
npx skills add grafana/skills --skill dashboarding -a claude-codeЧто делает dashboarding
Скилл учит агента писать JSON дашборда Grafana: типы панелей (timeseries, stat, gauge, table, heatmap, logs, traces, node-graph), раскладка по 24-колоночной сетке gridPos, единицы измерения, пороги. Отдельно разобраны переменные — шаблонные, по датасорсу и связанные цепочкой, — а также трансформации organize, calculateField и filterByValue. Ссылки на панели и дашборды строятся через ${__field.labels.x} и ${__from}, аннотации — из Loki и Prometheus.
Работает это через HTTP API: агент собирает payload, проверяет его jq, отправляет POST /api/dashboards/db с overwrite: true и читает ответ. После каждой отправки скилл требует сверить вернувшийся version и сделать GET по uid дашборда — так видно, что панель действительно записалась, а не потерялась по дороге.
Что нужно заранее: доступный с машины стек Grafana (OSS, Enterprise или Cloud), токен с правом dashboards:write в заголовке Authorization: Bearer <token> и установленный jq для разбора ответов. Без токена с этим правом запросы просто не пройдут. Схема панелей, единиц и аннотаций лежит в references/json-schema.md внутри скилла — без неё агент будет угадывать поля.
Какие задачи решает
- собрать JSON дашборда для нового сервиса и запушить его через API
- добавить выпадающий список
$jobв существующий дашборд - посчитать колонку «Error %» трансформацией
calculateField - наложить деплои на график аннотациями из Loki или Prometheus
- выгрузить JSON дашборда и проверить его после отправки по
uid
Примеры запросов агенту
- создай дашборд для метрики http_requests_total с разбивкой по status_code
- добавь в дашборд demo-svc-v1 переменную $job со списком сервисов
- покажи ошибки в процентах отдельной колонкой в таблице
Как установить dashboarding
1Через Skills CLI (Vercel)
npx skills add grafana/skills --skill dashboarding -a claude-code2Вручную: положить файлы
~/.claude/skills/dashboarding/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/dashboarding/
1Через Skills CLI (Vercel)
npx skills add grafana/skills --skill dashboarding -a codex2Вручную: положить файлы
.agents/skills/dashboarding/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add grafana/skills --skill dashboarding -a cursor2Вручную: положить файлы
.cursor/skills/dashboarding/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install grafana/skills dashboarding2Вручную: положить файлы
.github/skills/dashboarding/SKILL.md1Через Skills CLI (Vercel)
npx skills add grafana/skills --skill dashboarding -a gemini-cli2Командой платформы
gemini skills install https://github.com/grafana/skills --path skills/grafana-core/dashboardingВручную: положить файлы
.devin/skills/dashboarding/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add grafana/skills --skill dashboarding -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о dashboarding
Как установить dashboarding в Claude?
Выполните npx skills add grafana/skills --skill dashboarding -a claude-code. Скилл встанет в ~/.claude/skills/dashboarding/SKILL.md.
Что делает скилл dashboarding?
Пишет и правит JSON дашбордов Grafana: панели, переменные, трансформации, аннотации, ссылки. Отправляет готовый дашборд в HTTP API и проверяет результат по uid.
Что нужно, чтобы скилл заработал?
Стек Grafana, доступный с вашей машины, токен с правом dashboards:write и jq для разбора ответов API.
Исходный текст
SKILL.md · Apache-2.0
---
name: dashboarding
license: Apache-2.0
description: Build, modify, and ship Grafana dashboards as JSON via the HTTP API — panel types (timeseries / stat / gauge / table / heatmap / logs / traces / node-graph), `gridPos` 24-column layout, units, thresholds, template + datasource + chained variables, transformations (`organize` / `calculateField` / `filterByValue`), panel + dashboard links with `${__field.labels.x}` / `${__from}`, and Loki/Prometheus annotations. Use when scripting dashboard creation, writing the dashboard JSON for a new service, adding a `$job` dropdown variable, computing an "Error %" column with a transformation, overlaying deploys as annotations, or pushing a dashboard via `POST /api/dashboards/db` — even when the user says "create a dashboard for this metric", "add a service dropdown", "show errors as percentage", "overlay our deploys", or "export the dashboard JSON" without naming the API or schema. After every API push, verify with the returned `version` plus a GET on the dashboard UID.
---
# Grafana Dashboard Authoring
> **Docs**: https://grafana.com/docs/grafana/latest/dashboards/
Dashboards are JSON. Author once, push via API, share by `uid`.
## Prerequisites
- Grafana stack (OSS, Enterprise, or Cloud) reachable from your machine
- API token with `dashboards:write` (`Authorization: Bearer <token>`)
- `jq` for inspecting responses
- The JSON-schema cheat sheet in [`references/json-schema.md`](references/json-schema.md)
## Common Workflows
### 1. Push a new dashboard via the API + verify
```bash
# 1. Build the payload — wrap the dashboard JSON, set folder, mark overwrite
cat > /tmp/dash.json <<'JSON'
{
"dashboard": {
"uid": "demo-svc-v1",
"title": "Demo Service",
"schemaVersion": 41,
"tags": ["demo"],
"time": { "from": "now-1h", "to": "now" },
"templating": { "list": [] },
"panels": [{
"id": 1, "type": "timeseries", "title": "Request Rate",
"gridPos": { "x": 0, "y": 0, "w": 24, "h": 8 },
"datasource": { "type": "prometheus", "uid": "prometheus" },
"targets": [{
"expr": "sum(rate(http_requests_total[5m])) by (status_code)",
"legendFormat": "{{status_code}}", "refId": "A"
}],
"fieldConfig": { "defaults": { "unit": "reqps" }, "overrides": [] }
}]
},
"folderUid": "",
"overwrite": true,
"message": "initial push"
}
JSON
# 2. Validate the JSON BEFORE you send it (catches trailing-comma typos)
jq empty /tmp/dash.json && echo "json ok"
# 3. POST
RESP=$(curl -s -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
"$GRAFANA/api/dashboards/db" -d @/tmp/dash.json)
echo "$RESP" | jq '{status, uid, url, version}'
# Expect: status="success", url="/d/demo-svc-v1/...", version=1 (incremented on each push)
# 4. Verify the round-trip — read it back and confirm one panel + the expected title
curl -s -H "Authorization: Bearer $TOKEN" \
"$GRAFANA/api/dashboards/uid/demo-svc-v1" \
| jq '{title: .dashboard.title, panels: (.dashboard.panels | length)}'
# Expect: {"title":"Demo Service","panels":1}
# 5. Open the dashboard in a browser — confirm the panel renders with data.
```
### 2. Add a `$job` template variable to an existing dashboard
```bash
# 1. Fetch existing dashboard
curl -s -H "Authorization: Bearer $TOKEN" \
"$GRAFANA/api/dashboards/uid/demo-svc-v1" > /tmp/dash.json
# 2. Edit templating.list — append:
# { "name":"job", "type":"query",
# "datasource":{"type":"prometheus","uid":"prometheus"},
# "query":{"query":"label_values(up, job)","refId":"A"},
# "refresh":2, "includeAll":true, "multi":true, "label":"Service" }
# (Use jq, an editor, or the Grafana UI — schema in references/json-schema.md.)
# 3. Update the panel expr to use the variable: rate(http_requests_total{job=~"$job"}[5m])
# 4. POST it back with overwrite: true. Verify the variable appears in the UI dropdown.
```
### 3. Compute an "Error %" column with a transformation
```json
{
"id": "calculateField",
"options": {
"alias": "Error %", "mode": "reduceRow",
"reduce": { "reducer": "last" },
"binary": { "left": "errors", "right": "total", "operator": "/" }
}
}
```
Add this to the panel's `transformations: []`. Verify in the UI panel inspector — the new field should appear and update with the variable selection.
Full schema (panels, units, all transformations, annotations, links): [`references/json-schema.md`](references/json-schema.md).
## API reference
```bash
# Get
curl -s -H "Authorization: Bearer $TOKEN" \
"$GRAFANA/api/dashboards/uid/<uid>" | jq '.dashboard'
# Search
curl -s -H "Authorization: Bearer $TOKEN" \
"$GRAFANA/api/search?query=kubernetes&type=dash-db" | jq '.[] | {uid,title,folderTitle}'
# Create folder
curl -s -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" "$GRAFANA/api/folders" \
-d '{"uid":"platform-team","title":"Platform Team"}'
```
For dashboards embedded in app plugins, use `@grafana/scenes` (skill `grafana-o11y:grafana-scenes`).
## Resources
- [Dashboard JSON model](https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/view-dashboard-json-model/)
- [HTTP API — dashboards](https://grafana.com/docs/grafana/latest/developers/http_api/dashboard/)
- [Panel types](https://grafana.com/docs/grafana/latest/panels-visualizations/)
- [Variables](https://grafana.com/docs/grafana/latest/dashboards/variables/)
- [Transformations](https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/)
© grafana · Apache-2.0 · grafana/skills