# Activity log

*Settings > Activity*, for admins, says who signed in, changed what, and did what to which machine.

## What is written

- Sign-ins and sign-outs, wrong passwords and codes.
- Every change of the settings, accounts, tokens, machines and saved actions.
- Every action on a machine, and one that failed.
- Live views opened and ended; keyboard and mouse taken, taken over and given back; a server's console opened.
- Alerts, exports and imports, and downloads of this log.

Never a password, a key pressed, or text that was typed. An account's live views write 120 entries an hour at the most, so a script opening them in a loop cannot push older entries out.

## Search and download

- Search by words, and narrow to sign-ins, actions, changes or alerts, to a machine, to an account or token, and to a time.
- Download as a table (CSV) or as JSON lines, all of it or what is shown.
- Enlarged, a tile shows an admin the last three things done to its machine. *All of it* opens the log there.

## Where it is kept

Text files in the data folder: `audit.log`, and before it `audit.log.1` to `audit.log.9`, one JSON entry a line, never rewritten. grep and tail read them while qKVM is down. An index beside them, `audit.sqlite`, makes a search of a long log fast.

| Option | What it does | Default |
|---|---|---|
| `activity_mb` | megabytes kept, 10 to 100000, in ten files | 50 |

50 MB holds about five months of a busy wall (64 machines, three people at work). Change it with [Advanced server settings](https://qkvm.com/docs/web/advanced-server-settings).

## Proof against editing

Each line carries its place in a chain, signed with a key kept in the wall's sealed settings. A line changed, taken out, moved or put in shows when the log is checked. The wall writes seals of the chain as it starts and stops, every hour, and before the oldest file goes.

Heads of the chain kept outside the wall show even a log written anew by somebody who holds the key:

- `--audit-syslog` sends every line, with its chain, to a syslog collector.
- An alert destination with *Daily seal of the activity log* ticked is sent `qKVM activity log seal: line N head H` once a day.

## Check the log

On the page, *Check the log* (beside the downloads) says intact, or broken at line N and why. Away from the wall:

```
python -m qkvm.checklog audit.log.9 audit.log.8 audit.log
```

Give the files oldest first, or a download as JSON lines. Add `--data-dir DATA` or `--key-file KEY` to check each signature, `--heads FILE` to hold the log to heads kept outside, and `--part` for a download.

| Exit status | Means |
|---|---|
| 0 | intact |
| 1 | broken |
| 2 | could not check |
| 3 | intact where it is chained, with lines not proved |
| 4 | with `--part`: intact as far as it goes |

A check cannot catch somebody who holds the running wall, or the data folder together with its storage key. Only heads kept outside the wall show that.

## For a program

`GET /api/v1/audit?device=ID&limit=100` answers what the log says of one machine, for an admin. The rest of the log's requests are the page's own.

## Related

- [Accounts and roles](https://qkvm.com/docs/web/accounts)
- [History](https://qkvm.com/docs/web/history)
- [How it is protected](https://qkvm.com/docs/web/how-it-is-protected)
- [Alert destinations](https://qkvm.com/docs/web/alert-destinations)

[Full reference](https://github.com/qkvm/qkvm/blob/main/GUIDE.md#activity-log)
