nodetool enableauditlog
Enables audit logging on the node.
Synopsis
Section titled “Synopsis”nodetool [connection_options] enableauditlog [options]See connection options for connection options.
Description
Section titled “Description”nodetool enableauditlog activates the audit logging feature on a Cassandra node. When enabled, Cassandra records audit events such as authentication attempts, authorization checks, and CQL operations to a configurable audit log.
Audit logging is essential for:
- Security compliance - Meeting regulatory requirements (SOX, HIPAA, PCI-DSS)
- Security monitoring - Detecting unauthorized access attempts
- Forensic analysis - Investigating security incidents
- Access tracking - Recording who accessed what data and when
Cassandra 4.0+
Audit logging is available in Apache Cassandra 4.0 and later versions.
Options
Section titled “Options”| Option | Description |
|---|---|
--excluded-categories | Comma-separated list of audit categories to exclude |
--excluded-keyspaces | Comma-separated list of keyspaces to exclude from auditing |
--excluded-users | Comma-separated list of users to exclude from auditing |
--included-categories | Comma-separated list of audit categories to include |
--included-keyspaces | Comma-separated list of keyspaces to include for auditing |
--included-users | Comma-separated list of users to include for auditing |
--logger | Audit logger class name |
--roll-cycle | Log file roll cycle (HOURLY, DAILY, etc.) |
--blocking | Block operations if audit log is full |
--max-archive-retries | Maximum archive retries |
--max-queue-weight | Maximum weight of in-memory log queue (bytes) |
--max-log-size | Maximum total log size before oldest logs deleted |
--archive-command | Archive command for rolled logs (requires allow_nodetool_archive_command: true in cassandra.yaml) |
Audit Categories
Section titled “Audit Categories”| Category | Description |
|---|---|
QUERY | SELECT statements |
DML | INSERT, UPDATE, DELETE statements |
DDL | CREATE, ALTER, DROP statements |
DCL | GRANT, REVOKE statements |
AUTH | Authentication events (login, failed attempts) |
PREPARE | Prepared statement creation |
ERROR | Query errors |
OTHER | Other audit events |
Examples
Section titled “Examples”Enable with Default Settings
Section titled “Enable with Default Settings”nodetool enableauditlogEnable for Specific Categories
Section titled “Enable for Specific Categories”# Only audit authentication and DCL (permissions) eventsnodetool enableauditlog --included-categories AUTH,DCLExclude System Keyspaces
Section titled “Exclude System Keyspaces”# Audit all except system keyspacesnodetool enableauditlog --excluded-keyspaces system,system_schema,system_auth,system_distributed,system_tracesAudit Specific Users
Section titled “Audit Specific Users”# Only audit specific user activitynodetool enableauditlog --included-users admin,operator
# Or audit everyone except certain usersnodetool enableauditlog --excluded-users monitoring_user,backup_userAudit Specific Keyspaces
Section titled “Audit Specific Keyspaces”# Only audit activity on sensitive keyspacesnodetool enableauditlog --included-keyspaces customer_data,financial_recordsFull Configuration Example
Section titled “Full Configuration Example”nodetool enableauditlog \ --included-categories AUTH,DML,DDL,DCL \ --excluded-keyspaces system,system_schema \ --excluded-users monitoring \ --roll-cycle HOURLY \ --blocking trueAudit Log Output
Section titled “Audit Log Output”Default Location
Section titled “Default Location”/var/log/cassandra/audit/Log Format
Section titled “Log Format”Audit logs are written in a binary format by default (Chronicle Queue). Each entry contains:
- Timestamp
- User
- Source IP
- Operation type
- Keyspace/Table
- CQL statement
- Status (success/failure)
Viewing Audit Logs
Section titled “Viewing Audit Logs”# Use auditlogviewer toolauditlogviewer /var/log/cassandra/audit/
# Or configure a custom logger for text outputConfiguration in cassandra.yaml
Section titled “Configuration in cassandra.yaml”Runtime settings from enableauditlog can also be configured persistently:
audit_logging_options: enabled: true logger: - class_name: BinAuditLogger included_keyspaces: customer_data,financial excluded_keyspaces: system,system_schema included_categories: AUTH,DML,DDL,DCL excluded_categories: included_users: excluded_users: monitoring roll_cycle: HOURLY block: true max_queue_weight: 268435456 max_log_size: 17179869184 archive_command: max_archive_retries: 10Use Cases
Section titled “Use Cases”Compliance Auditing
Section titled “Compliance Auditing”Enable comprehensive auditing for regulatory compliance:
# PCI-DSS / SOX compliance - audit all data accessnodetool enableauditlog \ --included-categories AUTH,QUERY,DML,DDL,DCL \ --excluded-keyspaces system,system_schema,system_auth \ --roll-cycle DAILY \ --block trueSecurity Monitoring
Section titled “Security Monitoring”Focus on security-relevant events:
# Authentication and authorization eventsnodetool enableauditlog \ --included-categories AUTH,DCL,ERROR \ --roll-cycle HOURLYSensitive Data Access
Section titled “Sensitive Data Access”Audit access to specific sensitive data:
# Only audit customer data keyspacenodetool enableauditlog \ --included-keyspaces pii_data,financial_data \ --included-categories QUERY,DML \ --roll-cycle HOURLYTroubleshooting Access Issues
Section titled “Troubleshooting Access Issues”Temporarily enable to investigate access problems:
# Enable detailed auditingnodetool enableauditlog \ --included-categories AUTH,ERROR
# Investigate...
# Disable when donenodetool disableauditlogImpact Assessment
Section titled “Impact Assessment”Performance Impact
Section titled “Performance Impact”| Factor | Impact |
|---|---|
| Disk I/O | Moderate (writes to audit log) |
| CPU | Low to moderate |
| Latency | Slight increase (especially with --block true) |
| Disk space | Depends on volume and retention |
Performance Considerations
Audit logging adds overhead to every audited operation. In high-throughput environments, carefully select which categories and keyspaces to audit to minimize impact.
Disk Space Planning
Section titled “Disk Space Planning”# Estimate audit log size# Consider: operations/second * average log entry size * retention period
# Example: 10,000 ops/sec * 200 bytes * 86400 seconds/day = ~172 GB/dayMonitoring Audit Logging
Section titled “Monitoring Audit Logging”Check Status
Section titled “Check Status”nodetool getauditlogMonitor Log Growth
Section titled “Monitor Log Growth”# Check audit log directory sizedu -sh /var/log/cassandra/audit/
# Watch log growthwatch -n 60 'du -sh /var/log/cassandra/audit/'Verify Logging
Section titled “Verify Logging”# Perform an operationcqlsh -e "SELECT * FROM system.local LIMIT 1"
# Check audit log (if using text logger)tail -f /var/log/cassandra/audit/audit.log
# Or use auditlogviewer for binary logsauditlogviewer /var/log/cassandra/audit/ | tail -10Cluster-Wide Enablement
Section titled “Cluster-Wide Enablement”Enable on All Nodes
Section titled “Enable on All Nodes”#!/bin/bashCATEGORIES="AUTH,DML,DDL,DCL"EXCLUDED_KS="system,system_schema,system_auth"# Get list of node IPs from local nodetool status
nodes=$(nodetool status | grep "^UN" | awk '{print $2}')
echo "Enabling audit logging cluster-wide..."for node in $nodes; do echo -n "$node: " ssh "$node" "nodetool enableauditlog \" --included-categories $CATEGORIES \ --excluded-keyspaces $EXCLUDED_KS \ 2>/dev/null && echo "enabled" || echo "FAILED"done
echo ""echo "Verification:"for node in $nodes; do echo "=== $node ===" ssh "$node" "nodetool getauditlog 2>/dev/null"doneTroubleshooting
Section titled “Troubleshooting”Audit Log Not Writing
Section titled “Audit Log Not Writing”# Check directory permissionsls -la /var/log/cassandra/audit/
# Check disk spacedf -h /var/log/cassandra/
# Check logs for errorsgrep -i "audit" /var/log/cassandra/system.log | tail -20Performance Degradation After Enable
Section titled “Performance Degradation After Enable”# Check if blocking is causing issuesnodetool getauditlog | grep block
# Reduce scope of auditingnodetool disableauditlognodetool enableauditlog --included-categories AUTH,ERROR
# Or disable blockingnodetool enableauditlog --block falseLog Files Growing Too Fast
Section titled “Log Files Growing Too Fast”# Narrow down what's being auditednodetool disableauditlog
# Re-enable with stricter filtersnodetool enableauditlog \ --included-categories AUTH,DCL \ --excluded-keyspaces system,system_schema,system_auth,system_distributed,system_traces \ --excluded-users monitoring,backupLog Management
Section titled “Log Management”Archive Configuration
Section titled “Archive Configuration”# Enable with archive commandnodetool enableauditlog \ --archive-command "/usr/local/bin/archive_audit.sh %path" \ --max-archive-retries 3Manual Log Rotation
Section titled “Manual Log Rotation”#!/bin/bash# Audit logs auto-rotate based on roll-cycle# Manual archive example:
AUDIT_DIR="/var/log/cassandra/audit"ARCHIVE_DIR="/archive/cassandra/audit"
# Move old logs to archivefind $AUDIT_DIR -name "*.cq4" -mtime +7 -exec mv {} $ARCHIVE_DIR/ \;
# Compress archived logsfind $ARCHIVE_DIR -name "*.cq4" -exec gzip {} \;Best Practices
Section titled “Best Practices”Audit Logging Guidelines
- Start narrow - Begin with critical categories (AUTH, DCL) and expand
- Exclude system keyspaces - Reduce noise from internal operations
- Monitor disk space - Audit logs can grow rapidly
- Plan retention - Establish log rotation and archival policies
- Test performance - Measure impact before production deployment
- Consistent configuration - Enable with same settings across all nodes
- Secure audit logs - Protect logs from tampering
Security Considerations
- Audit logs may contain sensitive query parameters
- Secure the audit log directory with appropriate permissions
- Consider encryption for audit log archives
- Implement tamper-evident logging for compliance
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| disableauditlog | Disable audit logging |
| getauditlog | View audit log configuration |
| enablefullquerylog | Enable full query logging |