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

observability-alert-manager

Claudeのコードに関する異常や閾値を監視するために、セッション数、エラー発生率、コンテキスト利用状況、サブエージェントの動作などをGrafanaアラートで設定し、問題発生を早期に検知するSkill。

📜 元の英語説明(参考)

Configure Grafana alerts for Claude Code anomalies and thresholds. Use when setting up monitoring alerts for sessions, errors, context usage, or subagents.

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

一言でいうと

Claudeのコードに関する異常や閾値を監視するために、セッション数、エラー発生率、コンテキスト利用状況、サブエージェントの動作などをGrafanaアラートで設定し、問題発生を早期に検知するSkill。

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

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

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

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

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

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して observability-alert-manager.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → observability-alert-manager フォルダができる
  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 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Observability Alert Manager

拡張されたテレメトリを使用して、Claude Code モニタリング用の Grafana アラートを設定および管理します。

データソース

プライマリ: Loki の {job="claude_code_enhanced"}

操作

create-alert

新しいアラートルールを定義します。 パラメータ: name、query (LogQL)、threshold、duration、severity、notification。

list-alerts

設定されているすべてのアラートとそのステータスを表示します。

test-alert

アラート条件をシミュレートします。

delete-alert

アラートルールを削除します。

事前構築済みアラートテンプレート

セッションアラート

  1. Long Session Duration: セッション >1 時間

    {job="claude_code_enhanced", event_type="session_end"} | json | duration_seconds > 3600
  2. High Turn Count: セッション >50 ターン

    {job="claude_code_enhanced", event_type="session_end"} | json | turn_count > 50
  3. Session Error Spike: セッションで >5 エラー

    {job="claude_code_enhanced", event_type="session_end"} | json | error_count > 5

エラーアラート

  1. High Error Rate: >5 エラー/時間

    count_over_time({job="claude_code_enhanced", event_type="tool_result", status="error"} [1h]) > 5
  2. Specific Tool Failures: Bash エラー

    count_over_time({job="claude_code_enhanced", event_type="tool_result", status="error", tool="Bash"} [1h]) > 3

コンテキストアラート

  1. High Context Usage: >80% コンテキストウィンドウ

    {job="claude_code_enhanced", event_type="context_utilization"} | json | context_percentage > 80
  2. Auto Compaction Triggered: コンテキストフル

    {job="claude_code_enhanced", event_type="context_compact", trigger="auto"}

サブエージェントアラート

  1. Excessive Subagent Spawning: >10 サブエージェント/セッション
    {job="claude_code_enhanced", event_type="session_end"} | json | subagents_spawned > 10

アクティビティアラート

  1. Telemetry Staleness: データなし >10 分

    absent_over_time({job="claude_code_enhanced"} [10m])
  2. Unusual Activity Spike: >100 ツールコール/時間

     count_over_time({job="claude_code_enhanced", event_type="tool_call"} [1h]) > 100

プロンプトパターンアラート

  1. Debugging Session Spike: 多数のデバッグプロンプト
    count_over_time({job="claude_code_enhanced", event_type="user_prompt", pattern="debugging"} [1h]) > 10

アラート設定例

High Error Rate アラートの作成

create-alert \
  --name "High Error Rate" \
  --query 'count_over_time({job="claude_code_enhanced", event_type="tool_result", status="error"} [1h]) > 5' \
  --severity warning \
  --notification slack

Context Usage アラートの作成

create-alert \
  --name "High Context Usage" \
  --query '{job="claude_code_enhanced", event_type="context_utilization"} | json | context_percentage > 80' \
  --severity info \
  --notification email

Session Duration アラートの作成

create-alert \
  --name "Long Session Warning" \
  --query '{job="claude_code_enhanced", event_type="session_end"} | json | duration_seconds > 3600' \
  --severity info \
  --notification dashboard

Grafana アラートのセットアップ

Grafana UI 経由

  1. Alerting → Alert rules に移動します
  2. Loki データソースで新しいルールを作成します
  3. 上記のテンプレートから LogQL クエリを入力します
  4. 条件と通知を設定します

API 経由

curl -X POST http://localhost:3000/api/ruler/grafana/api/v1/rules/claude-code \
  -H "Content-Type: application/json" \
  -u admin:admin \
  -d '{
    "name": "claude-code-alerts",
    "rules": [
      {
        "alert": "HighErrorRate",
        "expr": "count_over_time({job=\"claude_code_enhanced\", status=\"error\"} [1h]) > 5",
        "for": "5m",
        "labels": {"severity": "warning"},
        "annotations": {"summary": "High error rate detected"}
      }
    ]
  }'

