Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Audit logs

The security plugin records security-relevant activity as audit events: failed logins, requests denied for missing privileges, and changes to the security configuration (users, roles, role mappings, action groups and the rest of the security index). Wazuh Indexer stores these events as documents in the security-auditlogs data stream.

Where the events are stored

The packaged /etc/wazuh-indexer/opensearch.yml sends audit events to the security-auditlogs data stream:

plugins.security.audit.type: internal_opensearch_data_stream
plugins.security.audit.config.data_stream.name: security-auditlogs

The security plugin creates the data stream on the first audit event, from its own index template (opensearch-security-auditlog), which gives the backing indices no replica. The Setup plugin adds index.auto_expand_replicas: 0-1 to each backing index when it is created, so on a cluster of two or more nodes the events have a copy on a second node. It also ships the security-auditlogs-policy ISM policy, which manages the data stream: the backing index rolls over monthly and each one is deleted at 90 days of age. See Retention to keep the events for a different period.

Only users with access to the security-auditlogs data stream can read the events. By default that is the admin user (all_access). The data stream name is deliberately outside wazuh-*, which the Wazuh Dashboard reads on behalf of every dashboard user.

plugins.security.audit.type is a static node setting. Without it, the security plugin has nowhere to write audit events and drops them, even though the dashboard’s Audit logs page shows audit logging as enabled.

Viewing the events

In the Wazuh Dashboard, create an index pattern for security-auditlogs* with @timestamp as the time field, and open it in Discover. The security plugin’s template defines no field mappings, so OpenSearch maps each field from the first event that carries it. Text fields get a .keyword sub-field for exact matches and aggregations, for example audit_category.keyword. Useful fields:

FieldContent
audit_categoryEvent type, for example FAILED_LOGIN, MISSING_PRIVILEGES or COMPLIANCE_INTERNAL_CONFIG_WRITE.
audit_request_effective_userUser the request ran as.
audit_request_remote_addressAddress the request came from.
audit_rest_request_method, audit_rest_request_pathREST request that produced the event.
audit_request_privilegePermission that was checked, on MISSING_PRIVILEGES events.
audit_trace_resolved_indicesIndices the request touched.
audit_request_bodyRequest body, or the changed security configuration document. Passwords sent to the security REST API are replaced with __SENSITIVE__, and password hashes with __HASH__.

Which events are recorded

The audit configuration is stored in the security index and can be changed at runtime on the dashboard’s Audit logs page, or in /etc/wazuh-indexer/opensearch-security/audit.yml followed by securityadmin.sh. The shipped defaults are:

  • REST and transport auditing enabled, except for the AUTHENTICATED and GRANTED_PRIVILEGES categories. Those two record every successful request, including each request the dashboard makes for a logged-in user, and would fill a small deployment’s disk.
  • Index administration requests, including reads of index templates, mappings and data streams, are recorded as INDEX_EVENT. A tool that polls those APIs with an administrative user adds one event per call.
  • Flushes are not recorded (ignore_requests: ["indices:admin/flush*"]). The upgrade procedure flushes the cluster right before stopping each node, and the closing node cannot store the events of that flush: each one would be logged as an error instead.
  • The kibanaserver user, used by the Wazuh Dashboard for its own requests, is ignored.
  • Compliance auditing of the security configuration (internal_config) enabled: every change to users, roles, role mappings and the rest of the security index is recorded with the user who made it.

To record successful logins too, enable the AUTHENTICATED category, and check the size of the backing indices with GET _cat/indices/.ds-security-auditlogs-*?v before keeping it on.