ClouisleClouisle

Audit Logs

View, filter, export, and archive system operation audit logs

Audit logs record resource operations across the system: the actor, action, resource, before/after change snapshots, and source IP. Sensitive fields are redacted at write and display time, so raw secrets never appear in logs. Viewing audit logs requires audit:read; exporting requires audit:export.

Audit Log Events

Audit logs cover the following event types. Each event records the actor, timestamp, resource, operation type, status, and change details.

Authentication Events

User login, logout, and registration actions:

EventDescriptionRecorded Content
login_successSuccessful loginUser, time, IP, User Agent, auth method, 2FA used
login_failedFailed loginUser, time, IP, failure reason, attempt count
logoutLogoutUser, time, IP, session duration
registerRegistrationUser, time, IP, registration method, email verified

User Management Events

Administrator actions on user accounts:

EventDescriptionRecorded Content
create_userCreate userActor, time, new user email, full name, role, status
update_userUpdate userActor, time, changed fields before/after (e.g., role, status)
delete_userDelete userActor, time, deleted user identifier

Team Management Events

Team creation and member changes:

EventDescriptionRecorded Content
create_teamCreate teamActor, time, team name, description, owner
add_team_memberAdd team memberActor, time, team, member ID, member email, role
remove_team_memberRemove team memberActor, time, team, member ID, removal reason

Agent Events

Agent creation, update, publish, and deletion:

EventDescriptionRecorded Content
create_agentCreate AgentActor, time, Agent name, team, model
update_agentUpdate AgentActor, time, changed fields before/after (e.g., max_iterations, system_prompt)
publish_agentPublish AgentActor, time, visibility, marketplace listing
delete_agentDelete AgentActor, time, Agent identifier

API Key Events

API Key creation and state changes:

EventDescriptionRecorded Content
create_api_keyCreate API KeyActor, time, Key name, scopes, agent/workflow count, expiration
activate_api_keyActivate API KeyActor, time, Key identifier
deactivate_api_keyDeactivate API KeyActor, time, Key identifier, deactivation reason

System Settings Events

Site configuration changes:

EventDescriptionRecorded Content
update_site_settingUpdate single settingActor, time, setting key, before/after values
bulk_update_site_settingsBulk update settingsActor, time, count of updated settings, setting keys list
reset_site_settingsReset settingsActor, time, reset category, count of reset settings

Security Events

Account security-related operations:

EventDescriptionRecorded Content
change_passwordChange passwordUser, time, IP
reset_passwordReset passwordUser, time, reset method, initiated by
activate_userActivate accountActor, time, target user
deactivate_userDeactivate accountActor, time, target user, deactivation reason

Viewing and Filtering

Open Admin > Audit Logs. Each entry shows: timestamp, user, action, resource type, resource name, operation (create/read/update/delete), status, IP address, and details.

Search and Filtering

The list endpoint GET /api/v1/admin/audit-logs supports the following query parameters:

ParameterDescription
user_idFilter by user UUID
team_idFilter by team UUID
actionFilter by exact action values; supports repeated values for action__in match (wildcards not supported)
resource_typeFilter by resource type (user, team, agent, workflow, etc.)
resource_idFilter by resource UUID
statusFilter by status (success, failed, etc.)
start_date / end_dateFilter by time period
searchCase-insensitive substring (icontains) search over resource name, resource ID, and IP address

There is no dedicated IP address filter parameter, but the search field supports substring matching on IPs (e.g., 192.168.1.). search does not interpret * or other glob patterns.

Roadmap: Cannot filter by changed field, before value, or after value. Field-level changes are visible only in log details and exports.

Roadmap: No saved-search feature yet. Re-run the filters you need manually.

Viewing Log Details

Click a log entry to view full details, including:

  • Basic Information: ID, timestamp, user, user ID, action, status
  • Resource Information: Resource type, resource ID, resource name, operation type
  • Request Information: IP address, User Agent, auth method
  • Changes: before / after field-level change snapshots (sensitive values redacted)
  • Metadata: Team ID/name, model, duration, etc.

Roadmap: No "Related Logs" view. To find related entries, filter by the same user_id, resource_id, or time range.

Sensitive Data Redaction

Field-level before / after change data is processed by AuditLogService.sanitize_changes before storage:

  • Sensitive fields are masked: Keys containing password, hashed_password, api_key, secret_key, access_token, refresh_token, private_key, secret, or token are masked. String values longer than 8 characters show only the first 8 characters followed by ***; other values are replaced with ***.
  • Email addresses are partially masked: with a local part longer than 2 characters the first and last characters are kept (a***e@example.com); with 2 or fewer, only the first is kept (a***@example.com).
  • Nested dictionaries are processed recursively.
  • Values are truncated to a maximum field length (500 characters); oversized structures are replaced with a preview string.

Because redaction happens at write time, raw secrets never appear in audit logs.

Exporting Audit Logs

Export Formats

Supports CSV and JSON. The export endpoint GET /api/v1/admin/audit-logs/export?format=csv|json accepts every list filter except resource_id (user_id, team_id, action, resource_type, status, start_date, end_date, search) and returns up to 10,000 logs, newest first.

Export search differs from list search

The list endpoint's search matches resource name, resource ID, and IP address; the export endpoint's search matches resource name and IP address only (no resource ID), and there is no resource_id parameter at all. Searching by resource ID and then exporting therefore yields more rows than the list view — for troubleshooting, export using resource name or IP as the criterion.