通知チャネル

  • Slack: Webhook 連携
  • Email: SMTP 設定
  • PagerDuty: インシデント管理
  • Dashboard: 画面上のアノテーション

アラートの重大度レベル

レベル ユースケース
critical 即時対応が必要
warning 近いうちに注意が必要
info 情報提供、対応不要

スクリプト

  • scripts/create-alert.sh - 新しいアラートを作成します
  • scripts/list-alerts.sh - すべてのアラートをリストします
  • scripts/test-alerts.sh - アラート条件をテストします
  • scripts/import-alert-templates.sh - 事前構築済みのすべてのテンプレートをインポートします
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Observability Alert Manager

Configure and manage Grafana alerts for Claude Code monitoring using enhanced telemetry.

Data Source

Primary: {job="claude_code_enhanced"} in Loki

Operations

create-alert

Define new alert rule. Parameters: name, query (LogQL), threshold, duration, severity, notification.

list-alerts

Show all configured alerts and their status.

test-alert

Simulate alert conditions.

delete-alert

Remove alert rule.

Pre-built Alert Templates

Session Alerts

  1. Long Session Duration: Session >1 hour

    {job="claude_code_enhanced", event_type="session_end"} | json | duration_seconds > 3600
  2. High Turn Count: Session >50 turns

    {job="claude_code_enhanced", event_type="session_end"} | json | turn_count > 50
  3. Session Error Spike: >5 errors in session

    {job="claude_code_enhanced", event_type="session_end"} | json | error_count > 5

Error Alerts

  1. High Error Rate: >5 errors/hour

    count_over_time({job="claude_code_enhanced", event_type="tool_result", status="error"} [1h]) > 5
  2. Specific Tool Failures: Bash errors

    count_over_time({job="claude_code_enhanced", event_type="tool_result", status="error", tool="Bash"} [1h]) > 3

Context Alerts

  1. High Context Usage: >80% context window

    {job="claude_code_enhanced", event_type="context_utilization"} | json | context_percentage > 80
  2. Auto Compaction Triggered: Context full

    {job="claude_code_enhanced", event_type="context_compact", trigger="auto"}

Subagent Alerts

  1. Excessive Subagent Spawning: >10 subagents/session
    {job="claude_code_enhanced", event_type="session_end"} | json | subagents_spawned > 10

Activity Alerts

  1. Telemetry Staleness: No data >10min

    absent_over_time({job="claude_code_enhanced"} [10m])
  2. Unusual Activity Spike: >100 tool calls/hour

     count_over_time({job="claude_code_enhanced", event_type="tool_call"} [1h]) > 100

Prompt Pattern Alerts

  1. Debugging Session Spike: Many debugging prompts
    count_over_time({job="claude_code_enhanced", event_type="user_prompt", pattern="debugging"} [1h]) > 10

Example Alert Configurations

Create High Error Rate Alert

create-alert \
  --name "High Error Rate" \
  --query 'count_over_time({job="claude_code_enhanced", event_type="tool_result", status="error"} [1h]) > 5' \
  --severity warning \
  --notification slack

Create Context Usage Alert

create-alert \
  --name "High Context Usage" \
  --query '{job="claude_code_enhanced", event_type="context_utilization"} | json | context_percentage > 80' \
  --severity info \
  --notification email

Create Session Duration Alert

create-alert \
  --name "Long Session Warning" \
  --query '{job="claude_code_enhanced", event_type="session_end"} | json | duration_seconds > 3600' \
  --severity info \
  --notification dashboard

Grafana Alert Setup

Via Grafana UI

  1. Navigate to Alerting → Alert rules
  2. Create new rule with Loki data source
  3. Enter LogQL query from templates above
  4. Configure conditions and notifications

Via API

curl -X POST http://localhost:3000/api/ruler/grafana/api/v1/rules/claude-code \
  -H "Content-Type: application/json" \
  -u admin:admin \
  -d '{
    "name": "claude-code-alerts",
    "rules": [
      {
        "alert": "HighErrorRate",
        "expr": "count_over_time({job=\"claude_code_enhanced\", status=\"error\"} [1h]) > 5",
        "for": "5m",
        "labels": {"severity": "warning"},
        "annotations": {"summary": "High error rate detected"}
      }
    ]
  }'

Notification Channels

  • Slack: Webhook integration
  • Email: SMTP configuration
  • PagerDuty: Incident management
  • Dashboard: On-screen annotations

Alert Severity Levels

Level Use Case
critical Immediate action required
warning Needs attention soon
info Informational, no action needed

Scripts

  • scripts/create-alert.sh - Create new alert
  • scripts/list-alerts.sh - List all alerts
  • scripts/test-alerts.sh - Test alert conditions
  • scripts/import-alert-templates.sh - Import all pre-built templates