investigating-metric-anomalies
できること
このスキルは、インフラの指標が上がる、下がる、または急増する理由を見つけます。例えば取り込みの遅延やエラー率です。アラートや気になるグラフに対応しているエンジニア向けです。
使う場面
- ✓サーバーの指標でアラートが鳴り、その原因の見当をつけたいとき。
- ✓エラー率、遅延、キューの深さが変わり、理由を知りたいとき。
- ✓指標の変化から始まったインシデントに対応しているとき。
スキルのリンク
https://github.com/PostHog/posthog/blob/master/products/metrics/skills/investigating-metric-anomalies/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“取り込みの遅延が今朝から上がり続けています。原因を見つけてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
指標の名前を特定し、変化の大きさと開始時刻を測ります。その時刻の前後のログとトレースを確認します。証拠を組み合わせて、考えられる原因にまとめます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Investigating metric anomalies
The job: go from a metric symptom ("ingestion lag is rising") to a probable cause with evidence, fast. The metric tells you what and when; logs and traces tell you why. Follow the loop below — it front-loads the cheap, high-information calls and only fans out when the blast radius is unclear.
The loop
1. Pin down the metric
If you have the exact metric name, skip ahead. Otherwise call metric-names-list with a substring from the symptom (lag, error, latency, queue). The returned metric_type decides the lens: counters (sum) are only meaningful as rate/increase, gauges as avg, histograms as histogram_quantile.
2. Characterize first — one call, three answers
Call characterize-metric-anomaly with the metric name and anomalyFrom (the alert fire time, or when the user says it started looking wrong; subtract some margin if unsure). It compares against the preceding window by default and answers:
- How bad:
direction,change_ratio,anomaly_peakvsbaseline_mean. Ifdirectionisflat, your window or metric is wrong — widen the window, or compare against the same window yesterday viabaselineFrom/baselineTo(daily-pattern metrics often look "anomalous" against the immediately-preceding hours). - When:
onset_time— treat this timestamp as the pivot for everything that follows. - Where:
top_movers— label values whose behavior changed. One mover (a single pod, shard, or endpoint) means a localized culprit; everything moving together means a shared cause (an upstream dependency, a deploy, infra).
3. Sharpen with targeted metric queries
Use query-metrics to test the hypotheses the report raises:
- Drill a mover: re-query with
filterspinning the suspicious label value, grouped by a second key, to localize further (pod → container, endpoint → status code). - Normalize: a rising error count means nothing if traffic doubled — use
clauses+formula(errors / requests) to separate rate changes from volume changes. - Check the neighbors: query the obvious companion metrics over the same window (for lag: throughput and error counters of the same service; for latency: request rate and saturation gauges). Use the same
intervalso the grids align visually.
4. Correlate across signals at the onset
Pivot into logs and traces using the same service and a window bracketing onset_time (a few buckets before, through the peak):
- Logs: use
query-logs(follow its own discover-first workflow) filtered to the implicatedservice.nameand window, severityerrorfirst, thenwarn. Restarts, crash loops, connection errors, and deploy markers right before onset are the classic causes. Widen to other services in the request path if the service's own logs are clean. - Traces: use the APM span tools (
query-apm-spansetc.) for the same service/window — slow or erroring spans show which dependency degraded, and atrace_idfrom an exemplar or log line links a concrete request across all three signals.
5. Conclude with evidence, not vibes
State: the symptom (metric, magnitude, onset), the probable cause (what you found in logs/traces and how its timing aligns with the onset), the blast radius (which services/labels are affected, from the movers and grouped queries), and the confidence level. If the cause is still ambiguous, say which hypothesis the evidence favors and what would disambiguate (e.g. "the lag began draining at 20:12 — consistent with a consumer restart; check who restarted it").
Worked example: "ingestion lag is rising — why?"
metric-names-listwithvalue: "lag"→logs_rate_limiter_message_lag_seconds(histogram) and friends.characterize-metric-anomalyon it withanomalyFrom= alert time → directionup, change ratio 40x,onset_time20:10, top moverservice_name = logs-ingestion(the other services' lag stayed flat) — so the logs consumer specifically is behind, not the whole pipeline.query-metrics:rateof the consumer's throughput counter over the same window → throughput was zero during the gap and spiked after onset: the consumer wasn't slow, it was down, and the "rising lag" is it draining the backlog.query-logsforservice.name = logs-ingestion(and its neighbors) around 20:00–20:15 → process exit + restart lines at the gap boundaries.- Conclusion: consumer outage 20:01–20:10 (restart visible in logs); lag spike is backlog
よくある質問
問題がいつ始まったかをどう見つけますか?
変化が始まった時刻を見つけ、その時刻をログとトレースを見るための起点にします。
指標が横ばいに見える場合はどうしますか?
時間枠や指標が間違っている可能性があるため、時間枠を広げるか、昨日の同じ時刻と比べます。
問題を直してくれますか?
いいえ。考えられる原因を証拠とともに説明するので、何を直すかはあなたが決められます。
詳細
作者による元の説明
Investigates server/infrastructure metric anomalies in PostHog Metrics — from "this metric is rising/dropping/spiking" or a fired alert to a probable cause with evidence. Use when asked why a metric looks wrong (ingestion lag rising, error rate spiking, latency degrading, queue depth growing, throughput dropping), when an alert fires on an OTel/Prometheus metric, or for any incident triage that starts from a metric symptom. Composes characterize-metric-anomaly, query-metrics, and metric-names-list with logs (query-logs) and traces (APM span tools) for cross-signal root-cause correlation.
repo: PostHog/posthog
人気
- GitHubのスター
- 41k
- ランキング
- #6895
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
depot-ci
41kエージェントが、GitHub Actionsの代替であるDepot CIのワークフローを設定し実行できるよう支援します。既存のワークフローの移行や、実行ログの確認も含みます。
depot-container-builds
41kエージェントが、Depotのリモート・ビルダーでDockerイメージを作れるよう支援します。マルチプラットフォームのイメージ、レジストリへのプッシュ、ビルド失敗の修正を含みます。
depot-github-runners
41kエージェントが、GitHub Actionsのジョブを Depot が管理するランナーに移し、ランナーのサイズとラベルを選び、ランナー設定の問題を解決できるよう支援します。
editing-agents-md
41kエージェントが、AGENTS.mdとCLAUDE.mdのどちらにルールを書くべきかを判断し、ファイルを膨らませずに守られやすい形で書けるよう支援します。
似ているスキル
openclaw-update
394k既存のOpenClaw Gatewayを更新するようエージェントを支援します。インストール方法に合った更新方法を選び、セッションを動かし続けます。
diagnose-gateway
394k設定、チャンネル、ポートを確認して、OpenClaw Gatewayが失敗している理由を、何も変更せずに突き止めるようエージェントを支援します。
crabbox-apps
394k一時的なクラウドマシン上でアプリを開いて実行し、そのビューをチャットのサイドパネルに表示するようエージェントを支援します。