Investigating Metric Anomalies
PostHogOfficialPublished by PostHog
- Skill
- Research and analysis
- Data and AI
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a systematic approach to root-cause analysis for infrastructure and server metrics. By moving from a metric symptom to evidence-based conclusions, it guides the user through identifying the metric, characterizing the anomaly, performing targeted queries, and correlating findings with logs and traces. It emphasizes a data-driven loop that helps distinguish between localized issues and systemic failures, ensuring that incident triage is based on concrete evidence rather than speculation.
What it does
- Identifies specific metrics related to system symptoms like latency, error rates, or throughput.
- Characterizes anomalies by determining the onset time, magnitude, and affected segments.
- Localizes issues by identifying top movers and label-specific behavior changes.
- Correlates metric anomalies with logs and traces to pinpoint the root cause.
- Provides a framework for concluding investigations with evidence-backed findings.
- Helps distinguish between transient spikes, service outages, and backlog processing.
When to use it
- When an infrastructure alert fires on an OTel or Prometheus metric.
- When a user reports a system symptom like rising ingestion lag or spiking error rates.
- During incident triage when a metric shows unexpected behavior.
- When you need to determine if a metric change is a localized issue or a systemic problem.
Advantages
- Reduces time-to-resolution by following a prioritized, high-information investigation loop.
- Prevents misinterpretation of metrics by accounting for counter resets and reporting gaps.
- Enables cross-signal correlation between metrics, logs, and traces.
- Provides a clear structure for documenting findings and blast radius.
Usage examples
- “Why is the ingestion lag rising on our logs-ingestion service?”
- The agent will list relevant metrics, characterize the anomaly to find the onset time, query throughput to see if the consumer is down, and check logs for restart events to confirm the cause.
- “Investigate the latency spike reported in the Prometheus dashboard at 10:00 AM.”
- The agent will characterize the latency anomaly, identify the top movers (e.g., specific endpoints or pods), and correlate the spike with trace data to identify the degraded dependency.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/posthog/investigating-metric-anomalies/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip investigating-metric-anomalies.zip -d .agents/skills
Documentation by PostHog
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 drain, self-recovering; affected signal: logs freshness only — no data loss (topic retained messages). Evidence: zero throughput during the window, message-age spike equal to outage duration, restart log lines.
Pitfalls
Counters reset on process restart —
rate/increasealready handle this; never eyeball raw cumulative counter values.A metric that stops reporting is not "zero" — a gap in
serieswithtop_moversshowing a vanished label value means the emitter died; pivot to logs immediately.Don't trust a single aggregation: a flat
avgcan hide a screamingp95. For latency-like gauges and histograms, characterize the tail too.Scraped Prometheus metrics arrive ~15–60s behind real time; don't read the last bucket of a series as "current".
Files
- ATTRIBUTION.mdAdded by AutoGineer879 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md5.8 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- PostHog
- Publisher
- PostHog (Official)
- Source
- PostHog/skills · skills/omnibus/investigating-metric-anomalies · commit a5d30e7
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by PostHog.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download investigating-metric-anomalies.zip