スキル一覧に戻る

detect-anomalies-aiops

pjt222
更新日 2 days ago
6 閲覧
17
2
17
GitHubで表示
その他aiapi

について

このスキルは、時系列分析(Isolation Forest、Prophet、LSTM)、アラート相関、根本原因分析を用いて、運用メトリクスのAI駆動異常検出を実装します。単純な静的閾値を超えて、システムメトリクス、ログ、トレースにおける真の異常をインテリジェントに識別することで、アラート疲労を軽減します。運用チームがアラートの量に圧倒されている場合、複雑な複数メトリクスの異常を検出する場合、または季節パターンによって従来の閾値が効果を発揮しない場合にご利用ください。

クイックインストール

Claude Code

推奨
メイン
npx skills add pjt222/agent-almanac -a claude-code
プラグインコマンド代替
/plugin add https://github.com/pjt222/agent-almanac
Git クローン代替
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/detect-anomalies-aiops

このコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします

ドキュメント

Detect Anomalies for AIOps

See Extended Examples for complete configuration files and templates.

ML → anomalies in ops metrics + alert correlation + cut false positives.

Use When

  • Ops team drowns in alerts (>100/day)
  • Multi-metric anomalies (not just threshold)
  • Seasonal patterns → static thresholds fail
  • Predict issues before user impact
  • Correlate alerts → root cause
  • Monitoring → too many false positives
  • Subtle perf degradation trends

In

  • Required: Time series metrics (CPU, mem, latency, err rate)
  • Required: Historical data (30-90 days min)
  • Optional: Alert history w/ labels (TP/FP)
  • Optional: Sys topology (svc deps)
  • Optional: Logs → correlation
  • Optional: Deploy/change events → context

Do

Step 1: Env + Load Data

Install deps + prep time series.

# Create virtual environment
python -m venv venv
source venv/bin/activate

# Install anomaly detection libraries
pip install prophet scikit-learn pandas numpy
pip install tensorflow keras  # for LSTM models
pip install pyod  # Python Outlier Detection library
pip install statsmodels  # for statistical methods
pip install prometheus-api-client  # if using Prometheus

# Visualization
pip install plotly matplotlib seaborn

Load + prep:

# aiops/data_loader.py
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
from typing import List, Dict
import logging

logging.basicConfig(level=logging.INFO)
# ... (see EXAMPLES.md for complete implementation)

→ Time series loaded w/ regular intervals, missing vals handled, features engineered.

If err: Prometheus conn fails → verify URL + net. Data gaps → forward-fill or interpolate. Ensure ts col is datetime. Mem issues on large ranges → chunks.

Step 2: Isolation Forest (Multivariate)

Unsupervised Isolation Forest.

# aiops/isolation_forest_detector.py
from sklearn.ensemble import IsolationForest
from sklearn.preprocessing import StandardScaler
import pandas as pd
import numpy as np
from typing import Dict, List
import joblib

# ... (see EXAMPLES.md for complete implementation)

→ Model trained on history, anomalies scored, typically 0.5-2% flagged.

If err: too many (>5%) → reduce contamination or retrain on cleaner baseline. Too few (<0.1%) → increase contamination or check scaling. Verify features have variance.

Step 3: Prophet (Forecast + Anomaly)

Facebook Prophet → seasonality + deviations.

# aiops/prophet_detector.py
from prophet import Prophet
import pandas as pd
import numpy as np
from typing import Dict, Tuple
import logging

logger = logging.getLogger(__name__)
# ... (see EXAMPLES.md for complete implementation)

→ Prophet captures daily/weekly seasonality, anomalies when actuals fall outside 99% CI, forecasts for capacity planning.

If err: too slow (>5 min/metric) → reduce history to 30 days or disable weekly_seasonality. Too many FP → interval_width to 0.995. Missing seasonal → custom seasonalities. TZ consistency in ts.

Step 4: Correlate Alerts + Root Cause

Group related anomalies, find causes.

# aiops/alert_correlation.py
import pandas as pd
import numpy as np
from sklearn.cluster import DBSCAN
from typing import List, Dict
from datetime import timedelta
import networkx as nx

# ... (see EXAMPLES.md for complete implementation)

→ Related anomalies → incidents, root causes via dep graph, incident summaries.

If err: all anomalies as separate → increase time_window_minutes. Root cause unclear → define metric_relationships per architecture. Verify ts sort.

Step 5: Integrate w/ Alerting