CSV columns: ID, Time, User, Action, Resource Type, Resource Name, Operation, Status, IP Address, Error Message

JSON: Exports full serialized entries (including changes).

curl -X GET "https://your-domain.com/api/v1/admin/audit-logs/export?format=csv" \
  -H "Authorization: Bearer $ADMIN_TOKEN"

Roadmap: No scheduled exports (daily/weekly/monthly) or delivery to email/S3. Exports are manual only.

Retention and Archival

Retention Policy

Retention is controlled by the audit_log_retention_days site setting, default 365 days with a range of 30-3650.

Configuration: Navigate to Admin > Site Settings > Storage, set Audit log retention (days) and Archive file storage path (default /var/log/clouisle/audit_archives).

Manual Archive

  1. Navigate to Admin > Site Settings > Storage.
  2. In the Audit Logs section, click Archive and confirm.
  3. The task runs asynchronously (requires audit:export); the UI polls task status every 2 seconds and times out after 5 minutes.

Note: The manual archive control lives on the Storage settings page, not on the audit log page — the audit log page only views, filters, and exports.

Endpoints used:

MethodPathDescription
POST/api/v1/admin/site-settings/archive-audit-logsTrigger the archive; returns { "task_id", "status": "pending" }
GET/api/v1/admin/site-settings/archive-audit-logs/{task_id}Poll status: PENDING / STARTED / SUCCESS (with result.archived_count) / FAILURE (with error)
POST/api/v1/admin/audit-logs/archiveEquivalent trigger under the audit-log router: submits the same tasks.archive_old_audit_logs but returns only task_id — there is no companion status endpoint

All three require audit:export; both success and failure of the trigger are themselves written to the audit log (trigger_audit_log_archive).

How Archiving Works:

  • The archive task tasks.archive_old_audit_logs selects logs older than the retention cutoff (now - audit_log_retention_days)
  • Logs are exported to local JSON files grouped by month, e.g. /var/log/clouisle/audit_archives/audit_logs_202602.json (existing monthly files are appended to)
  • Once archived, those rows are deleted from the database

Archiving deletes the archived rows from the database, leaving only the local JSON files. The archive path must live on a persistent volume, otherwise a container rebuild destroys the only copy — and confirm audit_log_retention_days against your compliance requirement before triggering.

Roadmap: There is no scheduled automatic archive — archiving is always manual — and no S3/Azure/Blob archive destinations. Archive output is written only to the local path configured in audit_log_archive_path.

Roadmap: No restore workflow for archived logs. Monthly JSON archive files under the archive path remain available for manual inspection.

Archive Status Query

GET /api/v1/admin/audit-logs/stats/retention returns: configured retention_days, cutoff_date, logs_to_archive, oldest_log_date, and next_archive_date.

next_archive_date is a value the endpoint computes as "tomorrow at 03:00" — no Celery Beat schedule backs it. Archiving is always manual; do not read it as a promise that the system will archive automatically at that time (app/core/celery.py's beat_schedule has no archive task).

Statistics Endpoints

GET /api/v1/admin/audit-logs/stats returns aggregate statistics: total logs, today's logs, failed logs, active users (last 7 days), top 5 actions, top 5 users.

Roadmap: No audit report generator (user activity, admin actions, security events, resource changes, failed operations, or custom reports). The statistics endpoints above provide the currently available aggregates.

Roadmap: No real-time monitoring dashboard for audit logs. Site settings such as audit_alert_enabled, audit_alert_webhook, and failed-login thresholds exist as dormant configuration but are not consumed by any monitoring or notification code (see the "Audit Alerts" subsection of Site Settings).

API Endpoint Reference

MethodPathDescriptionPermission
GET/api/v1/admin/audit-logsQuery audit log list (with filtering)audit:read
GET/api/v1/admin/audit-logs/{id}Get single audit log detailsaudit:read
GET/api/v1/admin/audit-logs/export?format=csv|jsonExport audit logs (up to 10,000)audit:export
GET/api/v1/admin/audit-logs/statsGet audit statistics aggregatesaudit:read
GET/api/v1/admin/audit-logs/stats/retentionGet retention and archival statusaudit:read
POST/api/v1/admin/audit-logs/archiveTrigger manual archive task (returns task_id only)audit:export
POST/api/v1/admin/site-settings/archive-audit-logsTrigger manual archive task (used by the Storage settings page; returns task_id + status)audit:export
GET/api/v1/admin/site-settings/archive-audit-logs/{task_id}Poll archive task status and resultaudit:export

Best Practices

Audit Logging

  • Enable audit logging for all actions
  • Log both successes and failures
  • Include sufficient context
  • Protect log integrity
  • Review logs regularly
  • Archive logs appropriately
  • Monitor for anomalies
  • Set up alerts for critical events

Log Analysis

  • Review logs regularly
  • Look for patterns and trends
  • Investigate anomalies
  • Generate regular reports
  • Share findings with team
  • Document incidents and remediation
  • Use logs for compliance

Security

  • Restrict log access
  • Encrypt archived logs
  • Use secure storage
  • Monitor log access behavior
  • Audit the auditors
  • Maintain log integrity
  • Comply with regulations

See also:

How is this guide?

On this page