Audit Log
The audit log records actions that users perform on platform entities — devices, assets, dashboards, rule chains, customers, users, and more. Each record shows who performed the action, on which entity, when it happened, and whether it succeeded. Use the audit log to monitor activity, investigate incidents, and support security and compliance reviews.
What Is Recorded
Section titled “What Is Recorded”The audit log records actions that users perform through the UI or the REST API, including actions that fail with an error. Requests refused for lack of permission are generally not recorded. The exception is creating or updating a device, asset, entity view, customer, or dashboard: a refused attempt is recorded as a failed Added or Updated.
- Entities. Creating, updating, and deleting entities.
- Ownership and groups. Assigning entities to customers, edges, or groups, changing their owner, and making groups public or private.
- Relations. Adding, updating, and deleting relations, recorded on both related entities.
- Data. Updating or deleting attributes and telemetry, sending RPC commands, and calling the rule engine REST API.
- Alarms. Creating, updating, acknowledging, clearing, assigning, unassigning, commenting on, and deleting alarms. Acknowledging, clearing, assigning, or unassigning an alarm also adds a system comment, recorded as a separate Added comment record.
- Sign-in. Logins and explicit logouts; an expired session isn’t recorded. A wrong password or two-factor authentication code is recorded as a Login with status Failure. When too many wrong passwords lock the account, a Lockout record is added as well. Login attempts with an email that doesn’t exist aren’t recorded. SMS messages sent for two-factor authentication are recorded as SMS sent.
It doesn’t record what happens without a user: telemetry and attributes that devices send over MQTT, HTTP, CoAP, or other transports, and changes made by rule nodes, integrations, scheduled events, or calculated fields. The exception is device provisioning, which is recorded with the device name in the User column.
Requests made with an API key are recorded under the email of the user who owns the key. Creating or deleting API keys isn’t recorded.
The audit log only stores records; it doesn’t send alerts. To be notified when entities are created, updated, or deleted, use a notification rule with the Entity action trigger.
Open the Audit Log
Section titled “Open the Audit Log”Open Security ⇾ Audit logs from the left-hand menu. The page lists records from the selected time range (by default, the last day), with the most recent first.
- Tenant administrators see the records of the whole tenant.
- Customer users see the records of their customer: actions of the customer’s own users, and entity actions (such as create, update, delete, assign, and alarm actions) on the customer’s entities, including those made by tenant administrators. Attribute, telemetry, and RPC actions of tenant administrators, failed actions of tenant administrators, and records of sub-customers are not included.
System administrators see only the records of system administrators’ own actions, such as logins, tenant profile changes, and changes to tenant administrator accounts. Creating, updating, or deleting tenants is not recorded, and tenants’ records are not shown.
Audit Log Columns
Section titled “Audit Log Columns”Each row is one record. Click a column header to sort by it.
| Column | Description |
|---|---|
| Timestamp | When the action occurred. |
| Entity type | The type of entity acted upon, for example Device, Asset, Dashboard, Rule chain, Customer, or User. Alarm actions, except comments, are recorded against the alarm’s originator, so they show its type, for example Device. Alarm comments show Alarm. |
| Entity name | The name of the entity. For a created or updated alarm and for alarm comments, the alarm type; for other alarm actions, the originator’s name. |
| User | The email of the user who performed the action, or the device name for device provisioning. |
| Type | The action performed, for example Added, Updated, Deleted, Assigned to Customer, or Login. |
| Status | Success or Failure. |
Search and Filter
Section titled “Search and Filter”Use the controls above the table to narrow down the list:
- Time range — click the time range button (for example, last 1 day) to choose a preset period or a custom date range.
- Audit log filter — show only selected Audit log types, for example Login or Deleted.
- Search — click the search icon and enter text. The search runs on the server, ignores case, and matches part of the entity name, user, entity type, type, or status. Entity type, type, and status are matched by their stored names, such as
RULE_CHAIN,ASSIGNED_TO_CUSTOMER, orFAILURE: search forrule_chain, not Rule chain. Searching for a user’s email returns the user’s own actions and also actions on that user’s account. - Refresh — reload the list using the current time range and filters.
View Record Details
Section titled “View Record Details”Click the Details button (⋅⋅⋅) at the end of a row. The Audit log details dialog shows the Action data: the JSON payload of the action. What it contains depends on the action:
- Added and Updated — the entity as saved, that is, its state after the action. Dashboard records leave out the dashboard configuration.
- Login, Logout, and Lockout — the client IP address, browser, operating system, and device, plus, for OAuth 2.0 logins, the name of the OAuth 2.0 client used.
- Deleted — only the entity ID.
- Other actions store their own details, for example the customer an entity was assigned to, the attribute keys and values, or the RPC method and parameters.
For a failed action, the dialog also shows the Failure details.
A record holds only the state after the action. To see what an update changed, compare its Action data with the entity’s previous Added or Updated record, for example on the entity’s Audit logs tab.
Audit Logs on Entity Pages
Section titled “Audit Logs on Entity Pages”Most entity details pages have an Audit logs tab with the records of that entity: devices, assets, entity views, dashboards, edges, customers, users, device and asset profiles, rule chains, integrations, data converters, JavaScript library resources, roles, report templates, and entity groups. For system administrators, tenant profiles have it too.
- On most entities, the tab shows actions on that entity, including actions on alarms it originated, except alarm comments.
- On a customer, it shows the records of that customer, as described in Open the Audit Log.
- On a user, it shows actions on the user account, such as updates, logins, failed logins, lockouts, and logouts — not the user’s actions on other entities. To see those, search for the user’s email on the Audit logs page, or use
GET /api/audit/logs/user/{userId}(see REST API).
Failed attempts to create, update, or delete an entity aren’t linked to the entity, so they appear only on the Audit logs page. Failed logins, failed attribute or telemetry changes, and failed RPC calls do appear on the entity’s or user’s tab.
REST API
Section titled “REST API”All audit log endpoints are GET requests that return records page by page:
| Endpoint | Returns |
|---|---|
/api/audit/logs |
All records the caller can see: the tenant’s, or the customer’s for customer users |
/api/audit/logs/entity/{entityType}/{entityId} |
Actions on one entity |
/api/audit/logs/customer/{customerId} |
The records of one customer |
/api/audit/logs/user/{userId} |
Actions performed by one user |
System administrators can use only /api/audit/logs and /api/audit/logs/entity/{entityType}/{entityId}.
All endpoints take these parameters:
- Required:
pageSizeandpage(zero-based). - Optional:
startTimeandendTime(in milliseconds),actionTypes(a comma-separated list, for exampleLOGIN,LOCKOUT),textSearch,sortProperty(createdTime,entityType,entityName,userName,actionType, oractionStatus), andsortOrder(ASCorDESC).
Unlike the UI, the API returns all records up to now when startTime and endTime are omitted, and without sortProperty the records aren’t in time order: pass sortProperty=createdTime&sortOrder=DESC to get the newest first. See the REST API reference for details.
Configuration
Section titled ConfigurationAudit logging is configured in thingsboard.yml or through the matching environment variables:
# Audit log parameters# Enables audit logging, configures per-entity-type logging levels, and optionally exports logs to an external sink such as Elasticsearch.audit-log: # Enable/disable audit log functionality. enabled: "${AUDIT_LOG_ENABLED:true}" # Logging levels per each entity type. # Allowed values: OFF (disable), W (log write operations), RW (log read and write operations) logging-level: mask: "device": "${AUDIT_LOG_MASK_DEVICE:W}" # Device logging levels. "asset": "${AUDIT_LOG_MASK_ASSET:W}" # Asset logging levels. "dashboard": "${AUDIT_LOG_MASK_DASHBOARD:W}" # Dashboard logging levels. "widget_type": "${AUDIT_LOG_MASK_WIDGET_TYPE:W}" # Widget type logging levels. "widgets_bundle": "${AUDIT_LOG_MASK_WIDGETS_BUNDLE:W}" # Widget bundles logging levels. "customer": "${AUDIT_LOG_MASK_CUSTOMER:W}" # Customer logging levels. "user": "${AUDIT_LOG_MASK_USER:W}" # User logging levels. "rule_chain": "${AUDIT_LOG_MASK_RULE_CHAIN:W}" # Rule chain logging levels. "alarm": "${AUDIT_LOG_MASK_ALARM:W}" # Alarm logging levels. "integration": "${AUDIT_LOG_MASK_INTEGRATION:W}" # Integration logging levels. "converter": "${AUDIT_LOG_MASK_CONVERTER:W}" # Converter logging levels. "entity_group": "${AUDIT_LOG_MASK_ENTITY_GROUP:W}" # Entity Group logging levels. "scheduler_event": "${AUDIT_LOG_MASK_SCHEDULER_EVENT:W}" # Scheduler Event logging levels. "blob_entity": "${AUDIT_LOG_MASK_BLOB_ENTITY:W}" # Blob entity logging levels. "entity_view": "${AUDIT_LOG_MASK_ENTITY_VIEW:W}" # Entity view logging levels. "device_profile": "${AUDIT_LOG_MASK_DEVICE_PROFILE:W}" # Device profile logging levels. "asset_profile": "${AUDIT_LOG_MASK_ASSET_PROFILE:W}" # Asset profile logging levels. "edge": "${AUDIT_LOG_MASK_EDGE:W}" # Edge logging levels. "tb_resource": "${AUDIT_LOG_MASK_RESOURCE:W}" # TB resource logging levels. "ota_package": "${AUDIT_LOG_MASK_OTA_PACKAGE:W}" # Ota package logging levels. "calculated_field": "${AUDIT_LOG_MASK_CALCULATED_FIELD:W}" # Calculated field logging levels. "ai_model": "${AUDIT_LOG_MASK_AI_MODEL:W}" # AI model logging levels. "role": "${AUDIT_LOG_MASK_ROLE:W}" # Roles logging levels. "group_permission": "${AUDIT_LOG_MASK_GROUP_PERMISSION:W}" # Group permission logging levels. "report_template": "${AUDIT_LOG_MASK_REPORT_TEMPLATE:W}" # Report template logging levels. sink: # Type of external sink. possible options: none, elasticsearch type: "${AUDIT_LOG_SINK_TYPE:none}" # Name of the index where audit logs are stored # Index name could contain next placeholders (not mandatory): # @{TENANT} - substituted by tenant ID # @{DATE} - substituted by current date in format provided in audit_log.sink.date_format index_pattern: "${AUDIT_LOG_SINK_INDEX_PATTERN:@{TENANT}_AUDIT_LOG_@{DATE}}" # Date format. Details of the pattern can be found here: # https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html date_format: "${AUDIT_LOG_SINK_DATE_FORMAT:YYYY.MM.dd}" scheme_name: "${AUDIT_LOG_SINK_SCHEME_NAME:http}" # http or https host: "${AUDIT_LOG_SINK_HOST:localhost}" # Host of external sink system port: "${AUDIT_LOG_SINK_PORT:9200}" # Port of external sink system user_name: "${AUDIT_LOG_SINK_USER_NAME:}" # Username used to access external sink system password: "${AUDIT_LOG_SINK_PASSWORD:}" # Password used to access external sink systemenabled (AUDIT_LOG_ENABLED, true by default) turns audit logging on or off. When it’s false, nothing is recorded, and existing records are hidden too: the Audit logs page, the entity tabs, and the REST API return nothing. The cleanup described in Storage and Retention keeps running.
Logging Levels
Section titled Logging LevelsThe logging-level.mask section sets the logging level for each entity type, through the AUDIT_LOG_MASK_<TYPE> environment variables (for tb_resource, AUDIT_LOG_MASK_RESOURCE):
| Level | Description |
|---|---|
OFF |
Logging disabled for this entity type. |
W |
Log write actions, for example create, update, delete, and login. |
RW |
Also log the two read actions: Credentials read and Attributes read. |
Every entity type in the mask defaults to W. For tenant and customer users, entity types that aren’t listed in the mask, such as secrets, OAuth 2.0 clients, domains, mobile apps, and agents, aren’t logged at all. Write actions of system administrators, such as logins and tenant profile changes, are always logged, whatever the mask says.
Records are filed under the entity they concern, so the mask of that entity type applies:
- Login, logout, and lockout records belong to the user, so
AUDIT_LOG_MASK_USERcontrols them. - Alarm actions belong to the alarm’s originator, so the originator’s mask applies; the
alarmmask covers alarm comments and failed attempts to create or update an alarm.
Storage and Retention
Section titled Storage and RetentionAudit log records are stored in partitions in the SQL database. With SPRING_DEDICATED_EVENTS_DATASOURCE_ENABLED=true, they’re stored in the separate events database instead. These parameters are in the sql section of thingsboard.yml:
Partition size in hours (one week by default).
Enables the cleanup of old audit log records. Cleanup runs only when ttl is greater than 0.
How long to keep records, in seconds. 0 keeps them forever. Records are removed a whole partition at a time, so the cleanup is only as precise as the partition size.
How often the cleanup runs, in milliseconds (once a day by default).
External Log Sink
Section titled External Log SinkRecords can also be sent to Elasticsearch. Sending is best effort: if it fails, the record stays in the database and the server only logs the error. The index name is converted to lower case.
To enable it, set type (AUDIT_LOG_SINK_TYPE) to elasticsearch and the connection parameters shown in the YAML above: scheme_name, host, port, user_name, and password. Two parameters need more explanation:
Index name pattern. Supports @{TENANT} (tenant ID) and @{DATE} (current date) placeholders.
Date format for the @{DATE} placeholder. Uses Java DateTimeFormatter patterns. In these patterns, YYYY is the week-based year, so in the last days of December the default can produce next year’s index name. Set yyyy.MM.dd to use the calendar year.
Related Topics
Section titled “Related Topics”- Security Overview — authentication, sessions, and other tenant-wide security settings.
- Role-Based Access Control — control who can view audit records for specific entities, customers, or users.
- Notifications — get notified about entity actions in real time.
Was this helpful?