Review DocumentDB audit and profiler logging

Configure required log generation together with CloudWatch export.

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

  1. In a custom parameter group attached to the cluster, select audit events with audit_logs. For profiling, enable profiler and choose a threshold and sampling rate.
  2. Add the required log types to EnableCloudwatchLogsExports. In CloudWatch Logs, look for an operation covered by the audit settings and for sampled slow operations.
  3. 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.

References