Log Analyzer
by ntaksh42
Analyze application logs to detect errors, patterns, anomalies, and generate insights. Use when troubleshooting issues or analyzing system behavior.
Skill Details
Repository Files
1 file in this skill directory
name: log-analyzer description: Analyze application logs to detect errors, patterns, anomalies, and generate insights. Use when troubleshooting issues or analyzing system behavior.
Log Analyzer Skill
アプリケーションログを分析し、問題を特定するスキルです。
概要
大量のログファイルからエラー、警告、パターンを検出し、根本原因を分析します。
主な機能
- エラー検出: 例外、スタックトレース、エラーメッセージ
- パターン認識: 繰り返し発生する問題
- 時系列分析: エラーの発生傾向
- 根本原因分析: ログから問題の原因を推定
- 統計情報: エラー率、レスポンスタイム等
- アラート生成: 異常検知と通知
- ログレベル分類: ERROR、WARN、INFO、DEBUG
使用方法
以下のログを分析:
[ログファイルの内容]
分析項目:
- エラーの種類と頻度
- 根本原因の推定
- 解決策の提案
分析例
エラーログ分析
入力ログ:
2024-06-15 10:23:45 ERROR [database] Connection timeout after 30s
2024-06-15 10:23:50 ERROR [database] Connection timeout after 30s
2024-06-15 10:24:12 ERROR [database] Connection timeout after 30s
2024-06-15 10:25:33 ERROR [api] Failed to fetch user data: Database unavailable
2024-06-15 10:25:34 ERROR [api] Failed to fetch user data: Database unavailable
分析結果:
# ログ分析レポート
## サマリー
- **分析期間**: 2024-06-15 10:23:45 - 10:25:34 (2分間)
- **総ログ数**: 450行
- **エラー数**: 5件
- **警告数**: 12件
## 検出された問題
### [CRITICAL] データベース接続タイムアウト
**頻度**: 3回(10:23:45 - 10:24:12)
**影響**: API リクエスト失敗(2件)
**ログパターン**:
ERROR [database] Connection timeout after 30s
**根本原因(推定)**:
1. データベースサーバーの過負荷
2. ネットワーク接続の問題
3. コネクションプールの枯渇
**推奨アクション**:
1. データベースのCPU/メモリ使用率を確認
2. スロークエリログをチェック
3. コネクションプールサイズを確認
4. ネットワーク遅延を計測
### [HIGH] API エラー連鎖
**頻度**: 2回(DB タイムアウト後に発生)
**原因**: データベース障害の波及
## 時系列分析
10:23 ├─ DB接続タイムアウト開始 10:24 ├─ DB接続タイムアウト継続 10:25 ├─ API エラー発生(DB不可) └─ ユーザーリクエスト失敗
## 統計情報
| メトリクス | 値 |
|----------|-----|
| エラー率 | 1.1% (5/450) |
| 平均レスポンス | 245ms |
| 最大レスポンス | 30,012ms (timeout) |
| 成功率 | 98.9% |
## 推奨対応
### 即時対応
1. データベース接続状況の確認
2. アプリケーション再起動(接続プールリセット)
3. データベースのパフォーマンス確認
### 短期対応
1. コネクションプールサイズの最適化
2. タイムアウト値の見直し
3. リトライロジックの実装
### 長期対応
1. データベースのスケーリング
2. 読み取りレプリカの追加
3. キャッシュ層の導入
サポートログ形式
- 一般形式: syslog, Apache, Nginx
- アプリケーション: Log4j, Winston, Python logging
- クラウド: CloudWatch, Stackdriver
- JSON: 構造化ログ
ベストプラクティス
- 構造化ログ: JSON形式で統一
- 適切なレベル: ERROR、WARN、INFO を使い分け
- コンテキスト: リクエストID、ユーザーIDを含める
- 集約: ログ集約ツール(ELK、Splunk)使用
バージョン情報
- スキルバージョン: 1.0.0
- 最終更新: 2025-01-22
Related Skills
Attack Tree Construction
Build comprehensive attack trees to visualize threat paths. Use when mapping attack scenarios, identifying defense gaps, or communicating security risks to stakeholders.
Grafana Dashboards
Create and manage production Grafana dashboards for real-time visualization of system and application metrics. Use when building monitoring dashboards, visualizing metrics, or creating operational observability interfaces.
Matplotlib
Foundational plotting library. Create line plots, scatter, bar, histograms, heatmaps, 3D, subplots, export PNG/PDF/SVG, for scientific visualization and publication figures.
Scientific Visualization
Create publication figures with matplotlib/seaborn/plotly. Multi-panel layouts, error bars, significance markers, colorblind-safe, export PDF/EPS/TIFF, for journal-ready scientific plots.
Seaborn
Statistical visualization. Scatter, box, violin, heatmaps, pair plots, regression, correlation matrices, KDE, faceted plots, for exploratory analysis and publication figures.
Shap
Model interpretability and explainability using SHAP (SHapley Additive exPlanations). Use this skill when explaining machine learning model predictions, computing feature importance, generating SHAP plots (waterfall, beeswarm, bar, scatter, force, heatmap), debugging models, analyzing model bias or fairness, comparing models, or implementing explainable AI. Works with tree-based models (XGBoost, LightGBM, Random Forest), deep learning (TensorFlow, PyTorch), linear models, and any black-box model
Pydeseq2
Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.
Query Writing
For writing and executing SQL queries - from simple single-table queries to complex multi-table JOINs and aggregations
Pydeseq2
Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.
Scientific Visualization
Meta-skill for publication-ready figures. Use when creating journal submission figures requiring multi-panel layouts, significance annotations, error bars, colorblind-safe palettes, and specific journal formatting (Nature, Science, Cell). Orchestrates matplotlib/seaborn/plotly with publication styles. For quick exploration use seaborn or plotly directly.
