jpskill.com
🛠️ 開発・MCP コミュニティ

grafana

Grafanaは、様々なデータソースに接続して、インタラクティブなダッシュボードを作成したり、アラートを設定したり、設定をコードで管理したりできる、データ可視化のためのオープンソースツールを活用するSkill。

📜 元の英語説明(参考)

Grafana is an open-source visualization and dashboarding platform that connects to dozens of data sources including Prometheus, PostgreSQL, ClickHouse, and Elasticsearch. It lets you build interactive dashboards with panels, set up alerting rules, and manage everything as code through JSON dashboard definitions and provisioning configuration.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Grafanaは、様々なデータソースに接続して、インタラクティブなダッシュボードを作成したり、アラートを設定したり、設定をコードで管理したりできる、データ可視化のためのオープンソースツールを活用するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o grafana.zip https://jpskill.com/download/14958.zip && unzip -o grafana.zip && rm grafana.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14958.zip -OutFile "$d\grafana.zip"; Expand-Archive "$d\grafana.zip" -DestinationPath $d -Force; ri "$d\grafana.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して grafana.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → grafana フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Grafana

Grafana は、あなたのデータをダッシュボードに変えます。時系列データベース、SQL データベース、ログストア、クラウドサービスに接続し、メトリクス、ログ、トレースを単一の画面で可視化するパネルを構築できます。アラート機能が組み込まれており、dashboard-as-code のワークフローにより、開発者のローカル環境から企業全体の可観測性プラットフォームまで拡張できます。

このスキルでは、Docker のデプロイ、データソースの設定、パネルの構築、アラートの設定、JSON を使用したコードとしてのダッシュボードの管理について説明します。

Docker セットアップ

Grafana を実行する最も簡単な方法は、公式の Docker イメージを使用することです。これにより、Grafana は永続ストレージで起動し、ダッシュボードは再起動後も保持されます。

# docker-compose.yml — 永続ストレージとデフォルトの管理者認証情報を持つ Grafana
version: "3.8"

services:
  grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=admin
    volumes:
      - grafana-data:/var/lib/grafana
      - ./provisioning:/etc/grafana/provisioning

volumes:
  grafana-data:
# CLI — Grafana の起動
docker compose up -d

http://localhost:3000 を開き、admin/admin でログインします。Grafana は、初回ログイン時にパスワードの変更を促します。

データソース

データソースは、データを保持するバックエンドへの接続です。Grafana は、パネルをレンダリングする際にそれらにクエリを実行します。UI から追加することも、YAML ファイルでプロビジョニングすることもできます。

データソースのプロビジョニング

YAML ファイルを provisioning/datasources/ に配置すると、Grafana は起動時にそれらを自動的にロードします。これは、Grafana の infrastructure-as-code の基礎となります。

# provisioning/datasources/datasources.yml — データソースのプロビジョニング
# Prometheus、PostgreSQL、ClickHouse の接続を構成します

apiVersion: 1

datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://prometheus:9090
    isDefault: true
    editable: false

  - name: PostgreSQL
    type: postgres
    access: proxy
    url: postgres:5432
    database: app_production
    user: grafana_reader
    secureJsonData:
      password: "${PG_PASSWORD}"
    jsonData:
      sslmode: disable
      maxOpenConns: 10
      postgresVersion: 1500

  - name: ClickHouse
    type: grafana-clickhouse-datasource
    access: proxy
    jsonData:
      host: clickhouse
      port: 9000
      defaultDatabase: default
      protocol: native
    secureJsonData:
      password: ""

データソースプラグインのインストール

ClickHouse などの一部のデータソースでは、最初にプラグインをインストールする必要があります。

# CLI — ClickHouse データソースプラグインのインストール
docker exec -it grafana grafana-cli plugins install grafana-clickhouse-datasource
docker compose restart grafana

パネルの構築

パネルは、ダッシュボードの構成要素です。各パネルは、データソースに対してクエリを実行し、結果をグラフ、テーブル、統計、ゲージ、またはその他の視覚化としてレンダリングします。

Prometheus を使用した時系列パネル

一般的な最初のパネルは、リクエストレートを示す時系列グラフです。

# Prometheus クエリ — ステータスコード別の 1 秒あたりの HTTP リクエストレート
sum by (status_code) (rate(http_requests_total[5m]))

ClickHouse を使用したテーブルパネル

表形式のデータの場合は、名前付きの列を返す ClickHouse クエリを使用します。

-- ClickHouse クエリ — 今週の利用状況上位 10 件の機能
-- Grafana テーブルパネルで使用
SELECT
    event_name AS feature,
    count() AS total_events,
    uniq(user_id) AS unique_users
FROM events
WHERE created_at >= toStartOfWeek(now())
GROUP BY event_name
ORDER BY total_events DESC
LIMIT 10

PostgreSQL を使用した統計パネル

統計パネルには、単一の数値が表示されます。KPI に適しています。