Smart alerts + noise suppress.

# aiops/intelligent_alerting.py
import requests
import logging
from typing import Dict, List
from datetime import datetime, timedelta
import json

logger = logging.getLogger(__name__)
# ... (see EXAMPLES.md for complete implementation)

→ High sev → PagerDuty, med → Slack, low → log only, dupes suppressed in 15-min window.

If err: test webhook w/ curl first. Verify severity (0.5-0.9 range). Check rate limit doesn't suppress all. TZ handling for last_alerts.

Step 6: Deploy as Continuous Svc

Auto pipeline on interval.

# aiops/monitoring_service.py
import schedule
import time
import logging
from datetime import datetime, timedelta
from data_loader import MetricsDataLoader
from isolation_forest_detector import IsolationForestDetector
from prophet_detector import ProphetAnomalyDetector
# ... (see EXAMPLES.md for complete implementation)

→ Svc runs continuous, detects every 5 min, alerts on incidents, logs all.

If err: scheduler process alive (systemd/supervisor in prod). Verify Prometheus conn. Models loaded OK. Dead man's switch if svc stops. Monitor mem (reload models periodically if grows).

Check

  • History loaded w/ no missing ts
  • Isolation Forest → known anomalies from test set
  • Prophet captures daily/weekly seasonality
  • Alert correlation groups time-related anomalies
  • Root cause → upstream issues correct
  • Smart alerting suppresses dupes
  • Severity scores (0.5-0.9)
  • Svc runs 7+ days no crash
  • FP rate <10% (labeled data)
  • TP rate >80% (critical incidents)

Traps

  • Train on anomaly data: Baseline must be clean (no incidents). Manual review or labeled data.
  • Ignore seasonality: Static models fail on daily/weekly. Prophet or time features.
  • Too sensitive: 99% CI flags normal peaks. Start 99.5% + tune on FP.
  • Skip missing data: Gaps → model errors. Robust preprocess + interpolate.
  • Alert fatigue from low sev: Filter below threshold. High-conf only.
  • Ignore topology: Treating metrics solo misses cascades. Define deps.
  • Model drift: Old data → stale. Retrain monthly or on sys changes.
  • Resource contention: Detecting every metric costly. Prioritize critical svcs or sample.

  • monitor-model-drift — detect when detection models degrade
  • monitor-data-integrity — data quality before detection
  • setup-prometheus-monitoring — collect ops metrics
  • forecast-operational-metrics — capacity planning w/ Prophet

GitHub リポジトリ

pjt222/agent-almanac
パス: i18n/caveman-ultra/skills/detect-anomalies-aiops
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

関連スキル

llamaguard

その他

LlamaGuardは、暴力やヘイトスピーチなど6つの安全性カテゴリーにおいて、LLMの入力と出力をモデレートするMetaの70-80億パラメータモデルです。94〜95%の精度を提供し、vLLM、Hugging Face、Amazon SageMakerを使用してデプロイ可能です。このスキルを使用して、AIアプリケーションにコンテンツフィルタリングと安全策を簡単に統合できます。

スキルを見る

cost-optimization

その他

このClaudeスキルは、リソースの適正サイジング、タグ付け戦略、支出分析を通じて、開発者がクラウドコストを最適化することを支援します。AWS、Azure、GCPにわたるクラウド支出の削減とコストガバナンスの実施のためのフレームワークを提供します。インフラコストの分析、リソースの適正サイジング、または予算制約への対応が必要な際にご利用ください。

スキルを見る

quantizing-models-bitsandbytes

その他

このスキルは、bitsandbytesを使用してLLMを8ビットまたは4ビット精度に量子化し、精度の低下を最小限に抑えつつ50〜75%のメモリ削減を実現します。限られたGPUメモリでより大規模なモデルを実行したり、推論を高速化するのに理想的で、INT8、NF4、FP4などのフォーマットをサポートしています。HuggingFace Transformersと統合され、QLoRAトレーニングや8ビットオプティマイザーを可能にします。

スキルを見る

dispatching-parallel-agents

その他

このClaudeスキルは、複数のエージェントを配備し、3つ以上の独立した問題を並行して調査・修正します。共有状態や依存関係がなく解決可能な、無関係な障害が発生するシナリオ向けに設計されています。中核となる機能は並列問題解決であり、効率を最大化するために独立した問題領域ごとに1つのエージェントを割り当てます。

スキルを見る