# Log rollups

A rollup turns lines into a metric. It counts the lines matching a query each minute, or adds up or averages a number in their context, and keeps the per-minute result for longer than the raw logs: 30 days on Free, 365 on Pro, 730 on Business. Raw logs are kept 3, 14 or 30 days.

Open the source's **Settings**, then **Log rollups**.

## Making one

- **Name**: lowercase letters, digits and underscores. The rollup becomes the metric `rollup.name`.
- **What to keep**: a **count** of matching lines, the **sum** of a context field, or its **average**.
- **Lines matching**: the [query language](https://tailcove.dev/docs/query-language), without regular expressions. Empty means every line. A line that matches but has no usable number for a sum or average still counts as a match and adds nothing to the sum.
- **Context field**: a number at the top of the line's context or nested under it (`http.duration_ms`). Numbers written as text (`"35"`) count.

A rollup starts with the next lines that arrive. It does not look back at lines already stored. The number of rollups per source depends on your plan.

## Using one

A rollup is a metric to the rest of Tailcove. In a dashboard, add a **Metric** widget and choose `rollup.name`; its time range can reach back as far as your plan keeps rollups, past the raw logs. In an alert, choose a metric alert on `rollup.name` with the aggregate you want (for a count, `sum` over the window is the number of lines).

Rollups work on the lines as they are stored: a [transform rule](https://tailcove.dev/docs/transform-rules) that dropped or redacted a line or field is already applied, so a redacted field is never summed and a dropped line is never counted.

## Good to know

- The name `rollup.` is reserved: a metric sent to the metrics endpoint with that start is ignored.
- Deleting a rollup keeps its numbers until they expire. A rollup created later with the same name continues the series.
- Changing a rollup's query or field applies from the next lines on; earlier minutes keep what they had.
- A dashboard time window is at most 31 days, positioned anywhere within the rollup retention.