-- PostgreSQL クエリ — 月間経常収益
-- 単位が通貨 (USD) に設定された Grafana 統計パネルで使用
SELECT sum(amount) AS mrr
FROM subscriptions
WHERE status = 'active'
  AND period_start <= now()
  AND period_end >= now()

テンプレート変数

変数は、ダッシュボードをインタラクティブにします。クエリから変数を定義すると、ユーザーはドロップダウンでパネルをフィルタリングできます。

-- ClickHouse クエリ — イベント名の変数定義
-- 「Query」タイプの変数として「event_name」という名前で作成
SELECT DISTINCT event_name FROM events ORDER BY event_name

次に、$event_name を使用してパネルクエリでそれを参照します。

-- ClickHouse クエリ — テンプレート変数を使用したフィルタリングされたイベント数
SELECT
    toStartOfHour(created_at) AS time,
    count() AS events
FROM events
WHERE event_name = '$event_name'
    AND $__timeFilter(created_at)
GROUP BY time
ORDER BY time

アラート

Grafana Alerting は、スケジュールに基づいてルールを評価し、Slack、PagerDuty、またはメールなどの連絡先を通じて通知を送信します。

アラートルールのプロビジョニング

# provisioning/alerting/rules.yml — アラートルールのプロビジョニング
# エラー率が 5 分間 5% を超えた場合に発生します

apiVersion: 1

groups:
  - orgId: 1
    name: production-alerts
    folder: Production
    interval: 60s
    rules:
      - uid: high-error-rate
        title: High Error Rate
        condition: C
        data:
          - refId: A
            datasourceUid: prometheus
            model:
              expr: sum(rate(http_requests_total{status_code=~"5.."}[5m]))
          - refId: B
            datasourceUid: prometheus
            model:
              expr: sum(rate(http_requests_total[5m]))
          - refId: C
            datasourceUid: __expr__
            model:
              type: math
              expression: $A / $B
              conditions:
                - evaluator:
                    type: gt
                    params: [0.05]
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "Error rate is above 5%"

連絡先

# provisioning/alerting/contactpoints.yml — Slack 通知チャネル
apiVersion: 1

contactPoints:
  - orgId: 1
    name: slack-engineering
    receivers:
      - uid: slack-eng
        type: slack
        settings:
          url: "${S
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Grafana

Grafana turns your data into dashboards. It connects to time-series databases, SQL databases, log stores, and cloud services, then lets you build panels that visualize metrics, logs, and traces in a single pane of glass. With alerting built in and dashboard-as-code workflows, it scales from a developer's local setup to a company-wide observability platform.

This skill covers Docker deployment, configuring data sources, building panels, setting up alerts, and managing dashboards as code with JSON.

Docker Setup

The simplest way to run Grafana is the official Docker image. This starts Grafana with persistent storage so your dashboards survive restarts.

# docker-compose.yml — Grafana with persistent storage and default admin credentials
version: "3.8"

services:
  grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=admin
    volumes:
      - grafana-data:/var/lib/grafana
      - ./provisioning:/etc/grafana/provisioning

volumes:
  grafana-data:
# CLI — start Grafana
docker compose up -d

Open http://localhost:3000 and log in with admin/admin. Grafana will prompt you to change the password on first login.

Data Sources

Data sources are connections to the backends that hold your data. Grafana queries them when rendering panels. You can add them through the UI or provision them with YAML files.

Provisioning Data Sources

Place YAML files in provisioning/datasources/ and Grafana loads them automatically on startup. This is the foundation of infrastructure-as-code for Grafana.

# provisioning/datasources/datasources.yml — data source provisioning
# Configures Prometheus, PostgreSQL, and ClickHouse connections

apiVersion: 1

datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://prometheus:9090
    isDefault: true
    editable: false

  - name: PostgreSQL
    type: postgres
    access: proxy
    url: postgres:5432
    database: app_production
    user: grafana_reader
    secureJsonData:
      password: "${PG_PASSWORD}"
    jsonData:
      sslmode: disable
      maxOpenConns: 10
      postgresVersion: 1500

  - name: ClickHouse
    type: grafana-clickhouse-datasource
    access: proxy
    jsonData:
      host: clickhouse
      port: 9000
      defaultDatabase: default
      protocol: native
    secureJsonData:
      password: ""

Installing Data Source Plugins

Some data sources like ClickHouse require installing a plugin first:

# CLI — install the ClickHouse data source plugin
docker exec -it grafana grafana-cli plugins install grafana-clickhouse-datasource
docker compose restart grafana

Building Panels

Panels are the building blocks of dashboards. Each panel runs a query against a data source and renders the result as a graph, table, stat, gauge, or other visualization.

Time Series Panel with Prometheus

A common first panel is a time-series graph showing request rate:

# Prometheus query — HTTP request rate per second by status code
sum by (status_code) (rate(http_requests_total[5m]))

Table Panel with ClickHouse

