# Analytics

An agent's **Dashboard** section (`?tab=analytics`, called Analytics before 1.3.4) sits in its **Overview** group - the per-agent counterpart of the organization [Dashboard](https://docs.polyant.ai/admin-panel/dashboard). The same KPIs and time-series charts, scoped to this one agent.

It shares the Overview group with **[Status](https://docs.polyant.ai/admin-panel/instances#status)**, and they are two sections rather than one page on purpose: they answer the same question ("how is this agent doing?") at two scales - Status is whether the agent works *right now*, read at a glance; these are what it *did* over a period, read with a date range and a page of charts. Stacked together, the first became a preamble and the charts started below the fold.

Reading it needs `analytics:read`.

The same component renders the organization dashboard, from the organization-wide aggregate rather than one agent's. The response shape is identical.

## What is shown

- **KPI tiles** - **Total cost**, **Conversations**, **Messages**, **Response time** and **Cache hit rate**, each with its daily shape drawn along the bottom of the tile. **Response time** is the median (p50) of a turn's end-to-end time, the same figure as the response time chart. Each tile compares the period with the previous period of the same length: a percentage marked **vs previous period**, or **Unchanged**. The cache hit rate moves in points (`+4 pt`), since a percentage of a rate would overstate the change. When the previous period was empty, or the change is beyond 999% and the exact figure says nothing, the tile shows the previous figure instead, as **before: N**.
- **Cost Trend** by day, with the previous period's daily cost drawn beneath it, and **Model Usage**, with the split **By tier** inside the same card. In **Model Usage**, the service calls (titles, summaries, checks), which run on a fast-tier model nobody chose for the agent, are folded into one entry labelled **Service calls (titles, summaries, checks)** rather than named as a model.
- **Conversations** by day, with the **Messages per conversation**, and **Channels**. Models, tiers and channels are drawn as ranked bars.
- **Response time** - the daily **Typical (p50)** and **Slow (p95)** of a turn's end-to-end time, from the pipeline traces. The per-phase timings of one turn (context preparation, tool building, the LLM call, the total) are on its [Message details](https://docs.polyant.ai/admin-panel/conversations#message-details).
- **Tools** - one table of the most used tools, with their **Calls**, **Success** rate and **Slow (p95)** time. A tool the traces hold no timing for shows a dash.
- **When people write** - the messages people sent, as a grid of weekdays by hours of the day.
- **Cost estimate** - derived from the AI gateway's per-model pricing table.

The organization and workspace dashboards add **Agent Comparison**.

Through the API, the response carries the previous period's figures as `overview.previousPeriod` (with `overview.trends` holding the percentage changes, `null` where the previous figure is zero), the previous period's daily cost as `previousDailyCost`, and the response-time figures as `latency.overview` and `latency.previousOverview`. Tool timings are `latency.toolTimings`. Since 1.3.5 `hourlyDistribution` has 168 rows, one per weekday and hour, each with `weekday` (0 is Monday), `hour` and `count`.

## Cost counts every billed call

A model call that dies at the provider - an expired key, a rate limit, an overloaded model, a timeout - is recorded rather than dropped, with its **error class** and never the provider's error text. That makes "is this agent erroring?" a question the data can answer; it is reported on the agent's [Status](https://docs.polyant.ai/admin-panel/instances#status) section rather than here.

The aggregates split in two:

- **Cost and token totals count every call the provider billed.** A multi-step call that fails partway was billed for the steps it completed, and its row carries that cost. A turn **pre-empted** (cancelled and restarted because the user sent a follow-up mid-answer) is logged as `aborted` with what its model calls had been billed. Embedding calls (knowledge ingestion, memory extraction, retrieval) are logged with their tokens and cost. Totals are summed in double precision, so long periods keep their precision.
- **Call counts and response times count only model calls that returned.** A failed call does not drag the average latency down, a pre-empted turn is neither answered nor failed, and an embedding call, which returns in a fraction of a second beside every retrieval, stays out of both.

Costs recorded before 1.2.0 can read lower than the provider's bill for the same traffic: pre-empted turns and embedding calls left no row, and Amazon Nova was priced at the US rate instead of the eu-south-1 rate it is billed at. How each call is priced is described in [AI Gateway](https://docs.polyant.ai/concepts/ai-gateway#logging-every-call-lands-in-ai_logs).

### Why the spend cap shows a different total

The [spend caps](https://docs.polyant.ai/admin-panel/spend-cap) (managed services) count the same billed calls, but their windows differ: a cap's day or month follows the agent's time zone, while this page renders in your browser's.

## Time range

Three quick filters: 24 hours, 7 days, 30 days. A custom date-range picker is available for longer windows. All times are rendered in the user's browser timezone; the underlying data is stored UTC. With managed services **When people write** is also cut in the viewer's time zone: the panel sends it as `tz` (an IANA name such as `Europe/Rome`; an unknown one is a `400`), and without it the hours are UTC, as they always are in the open-source build.

## When does data appear

A fresh instance shows empty charts until the first message goes through. Latency tracing is fire-and-forget and buffered: expect data to land within ~5 seconds of a request completing.
