> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nerves-hub.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Audit log

> See what NervesHub records about changes to devices, deployment groups, products and organizations, where to read it, and how long it is kept.

NervesHub writes an audit log entry when a person, a device or a [deployment group](https://docs.nerves-hub.org/setup/deployments.md) does something worth tracing later: a reboot, a firmware push, a [release](https://docs.nerves-hub.org/deployments/releases.md) approval, a webhook change. Use it to answer who did what to a device or a deployment group, and when.

## What an entry holds

Each entry records:

* the actor: a user, a device, or a deployment group acting on its own,
* the resource it acted on,
* a description, cut at 500 characters,
* when it happened.

Actions taken from Slack are recorded as the linked NervesHub user, with "from Slack" in the description. See [Slack](https://docs.nerves-hub.org/outbound/slack.md).

> [!NOTE]
>
> Product API keys can also be the actor of an entry. They are on the main branch but in no tagged release as of NervesHub 2.5.4. See [CI/CD](https://docs.nerves-hub.org/outbound/ci-cd.md).

## What is recorded

| About | Entries |
| - | - |
| A device | Reboot, identify and reconnect requests. [Support script](https://docs.nerves-hub.org/management/support-scripts.md) runs. Firmware pushed to the device, updates sent by a deployment group, updates the device asked for, and [archives](https://docs.nerves-hub.org/updates/archives.md) sent. Update attempts and their outcome: updated, failed, ignored, rescheduled or blocked. Firmware validated. Firmware metadata changes. Tag changes. Moves between products and into deployment groups. Updates turned on or off, the [update mode](https://docs.nerves-hub.org/updates/device-managed-updates.md), and the [penalty box](https://docs.nerves-hub.org/deployments/rollout-controls.md) being cleared. Shared secrets created and deactivated. |
| A deployment group | The group being created, changed, turned on or off, or deleted. New releases, and changes to a release's [connecting code](https://docs.nerves-hub.org/deployments/connecting-code.md) or required setting. A [workflow step](https://docs.nerves-hub.org/concepts/deployment-workflows.md) waiting for approval, failing, or being approved, retried or skipped. Devices that no longer match the group. |
| A product | Support scripts created, updated and deleted. Firmware deleted. Reported errors resolved, muted and reopened. An [extension](https://docs.nerves-hub.org/extensions/overview.md) set for every device. |
| An organization | Webhooks created, updated and deleted, and their signing secret regenerated. Slack workspaces connected, disconnected or removed. Slack, Teams and Discord channels added, changed and removed. The two-factor authentication requirement turned on or off. |

## Where to see it

### A device

Open the device and select the **Activity** tab. Entries are listed newest first, grouped by day. The tab shows entries where the device is the actor or the resource.

Click **Download CSV** to export the device's entries.

### A deployment group

Open the deployment group and select the **Activity** tab. Click **Download CSV** to export the group's entries.

Members of a [role limited to tagged devices](https://docs.nerves-hub.org/access/roles.md#roles-limited-to-tagged-devices) cannot open deployment groups, so they cannot see this tab.

### Products and organizations

Entries about a product or an organization are recorded, but as of NervesHub 2.5.4 no page in the web UI and no API endpoint lists them.

### The CSV export

The export has one row per entry, with these columns: `id`, `org_id`, `actor_id`, `actor_type`, `description`, `kind`, `params`, `resource_id`, `resource_type`, `reference_id` and `inserted_at`.

`kind` classifies the entries a device's **Activity** tab shows. Entries written before kinds existed, and entries about other resources, have none.

## Retention

How long entries are kept is decided by the instance.

| Instance setting | Default | Effect |
| - | - | - |
| `TRUNCATE_AUDIT_LOGS_ENABLED` | `false` | When `false`, audit log entries are kept forever. When `true`, NervesHub deletes old entries every hour. |
| `TRUNCATE_AUDIT_LOGS_DEFAULT_DAYS_KEPT` | `30` | Days of audit log kept for an organization that has no retention of its own. |

Each organization can have its own number of days, which takes the place of the instance default. Neither the web UI nor the API sets it. It is a value on the organization's record (`audit_log_days_to_keep`), so ask whoever runs your instance.

Truncation deletes entries for good. If you need them for longer, export them first.

See [Feature prerequisites](https://docs.nerves-hub.org/hosting/feature-prerequisites.md#retention) for the instance side.

## Related pages

* [Roles and permissions](https://docs.nerves-hub.org/access/roles.md)
* [Two-factor authentication](https://docs.nerves-hub.org/access/two-factor.md)
* [Webhooks](https://docs.nerves-hub.org/outbound/webhooks.md)
* [Feature prerequisites](https://docs.nerves-hub.org/hosting/feature-prerequisites.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.