Subchapter 81.2
references/basics.mdMarkdown5 KBView on GitHub
AI agents: this is one page from PostHog’s docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt (opens in a new tab)
Metrics are numbers about your system measured over time: how many requests you served, how long they took, how deep the job queue is, how much memory a process is using. Where logs (opens in a new tab) record individual events and traces (opens in a new tab) follow individual requests, metrics summarize everything. They answer “how is the system doing?” at a glance, cheaply, all the time.
A metric is a named time series. You pick a name like http.server.duration, record values against it, and PostHog turns those values into points on a chart. Three shapes cover almost everything:
rate (per second) or an increase (per time bucket).avg or the latest reading.p95 or p99 they actually experience.Attributes add dimensions to a metric. Record http.server.duration with a route and status attribute and you can later split one chart into a line per route, or filter to only the 5xx responses.
Logs and traces are records of individual things that happened. They’re the right tool when you need to know what happened to one request. But they’re expensive to keep at full volume and slow to aggregate across millions of events.
Metrics are pre-aggregated by design. A burst of a million requests becomes a handful of data points per series, which means you can afford to measure everything, keep it always on, and chart a month of history instantly. That makes metrics the right tool for:
A queue that grows by 2% an hour never shows up in logs. Every individual job is processed fine, every trace looks healthy, and three weeks later the backlog takes the system down. A gauge on queue depth makes that failure visible on day one as a line that isn’t flat.
The same goes for error budgets and latency. A rate on an error counter divided by a rate on a request counter is your error ratio, and a p95 on a duration histogram is what your slowest users feel. Watching those two numbers per service catches most production regressions before your customers report them.
http.server.duration and Prometheus style names like jobs_processed_total both work; mixing conventions inside one system makes metrics hard to find.duration_ms or a unit field saves everyone from guessing.Most teams keep metrics in a separate system from everything else, so answering “did that latency spike affect signups?” means tab switching and timestamp matching. In PostHog, metrics live alongside your logs (opens in a new tab), traces (opens in a new tab), product analytics, and session replays, in the same project with the same query language.
Everything is queryable as SQL through the posthog.metrics table, and the PostHog MCP server (opens in a new tab) exposes metrics to AI agents, so your tools can chart, compare, and investigate metrics for you. When you chart a metric that has moved against its baseline, an anomaly badge surfaces the change and the label values behind it, and the raw samples stay linked to the logs and traces that explain them.
Ask PostHog AI
HelpfulCould be better