Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)41k · #6895

investigating-metric-anomalies

Skill này làm gì

Skill này tìm hiểu vì sao một chỉ số hạ tầng đang tăng, giảm hoặc tăng đột biến, chẳng hạn độ trễ ingestion hoặc tỷ lệ lỗi. Nó dành cho kỹ sư đang xử lý một cảnh báo hoặc một biểu đồ đáng lo.

Khi nào nên dùng

  • ✓Khi một cảnh báo kích hoạt trên một chỉ số máy chủ và bạn muốn biết nguyên nhân có khả năng nhất.
  • ✓Khi tỷ lệ lỗi, độ trễ hoặc độ sâu hàng đợi đã thay đổi và bạn muốn biết vì sao.
  • ✓Khi bạn đang xử lý một sự cố bắt đầu bằng một thay đổi trong chỉ số.

Liên kết skill

https://github.com/PostHog/posthog/blob/master/products/metrics/skills/investigating-metric-anomalies/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/PostHog/posthog/blob/master/products/metrics/skills/investigating-metric-anomalies/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Độ trễ ingestion của chúng tôi đã tăng từ sáng nay. Tìm xem điều gì đang gây ra nó.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill đặt tên cho chỉ số, đo mức thay đổi lớn đến đâu và bắt đầu khi nào, rồi kiểm tra nhật ký và trace quanh thời điểm đó. Skill kết hợp các bằng chứng thành một nguyên nhân có khả năng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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_peak vs baseline_mean. If direction is flat, your window or metric is wrong — widen the window, or compare against the same window yesterday via baselineFrom/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 filters pinning 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 interval so 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 implicated service.name and window, severity error first, then warn. 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-spans etc.) for the same service/window — slow or erroring spans show which dependency degraded, and a trace_id from 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?"

  1. metric-names-list with value: "lag" → logs_rate_limiter_message_lag_seconds (histogram) and friends.
  2. characterize-metric-anomaly on it with anomalyFrom = alert time → direction up, change ratio 40x, onset_time 20:10, top mover service_name = logs-ingestion (the other services' lag stayed flat) — so the logs consumer specifically is behind, not the whole pipeline.
  3. query-metrics: rate of 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.
  4. query-logs for service.name = logs-ingestion (and its neighbors) around 20:00–20:15 → process exit + restart lines at the gap boundaries.
  5. Conclusion: consumer outage 20:01–20:10 (restart visible in logs); lag spike is backlog
Câu hỏi thường gặp

Skill tìm thời điểm vấn đề bắt đầu như thế nào?

Nó tìm thời điểm bắt đầu của thay đổi và dùng thời điểm đó làm điểm xuất phát cho nhật ký và trace.

Nếu chỉ số trông phẳng thì sao?

Khoảng thời gian hoặc chỉ số có thể sai, nên skill mở rộng khoảng thời gian hoặc so sánh với cùng thời điểm hôm qua.

Skill có sửa vấn đề không?

Không. Nó giải thích nguyên nhân có khả năng kèm bằng chứng để bạn quyết định cần sửa gì.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
41k
Vị trí xếp hạng
#6895
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự