# Analyze

Analyze answers the questions a list of log lines cannot: how many errors per
host, what the 95th percentile of `duration_ms` is for each route, how a count
moves over the last day. Open it with the **Analyze** button next to the search
bar on a source's Logs page; the search and the time range come along.

## The form

| Setting      | Meaning                                                                                  |
| ------------ | ---------------------------------------------------------------------------------------- |
| Search       | Which lines to look at, in the [query language](https://tailcove.dev/docs/query-language)                    |
| Calculate    | `count`, `avg`, `sum`, `min`, `max`, or a percentile: `p50`, `p95`, `p99`                |
| Of field     | The `context` key to calculate over; not needed for a count                              |
| Group by     | `level`, `host` or a `context` key; leave empty for one number or one line               |
| Over time    | A line per group (at most 10 groups) instead of a ranked list                            |
| In total     | One number, or with a group the ranked list of the top groups (at most 50)               |

A calculation over a field looks only at lines where that field is a number. A
line without it, or with text in it, is skipped rather than counted as zero.
Percentiles are estimates (t-digest), accurate to a fraction of a percent on
large ranges.

Click a group in the ranked list to add it to the search and run the question
again for just that group. **Back to logs** opens the same search in the log
list. Everything in the form is in the page's address, so a link to Analyze
shows the same result to a teammate.

## Limits

Analyze runs on the same data as search, so it is held to limits that keep one
question from slowing everyone down:

- One group-by key, at most 50 groups in a list and 10 lines in a chart.
- The range is cut to the source's retention; a note says when that happened.
- Each query stops after 8 seconds or when it would read too many rows. The
  message says to narrow the time range or add a filter to the search.
- A team can run three analyses at once. A fourth is answered with "Try again
  in a moment" instead of waiting.

An analysis never runs exactly as you typed it. The form is checked first
and every value is passed as a parameter, so a field name or a search can not
change what the query does.
