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

log-analysis

Analyze application logs to identify errors, performance issues, and security anomalies. Use when debugging issues, monitoring system health, or investigating incidents. Handles various log formats including Apache, Nginx, application logs, and JSON logs.

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

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

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

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

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

ログ分析

このスキルを使用するタイミング

  • エラーのデバッグ: アプリケーションエラーの根本原因を分析します。
  • パフォーマンス分析: 応答時間とスループットを分析します。
  • セキュリティ監査: 異常なアクセスパターンを検出します。
  • インシデント対応: 障害発生時の根本原因を調査します。

手順

ステップ1: ログファイルの特定

# 一般的なログの場所
/var/log/                    # システムログ
/var/log/nginx/              # Nginxログ
/var/log/apache2/            # Apacheログ
./logs/                      # アプリケーションログ

ステップ2: エラーパターンの検索

一般的なエラー検索:

# ERRORレベルのログを検索
grep -i "error\|exception\|fail" application.log

# 最近のエラー (最後の100行)
tail -100 application.log | grep -i error

# タイムスタンプ付きのエラー
grep -E "^\[.*ERROR" application.log

HTTPエラーコード:

# 5xx サーバーエラー
grep -E "HTTP/[0-9.]+ 5[0-9]{2}" access.log

# 4xx クライアントエラー
grep -E "HTTP/[0-9.]+ 4[0-9]{2}" access.log

# 特定のエラーコード
grep "HTTP/1.1\" 500" access.log

ステップ3: パターン分析

時間ベースの分析:

# 時間枠ごとのエラー数
grep -i error application.log | cut -d' ' -f1,2 | sort | uniq -c | sort -rn

# 特定の時間枠のログ
grep "2025-01-05 14:" application.log

IPベースの分析:

# IPごとのリクエスト数
awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -20

# 特定のIPのアクティビティ
grep "192.168.1.100" access.log

ステップ4: パフォーマンス分析

応答時間分析:

# Nginxログから応答時間を抽出
awk '{print $NF}' access.log | sort -n | tail -20

# 遅いリクエスト (1秒以上)
awk '$NF > 1.0 {print $0}' access.log

トラフィック量分析:

# 1分あたりのリクエスト数
awk '{print $4}' access.log | cut -d: -f1,2,3 | uniq -c

# エンドポイントごとのリクエスト数
awk '{print $7}' access.log | sort | uniq -c | sort -rn | head -20

ステップ5: セキュリティ分析

不審なパターン:

# SQLインジェクションの試行
grep -iE "(union|select|insert|update|delete|drop).*--" access.log

# XSSの試行
grep -iE "<script|javascript:|onerror=" access.log

# ディレクトリトラバーサル
grep -E "\.\./" access.log

# ブルートフォースアタック
grep -E "POST.*/login" access.log | awk '{print $1}' | sort | uniq -c | sort -rn

出力形式

分析レポートの構造

# ログ分析レポート

## 概要
- 分析期間: YYYY-MM-DD HH:MM ~ YYYY-MM-DD HH:MM
- 総ログ行数: X,XXX
- エラー数: XXX
- 警告数: XXX

## エラー分析
| エラータイプ | 発生回数 | 最終確認日時 |
|----------|-----------|----------|
| エラーA  | 150       | 2025-01-05 14:30 |
| エラーB  | 45        | 2025-01-05 14:25 |

## 推奨されるアクション
1. [アクション1]
2. [アクション2]

ベストプラクティス

  1. 時間範囲の設定: 分析する時間枠を明確に定義します。
  2. パターンの保存: 一般的な grep パターンをスクリプト化します。
  3. コンテキストの確認: エラー周辺のログも確認します (-A-B オプション)。
  4. ログローテーション: 圧縮されたログも zgrep で検索します。

制約

必須ルール (MUST)

  1. 読み取り専用操作のみを実行します。
  2. 機密情報 (パスワード、トークン) をマスクします。

禁止事項 (MUST NOT)

  1. ログファイルを変更しないでください。
  2. 機密情報を外部に公開しないでください。

参考文献

例1: 基本的な使用方法

<!-- ここに例のコンテンツを追加してください -->

例2: 高度な使用方法

<!-- ここに高度な例のコンテンツを追加してください -->

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Log Analysis

When to use this skill

  • Error debugging: analyze the root cause of application errors
  • Performance analysis: analyze response times and throughput
  • Security audit: detect anomalous access patterns
  • Incident response: investigate the root cause during an outage

Instructions

Step 1: Locate Log Files

# Common log locations
/var/log/                    # System logs
/var/log/nginx/              # Nginx logs
/var/log/apache2/            # Apache logs
./logs/                      # Application logs

Step 2: Search for Error Patterns

Common error search:

# Search ERROR-level logs
grep -i "error\|exception\|fail" application.log

# Recent errors (last 100 lines)
tail -100 application.log | grep -i error

# Errors with timestamps
grep -E "^\[.*ERROR" application.log

HTTP error codes:

# 5xx server errors
grep -E "HTTP/[0-9.]+ 5[0-9]{2}" access.log

# 4xx client errors
grep -E "HTTP/[0-9.]+ 4[0-9]{2}" access.log

# Specific error code
grep "HTTP/1.1\" 500" access.log

Step 3: Pattern Analysis

Time-based analysis:

# Error count by time window
grep -i error application.log | cut -d' ' -f1,2 | sort | uniq -c | sort -rn

# Logs for a specific time window
grep "2025-01-05 14:" application.log

IP-based analysis:

# Request count by IP
awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -20

# Activity for a specific IP
grep "192.168.1.100" access.log

Step 4: Performance Analysis

Response time analysis:

# Extract response times from Nginx logs
awk '{print $NF}' access.log | sort -n | tail -20

# Slow requests (>= 1 second)
awk '$NF > 1.0 {print $0}' access.log

Traffic volume analysis:

# Requests per minute
awk '{print $4}' access.log | cut -d: -f1,2,3 | uniq -c

# Requests per endpoint
awk '{print $7}' access.log | sort | uniq -c | sort -rn | head -20

Step 5: Security Analysis

Suspicious patterns:

# SQL injection attempts
grep -iE "(union|select|insert|update|delete|drop).*--" access.log

# XSS attempts
grep -iE "<script|javascript:|onerror=" access.log

# Directory traversal
grep -E "\.\./" access.log

# Brute force attack
grep -E "POST.*/login" access.log | awk '{print $1}' | sort | uniq -c | sort -rn

Output format

Analysis report structure

# Log analysis report

## Summary
- Analysis window: YYYY-MM-DD HH:MM ~ YYYY-MM-DD HH:MM
- Total log lines: X,XXX
- Error count: XXX
- Warning count: XXX

## Error analysis
| Error type | Occurrences | Last seen |
|----------|-----------|----------|
| Error A  | 150       | 2025-01-05 14:30 |
| Error B  | 45        | 2025-01-05 14:25 |

## Recommended actions
1. [Action 1]
2. [Action 2]

Best practices

  1. Set time range: clearly define the time window to analyze
  2. Save patterns: script common grep patterns
  3. Check context: review logs around the error too (-A, -B options)
  4. Log rotation: search compressed logs with zgrep as well

Constraints

Required Rules (MUST)

  1. Perform read-only operations only
  2. Mask sensitive information (passwords, tokens)

Prohibited (MUST NOT)

  1. Do not modify log files
  2. Do not expose sensitive information externally

References

Examples

Example 1: Basic usage

<!-- Add example content here -->

Example 2: Advanced usage

<!-- Add advanced example content here -->