Set up database auditing
Capture Hyper-Converged Database (HCD) activity to a binary audit log. Each node only records the events that happen locally. Use the configuration to refine the type of events captured. HCD provides the following customizations:
-
Keyspace filtering: Capture activity in every keyspace or only targeted keyspaces.
-
Category filtering: Identify event categories to limit the number of events captured.
-
User filtering: Track the activity of particular users by their login username.
-
Node specific: Enable auditing on specific nodes, an entire datacenter, or the whole cluster.
Enable audit logging
You configure audit logging options per node, so settings can differ across nodes.
HCD records database activity using the BinAuditLogger, which writes events as binary log files to a configurable directory.
To enable audit logging, set the audit_logging_options in the cassandra.yaml file:
-
Locate the
cassandra.yamlconfiguration file.The location of the
cassandra.yamlfile depends on your installation type:-
Package installations:
/etc/hcd/cassandra/cassandra.yaml -
Tarball installations:
INSTALL_DIRECTORY/resources/cassandra/conf/cassandra.yaml
-
-
Set
enabled: trueand configure the options as needed:audit_logging_options: enabled: true logger: - class_name: BinAuditLogger # audit_logs_dir: # included_keyspaces: # excluded_keyspaces: system, system_schema, system_virtual_schema # included_categories: # excluded_categories: # included_users: # excluded_users: # roll_cycle: HOURLY # block: true # max_queue_weight: 268435456 # 256 MiB # max_log_size: 17179869184 # 16 GiB # archive_command: # max_archive_retries: 10-
enabled: true: Enables audit logging after the next start up. -
logger: BinAuditLogger: Writes audit events as binary log files. -
audit_logs_dir: Directory where binary audit log files are written. If not set, defaults to thelog.dirsystem property. -
roll_cycle: How frequently the binary log file rolls over. Default:HOURLY. -
block: Whentrue, slows down write operations rather than dropping audit log entries if the queue is full. Default:true. -
max_queue_weight: Maximum number of bytes of data in the queue beforeblocktakes effect. Default:268435456(256 MiB). -
max_log_size: Maximum size in bytes for the audit log directory. Ifarchive_commandis not set, the oldest files are deleted when this limit is reached. Default:17179869184(16 GiB). -
archive_command: Optional shell command to run when a log file is rolled. Use%pathas a placeholder for the file path, for example/path/to/script.sh %path. If not set, HCD automatically deletes the oldest files whenmax_log_sizeis reached. If set, the script is responsible for any cleanup — HCD does not delete old files automatically. -
max_archive_retries: Number of times to retry the archive command on failure. Default:10.
-
Filter event categories
Configure which categories to capture in the audit_logging_options section of the cassandra.yaml file.
By default, HCD captures all event categories when audit_logging_options.enabled: true and the filters (included_categories and excluded_categories) are commented out:
audit_logging_options:
enabled: true
logger:
- class_name: BinAuditLogger
# included_categories:
# excluded_categories:
To set filters, uncomment one of the following parameters, and then set the value to the relevant event categories:
-
included_categories: Includes only listed categories, and excludes all others. -
excluded_categories: Excludes listed categories, and includes all others.
For example, to include only data retrieval and manipulation events:
audit_logging_options:
enabled: true
logger:
- class_name: BinAuditLogger
included_categories: QUERY, DDL, AUTH
# excluded_categories:
Audit logging event categories and types
All events have both a category and a type. A type usually maps directly to a CQL command.
The following tables list all types in each category.
DDL category
The DDL category includes data definition language type events that modify the database schema:
| Event type | CQL command |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DML category
The DML category captures events related to data manipulation language operations in the database:
| Event type | CQL command |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cassandra driver prepared statement, such as a Java driver prepared statement |
|
DCL category
The DCL category captures events related to database control, role, and permission changes:
| Event type | CQL command |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QUERY category
The QUERY category captures events related to data retrieval operations:
| Event type | CQL command |
|---|---|
|
|
|
Remote Procedure Call (RPC) statement. |
AUTH category
The AUTH category captures events related to authentication and authorization operations:
| Event type | CQL shell (cqlsh) command |
|---|---|
|
Successful login attempt from |
|
Failed login attempt from |
|
Unauthorized access attempt from |
ERROR category
The ERROR category captures events related to error occurrences:
| Event type | Information |
|---|---|
|
CQL statement failures. |
|
Failed requests. |
UNKNOWN category
The UNKNOWN category captures events related to unknown occurrences:
| Event type | Information |
|---|---|
|
Unknown events. |
Filter keyspaces
Configure which keyspaces to capture in audit logs in the audit_logging_options section of the cassandra.yaml file:
audit_logging_options:
enabled: true
logger:
- class_name: BinAuditLogger
# included_categories:
# excluded_categories:
# included_keyspaces:
# excluded_keyspaces:
By default, both keyspace parameters are commented out, and events are captured for all keyspaces.
To filter keyspaces in audit log events, uncomment and set only one of the following parameters:
-
included_keyspaces: Include only matching keyspaces, and exclude all others.When using
included_keyspaces,AUTHmessages are not captured. -
excluded_keyspaces: Exclude matching keyspaces, and include all others.
The value must be either a regular expression (regex) or a comma-separated list of keyspace names as exact matches.
For example, HCD queries the system_local keyspace on every login.
The following exclusion captures login events without capturing additional queries to system_local:
audit_logging_options:
enabled: true
logger:
- class_name: BinAuditLogger
# included_categories:
# excluded_categories:
# included_keyspaces:
excluded_keyspaces: system_local
Filter users
Track specific users in audit logs in the audit_logging_options section of the cassandra.yaml:
audit_logging_options:
enabled: true
logger:
- class_name: BinAuditLogger
# included_categories:
# excluded_categories:
# included_keyspaces:
# excluded_keyspaces:
# included_users:
# excluded_users:
By default, both *_users parameters are commented out, and audit log events are captured for all users.
To track specific users only, uncomment and set one of the following parameters:
-
included_users: Includes only matching users, and excludes all others. -
excluded_users: Excludes matching users, and includes all others.
The value of these parameters must be a comma-separated list of usernames as exact matches.
The following example records audit log events for all users except hcd_admin and jim:
audit_logging_options:
enabled: true
logger:
- class_name: BinAuditLogger
# included_categories:
# excluded_categories:
# included_keyspaces:
# excluded_keyspaces:
# included_users:
excluded_users: hcd_admin, jim