Lesson 4: Security Auditing in MongoDB / Learn

Code Summary: Security Auditing in MongoDB

Review the following code, which demonstrates how to access the audit log file.

Locate the Audit Log File

To locate the audit log file, first open the mongod configuration file:

cat /etc/mongod.conf

Then review the auditLog.path setting to view the full path to the audit log file:

auditLog:
  destination: file
  format: JSON
  path: /var/log/mongodb/auditLog.json

Access the Audit Log File

To access the audit log file, tail the audit log to review its most recent entries. Use the jq command-line utility to pretty-print the log entries:

sudo tail /var/log/mongodb/auditLog.json | jq