For tabular data, use a ClickHouse query that returns named columns:

-- ClickHouse query — top 10 features by usage this week
-- Used in a Grafana Table panel
SELECT
    event_name AS feature,
    count() AS total_events,
    uniq(user_id) AS unique_users
FROM events
WHERE created_at >= toStartOfWeek(now())
GROUP BY event_name
ORDER BY total_events DESC
LIMIT 10

Stat Panel with PostgreSQL

Stat panels show a single number. They work well for KPIs:

-- PostgreSQL query — monthly recurring revenue
-- Used in a Grafana Stat panel with unit set to currency (USD)
SELECT sum(amount) AS mrr
FROM subscriptions
WHERE status = 'active'
  AND period_start <= now()
  AND period_end >= now()

Template Variables

Variables make dashboards interactive. Define a variable from a query, and users can filter panels with a dropdown:

-- ClickHouse query — variable definition for event names
-- Create as a "Query" type variable named "event_name"
SELECT DISTINCT event_name FROM events ORDER BY event_name

Then reference it in panel queries with $event_name:

-- ClickHouse query — filtered event count using template variable
SELECT
    toStartOfHour(created_at) AS time,
    count() AS events
FROM events
WHERE event_name = '$event_name'
    AND $__timeFilter(created_at)
GROUP BY time
ORDER BY time

Alerts

Grafana Alerting evaluates rules on a schedule and fires notifications through contact points like Slack, PagerDuty, or email.

Provisioning Alert Rules

# provisioning/alerting/rules.yml — alert rule provisioning
# Fires when error rate exceeds 5% for 5 minutes

apiVersion: 1

groups:
  - orgId: 1
    name: production-alerts
    folder: Production
    interval: 60s
    rules:
      - uid: high-error-rate
        title: High Error Rate
        condition: C
        data:
          - refId: A
            datasourceUid: prometheus
            model:
              expr: sum(rate(http_requests_total{status_code=~"5.."}[5m]))
          - refId: B
            datasourceUid: prometheus
            model:
              expr: sum(rate(http_requests_total[5m]))
          - refId: C
            datasourceUid: __expr__
            model:
              type: math
              expression: $A / $B
              conditions:
                - evaluator:
                    type: gt
                    params: [0.05]
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "Error rate is above 5%"

Contact Points

# provisioning/alerting/contactpoints.yml — Slack notification channel
apiVersion: 1

contactPoints:
  - orgId: 1
    name: slack-engineering
    receivers:
      - uid: slack-eng
        type: slack
        settings:
          url: "${SLACK_WEBHOOK_URL}"
          channel: "#engineering-alerts"
          title: '{{ .CommonLabels.alertname }}'
          text: '{{ .CommonAnnotations.summary }}'

Dashboard as Code

Grafana dashboards are JSON documents. You can export them from the UI, version control them, and provision them automatically. This is essential for reproducible infrastructure.

Provisioning Dashboards

Tell Grafana where to find dashboard JSON files:

# provisioning/dashboards/dashboards.yml — dashboard provisioning config
apiVersion: 1

providers:
  - name: default
    orgId: 1
    type: file
    disableDeletion: false
    updateIntervalSeconds: 30
    options:
      path: /etc/grafana/provisioning/dashboards/json
      foldersFromFilesStructure: true

Dashboard JSON

A minimal dashboard with one panel:

{
  "__comment": "provisioning/dashboards/json/overview.json — application overview dashboard",
  "uid": "app-overview",
  "title": "Application Overview",
  "timezone": "utc",
  "refresh": "30s",
  "time": { "from": "now-24h", "to": "now" },
  "panels": [
    {
      "id": 1,
      "type": "timeseries",
      "title": "Request Rate",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "sum(rate(http_requests_total[5m]))",
          "legendFormat": "requests/s"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "reqps",
          "custom": { "lineWidth": 2, "fillOpacity": 10 }
        }
      }
    },
    {
      "id": 2,
      "type": "stat",
      "title": "Active Users (24h)",
      "gridPos": { "h": 4, "w": 6, "x": 12, "y": 0 },
      "datasource": { "type": "grafana-clickhouse-datasource", "uid": "clickhouse" },
      "targets": [
        {
          "rawSql": "SELECT uniq(user_id) AS value FROM events WHERE created_at >= now() - INTERVAL 1 DAY"
        }
      ]
    }
  ],
  "templating": {
    "list": []
  },
  "schemaVersion": 39
}

Exporting Dashboards

To capture a dashboard you built in the UI as code, use the Grafana HTTP API:

# CLI — export a dashboard JSON by UID for version control
curl -s -H "Authorization: Bearer $GRAFANA_API_KEY" \
  'http://localhost:3000/api/dashboards/uid/app-overview' \
  | jq '.dashboard' > dashboards/app-overview.json

This workflow lets you iterate in the UI, export to JSON, commit to git, and deploy via provisioning — giving you the best of both visual editing and infrastructure-as-code.