Description
DocumentDB audit logs record authentication and selected database operations. Profiler logs sample operations that exceed a latency threshold.
Potential impact
Without these records, unusual access or slow responses can be difficult to explain.
Remediation
- In a custom parameter group attached to the cluster, select audit events with
audit_logs. For profiling, enableprofilerand choose a threshold and sampling rate. - Add the required log types to
EnableCloudwatchLogsExports. In CloudWatch Logs, look for an operation covered by the audit settings and for sampled slow operations. - Restrict log access, set retention and review collection costs and profiling overhead.
Examples
These excerpts omit credentials, networking and the parameter group.
Before
yaml
Resources:
MyDocDBCluster:
Type: AWS::DocDB::DBCluster
Properties:
DBClusterIdentifier: my-docdb-cluster
StorageEncrypted: true
After
yaml
Resources:
MyDocDBCluster:
Type: AWS::DocDB::DBCluster
Properties:
DBClusterIdentifier: my-docdb-cluster
StorageEncrypted: true
EnableCloudwatchLogsExports:
- audit
- profiler
Both templates encrypt stored data. The second also exports audit and profiler logs to CloudWatch.