> For the complete documentation index, see [llms.txt](https://wiki.datadike.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.datadike.com/sonar/administration/audit/audit-trail.md). Agents can also search and read this documentation through its [MCP server](https://wiki.datadike.com/~gitbook/mcp).

# Audit trail

What SONAR records in Reports & Audits › Audits and in a device's Audits tab: logins, object changes, commands, scripts, remote sessions and bulk actions, with filters, export and retention.

## What this is and when to use it

The audit trail is the list of actions that people perform through the console and the API: who signed in, who changed which object, who ran a command or a script on which device, who opened a remote session, who launched a bulk action. Each entry keeps the user, the time, the source address, a message and, for object changes, the values before and after the change.

Use it to answer a question about the past: who removed that device, who changed the default alert template, which scripts ran on `WS-0001` last week, who failed to sign in this morning.

The same records are shown in two places:

| Where                         | What it shows                                                      |
| ----------------------------- | ------------------------------------------------------------------ |
| **Reports & Audits › Audits** | The whole trail, with scope, user, action, object and time filters |
| The device's **Audits** tab   | Only the entries recorded against that device                      |

## Before you start

* Your role needs **View Audit Logs** (group **Logs** in **Admin Center › Roles**). Without it, **Audits** does not appear in the menu and the device's **Audits** tab returns no data. See [Roles and permissions](https://wiki.datadike.com/sonar/administration/identities/roles.md).
* Entries older than the audit retention period are no longer there to find. Check **Admin Center › Settings › Retention** first, see [Data retention](https://wiki.datadike.com/sonar/administration/settings/retention.md).

## What gets recorded

| Action                                               | Recorded when                                                                              | Typical message                                                                        |
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| **Login**                                            | A user signs in to the console                                                             | `jdoe logged in successfully`                                                          |
| **Failed Login**                                     | A password or a two-factor code is rejected                                                | `jdoe failed to login: Credentials were rejected`, or `...: Two Factor token rejected` |
| **Add Object**, **Modify Object**, **Delete Object** | A user creates, changes or deletes an object through the console or the API                | `jdoe modified client CLIENT-A`                                                        |
| **Agent Install**                                    | A new agent registers with SONAR                                                           | Names the new device, for example `... installed new agent WS-0001`                    |
| **Execute Command**                                  | A command is sent to a device                                                              | `jdoe issued powershell command on WS-0001.`                                           |
| **Execute Script**                                   | A script is run on a device, or tested                                                     | `jdoe ran script: "Clear temp" on WS-0001`                                             |
| **Remote Session**                                   | A user opens remote access to a device                                                     | Names the user and the device                                                          |
| **Bulk Action**                                      | A bulk command, script or patch action runs, or devices are moved between sites in bulk    | `jdoe executed bulk script: Clear temp on all agents within client: CLIENT-A`          |
| **URL Action**                                       | A URL action is run against a device, client or site, or a URL action or webhook is tested | Names the URL and the target                                                           |

Object changes cover devices, clients, sites, users, roles, API keys, scripts, checks, automated tasks, automation policies, patch policies, alert templates, the settings under **Settings**, custom fields, key store entries, URL actions, webhooks and access policies. A change is written only when a value really changed; saving a form without changes adds nothing.

When a device is removed, the reason typed in the confirmation is appended to the **Delete Object** message.

Step-up MFA checks are also recorded. They appear with the action **Mfa Stepup** or **Failed Mfa Stepup**.

{% hint style="info" %}
The trail records what people do. Data that agents report on their own, such as check results, inventory and software lists, is not an audit entry. Those live on the device, see [Device details](https://wiki.datadike.com/sonar/administration/devices/device-details.md).
{% endhint %}

## Steps

### Search the whole trail

1. Open **Reports & Audits › Audits**. The page opens on **Sonar Audits**, showing the last week, newest first.
2. Under **Scope**, choose **Clients** or **Agents**, then pick one or more entries in the **Clients** or **Agent** list. Leave both empty to search everything.
3. Under **User**, pick one or more users in **Users**.
4. Under **Actions**, click the pills you want: **Login**, **Failed Login**, **Add**, **Modify**, **Delete**, **Agent Install**. A second click turns a pill off.
5. Under **More Actions**, pick further actions in **Action**, such as **Execute Command**, **Execute Script**, **Remote Session**, **Bulk Action** or **URL Action**.
6. Under **Object**, pick the object types to keep, such as **Client**, **User** or **Core Settings**.
7. Under **Time Window**, pick the period, from **Today** to **All Time**.
8. Click **Apply Filters**.
9. Click a row to open **Audit details** with the recorded values.
10. To take the rows away, click the download icon (**Export**) above the table.

### Review one device

1. Select the device in the device list to open its panel.
2. Open the **Audits** tab.
3. Narrow with **Users**, **Action**, **Time** or the action pills. The list refreshes as soon as a filter changes.
4. Click a row to open **Audit details**.

## What you should see

A table of entries with the time, the user, the action as a coloured badge (green for additions and installs, yellow for changes, red for deletions and failed logins, blue for the rest), the object type, the message and the source address. For entries recorded against a device, **Client** and **Site** show where that device belongs.

Below the table, a selector sets 25, 50, 100, 500 or 1000 rows per page, and **Page 1 of N** with the arrows moves between pages.

**Audit details** opens on the right with the message as its subtitle and two blocks, **Before** and **After**. An **Add Object** entry has only an **After** value, a **Delete Object** entry only a **Before** value, and a **Modify Object** entry both, so you can compare them field by field. Entries with nothing to show read **No data**. For access policies the blocks read **Content restricted**; the policy's own **Audit Trail** keeps its change history, see [Access policies](https://wiki.datadike.com/sonar/administration/access/access-policies.md).

The export is a CSV file named `export.csv` with the columns of the table. It holds the rows of the page currently loaded.

## How to verify it worked

1. Sign out, sign in once with a wrong password, then sign in correctly.
2. Open **Reports & Audits › Audits**, set **Time Window** to **Today**, click the **Login** and **Failed Login** pills, then **Apply Filters**. Both attempts must be listed under your username, with your address in **Client IP**.
3. Change one value in **Admin Center › Settings › General**, for example **Default date format**, and save.
4. Back in **Audits**, turn the action pills off, pick **Core Settings** under **Object** and apply. A **Modify Object** entry must appear; its **Audit details** show the old value under **Before** and the new one under **After**.
5. Send a harmless command to a test device, then open that device's **Audits** tab. An **Execute Command** entry must be at the top.

## Common errors

| Symptom                                                         | Cause                                                                  | Fix                                                                                                                        |
| --------------------------------------------------------------- | ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| The entry you expect is not listed                              | The **Time Window** excludes it                                        | Widen it, up to **All Time**                                                                                               |
| The entry is missing even with **All Time**                     | It is older than the audit retention period                            | Entries past the period are deleted; raise **Audit Logs (days)** in **Admin Center › Settings › Retention** for the future |
| Logins and settings changes disappear when a client is selected | **Clients** and **Agent** match only entries recorded against a device | Empty the **Clients** or **Agent** list and apply again                                                                    |
| **Audits** is missing from the menu                             | The role lacks **View Audit Logs**                                     | Grant it in **Admin Center › Roles**                                                                                       |
| The export has fewer rows than the total                        | The export takes the page currently loaded                             | Set 1000 rows per page and export each page                                                                                |
| Nothing is recorded for data an agent sent                      | The trail records actions by users and API keys                        | Check the device's own tabs instead                                                                                        |

## Field reference

### Filters

| Filter                    | What it does                                                   | Values                                                                                                                                                      | Default       |
| ------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| **Scope**                 | Chooses whether you narrow by client or by device              | **Clients**, **Agents**                                                                                                                                     | **Clients**   |
| **Clients**               | Keeps entries recorded against devices of the selected clients | One or more clients                                                                                                                                         | Empty (all)   |
| **Agent**                 | Keeps entries recorded against the selected devices            | One or more devices                                                                                                                                         | Empty (all)   |
| **Users**                 | Keeps entries made by the selected users                       | One or more users                                                                                                                                           | Empty (all)   |
| **Actions** pills         | Quick selection of the most common actions                     | **Login**, **Failed Login**, **Add**, **Modify**, **Delete**, **Agent Install**                                                                             | None selected |
| **Action** (More Actions) | The full list of actions, combined with the pills              | Login, Failed Login, Add Object, Modify Object, Delete Object, Agent Install, Bulk Action, Execute Command, Execute Script, Remote Session, URL Action      | Empty (all)   |
| **Object**                | Keeps entries about the selected object types                  | Agent, Automated Task, Bulk Actions, Core Settings, Check, Client, Policy, Site, Script, User, Patch Policy, Alert Template, Role, URL Action, Custom Field | Empty (all)   |
| **Time**                  | Period covered                                                 | **Today**, **Last 3 Days**, **Last Week**, **Last 2 Weeks**, **Last Month**, **Last 3 Months**, **Last 6 Months**, **Last Year**, **All Time**              | **Last Week** |

In a device's **Audits** tab, **Scope** and **Object** are not shown: the device is the scope.

### Columns

| Column               | What it holds                                                      |
| -------------------- | ------------------------------------------------------------------ |
| **Time**             | When the action happened, in your date format                      |
| **Username**         | Who performed it. For a login failure, the username that was typed |
| **Action**           | The kind of action                                                 |
| **Object**           | The type of object involved                                        |
| **Message**          | A sentence describing the action, with the object or device name   |
| **Client IP**        | The address the request came from, when it was recorded            |
| **Client**, **Site** | Where the device belongs, for entries recorded against a device    |

## Related pages

* [Reports](https://wiki.datadike.com/sonar/administration/audit/reports.md): build documents from SONAR data
* [Data retention](https://wiki.datadike.com/sonar/administration/settings/retention.md): how long audit entries are kept
* [Roles and permissions](https://wiki.datadike.com/sonar/administration/identities/roles.md): granting **View Audit Logs**
* [Device details](https://wiki.datadike.com/sonar/administration/devices/device-details.md): the device panel and its tabs
* [Access policies](https://wiki.datadike.com/sonar/administration/access/access-policies.md): the policy's own audit trail
