dashboarding について
Grafana ダッシュボードの作成・管理を支援する Skill です。JSON と HTTP API で管理するユーザー向けに、作成、編集、検索、検証の手順を扱います。
主な機能
- 01API によるダッシュボードの登録
- 02ダッシュボードの取得と検索
- 03テンプレート変数と変換の編集
- 04JSON スキーマによる設定
活用シーン
- 01新しいダッシュボードの公開と検証
- 02既存ダッシュボードへの変数追加
- 03変換によるパネルフィールドの計算
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ grafana/ skills --skill dashboardingインストール後、Claude Code で/dashboardingを入力して読み込まれたか確認します。
同梱ファイルreferences/json-schema.md
詳細
Grafana ダッシュボードの作成
ダッシュボードは JSON 形式です。一度作成したら、API 経由で送信し、uid で共有できます。
前提条件
- お使いのマシンからアクセスできる Grafana スタック(OSS、Enterprise、または Cloud)
dashboards:writeを持つ API トークン(Authorization: Bearer <token>)- レスポンスの確認に使用する
jq references/json-schema.mdの JSON スキーマ早見表
よくあるワークフロー
1. API 経由で新しいダッシュボードを送信して検証する
# 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. 既存のダッシュボードに $job テンプレート変数を追加する
# 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. 変換を使って「Error %」列を計算する
{
"id": "calculateField",
"options": {
"alias": "Error %", "mode": "reduceRow",
"reduce": { "reducer": "last" },
"binary": { "left": "errors", "right": "total", "operator": "/" }
}
}
これをパネルの transformations: [] に追加します。UI のパネルインスペクターで検証してください。新しいフィールドが表示され、変数の選択に応じて更新されるはずです。
完全なスキーマ(パネル、単位、すべての変換、注釈、リンク):references/json-schema.md。
API リファレンス
# 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"}'
アプリプラグインに埋め込むダッシュボードには、@grafana/scenes(スキル grafana-o11y:grafana-scenes)を使用してください。
リソース
コメント
Markdown 対応