nodetool getauditlog
Cassandra 4.1+
This command is available in Cassandra 4.1 and later.
Displays the current audit logging configuration.
Synopsis
Section titled “Synopsis”nodetool [connection_options] getauditlogSee connection options for connection options.
Description
Section titled “Description”nodetool getauditlog retrieves and displays the current audit logging configuration on a Cassandra node. This command shows whether auditing is enabled and all associated settings including included/excluded categories, keyspaces, and users.
Output
Section titled “Output”When Enabled
Section titled “When Enabled”enabled: truelogger: BinAuditLoggeraudit_logs_dir: /var/log/cassandra/auditarchive_command:included_keyspaces: customer_data,financialexcluded_keyspaces: system,system_schema,system_authincluded_categories: AUTH,DML,DDL,DCLexcluded_categories:included_users:excluded_users: monitoringroll_cycle: HOURLYblock: truemax_queue_weight: 268435456max_log_size: 17179869184max_archive_retries: 10When Disabled
Section titled “When Disabled”The command shows the configuration from cassandra.yaml even when auditing is disabled. Fields will reflect the configured values, not necessarily empty:
enabled: falselogger: BinAuditLoggeraudit_logs_dir: /var/log/cassandra/auditarchive_command:...Examples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”nodetool getauditlogCheck Specific Field
Section titled “Check Specific Field”# Check if enablednodetool getauditlog | grep "enabled:"
# Check what categories are being auditednodetool getauditlog | grep "included_categories"Check Remote Node
Section titled “Check Remote Node”ssh 192.168.1.100 "nodetool getauditlog"Output Fields
Section titled “Output Fields”| Field | Description |
|---|---|
enabled | Whether audit logging is active |
logger | Audit logger class name |
audit_logs_dir | Directory where audit logs are stored |
archive_command | Command executed to archive rolled logs |
included_keyspaces | Keyspaces being audited (if set) |
excluded_keyspaces | Keyspaces excluded from auditing |
included_categories | Audit event categories being captured |
excluded_categories | Categories excluded from auditing |
included_users | Users being audited (if set) |
excluded_users | Users excluded from auditing |
roll_cycle | Log file rotation frequency |
block | Whether to block operations if log is full |
max_queue_weight | Maximum queue size in bytes |
max_log_size | Maximum total log size |
max_archive_retries | Maximum retries for archive command |
Use Cases
Section titled “Use Cases”Verify After Configuration Change
Section titled “Verify After Configuration Change”Confirm settings after enabling audit logging:
# Enable with specific settingsnodetool enableauditlog --included-categories AUTH,DML --excluded-keyspaces system
# Verify configurationnodetool getauditlogHealth Check
Section titled “Health Check”Include in operational health checks:
#!/bin/bashconfig=$(nodetool getauditlog 2>/dev/null)
if echo "$config" | grep -q "enabled: true"; then echo "OK: Audit logging is enabled"
# Check for recommended settings if echo "$config" | grep -q "AUTH"; then echo " - AUTH events are being audited" else echo " WARNING: AUTH events not being audited" fi
if echo "$config" | grep -q "block: true"; then echo " - Blocking mode is enabled (recommended)" else echo " - Non-blocking mode (events may be lost)" fi
exit 0else echo "CRITICAL: Audit logging is disabled!" exit 2fiCompliance Verification
Section titled “Compliance Verification”Verify audit configuration meets compliance requirements:
#!/bin/bashecho "=== Audit Logging Compliance Check ==="
config=$(nodetool getauditlog 2>/dev/null)issues=0
# Check enabledif ! echo "$config" | grep -q "enabled: true"; then echo "FAIL: Audit logging is not enabled" ((issues++))else echo "PASS: Audit logging is enabled"fi
# Check required categoriesrequired_categories=("AUTH" "DML" "DDL" "DCL")categories=$(echo "$config" | grep "included_categories" | cut -d: -f2)
for cat in "${required_categories[@]}"; do if echo "$categories" | grep -q "$cat"; then echo "PASS: $cat category is being audited" else echo "FAIL: $cat category is NOT being audited" ((issues++)) fidone
# Check blocking modeif echo "$config" | grep -q "block: true"; then echo "PASS: Blocking mode enabled"else echo "WARN: Non-blocking mode - audit events may be lost"fi
echo ""if [ $issues -eq 0 ]; then echo "Compliance check PASSED"else echo "Compliance check FAILED - $issues issue(s) found"fiCluster Audit Consistency
Section titled “Cluster Audit Consistency”Verify audit configuration is consistent across nodes:
#!/bin/bashecho "=== Cluster Audit Configuration Check ==="# Get list of node IPs from local nodetool status
nodes=$(nodetool status | grep "^UN" | awk '{print $2}')first_config=""
for node in $nodes; do config=$(ssh "$node" "nodetool getauditlog 2>/dev/null)"
if [ -z "$first_config" ]; then first_config="$config" echo "Reference node: $node" echo "$config" echo "" else if [ "$config" = "$first_config" ]; then echo "$node: CONSISTENT" else echo "$node: DIFFERS" echo "Differences:" diff <(echo "$first_config") <(echo "$config") fi fidoneMonitoring Integration
Section titled “Monitoring Integration”Prometheus Exporter
Section titled “Prometheus Exporter”#!/bin/bash# Export audit config as metrics
config=$(nodetool getauditlog 2>/dev/null)
# Enabled statusenabled=$(echo "$config" | grep "enabled:" | grep -q "true" && echo "1" || echo "0")echo "cassandra_audit_logging_enabled $enabled"
# Blocking modeblocking=$(echo "$config" | grep "block:" | grep -q "true" && echo "1" || echo "0")echo "cassandra_audit_logging_blocking $blocking"
# Max log sizemax_size=$(echo "$config" | grep "max_log_size:" | awk '{print $2}')[ -n "$max_size" ] && echo "cassandra_audit_max_log_size_bytes $max_size"JSON Output
Section titled “JSON Output”#!/bin/bash# Output audit config as JSON
config=$(nodetool getauditlog 2>/dev/null)
enabled=$(echo "$config" | grep "enabled:" | awk '{print $2}')logger=$(echo "$config" | grep "logger:" | cut -d: -f2 | xargs)categories=$(echo "$config" | grep "included_categories:" | cut -d: -f2 | xargs)block=$(echo "$config" | grep "block:" | awk '{print $2}')
cat <<EOF{ "timestamp": "$(date -Iseconds)", "audit_logging": { "enabled": $enabled, "logger": "$logger", "included_categories": "$categories", "blocking": $block }}EOFTroubleshooting
Section titled “Troubleshooting”Command Returns Empty
Section titled “Command Returns Empty”# Check JMX connectivitynodetool info
# Check Cassandra version (audit logging requires 4.0+)nodetool versionUnexpected Configuration
Section titled “Unexpected Configuration”# Compare with cassandra.yaml settingsgrep -A 20 "audit_logging_options" /etc/cassandra/cassandra.yaml
# Runtime changes may differ from config file# Settings from enableauditlog override cassandra.yaml until restartConfiguration Not Taking Effect
Section titled “Configuration Not Taking Effect”# Verify the enable command workednodetool getauditlog | grep enabled
# If still showing unexpected config, re-enablenodetool enableauditlog --included-categories AUTH,DML,DDL,DCLConfiguration Comparison
Section titled “Configuration Comparison”Runtime vs Persistent
Section titled “Runtime vs Persistent”| Setting Source | Persistence | Scope |
|---|---|---|
enableauditlog | Until restart | This node only |
cassandra.yaml | Permanent | All restarts |
# Show runtime configecho "=== Runtime Configuration ==="nodetool getauditlog
# Show file configecho ""echo "=== cassandra.yaml Configuration ==="grep -A 15 "audit_logging_options" /etc/cassandra/cassandra.yamlAudit Configuration Report
Section titled “Audit Configuration Report”#!/bin/bashOUTPUT_FILE="/var/log/cassandra/audit_config_$(date +%Y%m%d).log"
echo "=== Audit Logging Configuration Report ===" | tee $OUTPUT_FILEecho "Generated: $(date)" | tee -a $OUTPUT_FILEecho "Node: $(hostname)" | tee -a $OUTPUT_FILEecho "" | tee -a $OUTPUT_FILE
echo "Current Configuration:" | tee -a $OUTPUT_FILEnodetool getauditlog 2>/dev/null | tee -a $OUTPUT_FILE
echo "" | tee -a $OUTPUT_FILEecho "Audit Log Directory:" | tee -a $OUTPUT_FILEls -la /var/log/cassandra/audit/ 2>/dev/null | tee -a $OUTPUT_FILE
echo "" | tee -a $OUTPUT_FILEecho "Audit Log Size:" | tee -a $OUTPUT_FILEdu -sh /var/log/cassandra/audit/ 2>/dev/null | tee -a $OUTPUT_FILE
echo "" | tee -a $OUTPUT_FILEecho "Disk Usage:" | tee -a $OUTPUT_FILEdf -h /var/log/cassandra/ | tee -a $OUTPUT_FILEBest Practices
Section titled “Best Practices”Configuration Verification
- Regular checks - Periodically verify audit configuration
- After changes - Always check config after enable/disable
- Cluster consistency - Ensure all nodes have same config
- Compare to requirements - Verify against compliance needs
- Document settings - Keep record of intended configuration
- Monitor disk space - Check log growth alongside config
Configuration Tips
- Runtime settings from
enableauditlogdon't persist across restarts - For permanent configuration, update
cassandra.yaml - Consider both runtime and file settings when troubleshooting
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| enableauditlog | Enable audit logging |
| disableauditlog | Disable audit logging |
| enablefullquerylog | Enable full query logging |
| getfullquerylog | View full query log config |