01 Run describe-db-clusters command (OSX/Linux/UNIX) using the name of the DocumentDB database cluster that you want to reconfigure as the identifier parameter and custom query filters to describe the name of the parameter group associated with the selected database cluster:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws docdb describe-db-clusters
--region us-east-1
--db-cluster-identifier cc-prod-docdb-cluster
--query 'DBClusters[*].DBClusterParameterGroup | []'
02 The command output should return the name of the associated parameter group:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
[
"cc-prod-cluster-parameter-group"
]
03 Run modify-db-cluster-parameter-group command (OSX/Linux/UNIX) using the name of the parameter group returned at the previous step as the identifier parameter, to enable log profiling for the selected DocumentDB cluster parameter group:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws docdb modify-db-cluster-parameter-group
--region us-east-1
--db-cluster-parameter-group-name cc-prod-cluster-parameter-group
--parameters ParameterName=profiler,ParameterValue=enabled,ApplyMethod=immediate ParameterName=profiler_threshold_ms,ParameterValue=100,ApplyMethod=immediate ParameterName=profiler_sampling_rate,ParameterValue=1.0,ApplyMethod=immediate
04 The command output should return the name of the reconfigured parameter group:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
{
"DBClusterParameterGroupName": "cc-prod-cluster-parameter-group"
}
05 Run modify-db-cluster command (OSX/Linux/UNIX) to modify your Amazon DocumentDB database cluster in order enable publishing profiler logs to CloudWatch Logs. The following command example makes use of --apply-immediately parameter to apply the configuration changes asynchronously, as soon as possible. Any changes available in the pending modifications queue are also applied with this request. If any of the pending modifications require downtime, choosing this option can cause unexpected downtime for your DocumentDB application. If you add --no-apply-immediately parameter to the command request, the DocumentDB service will apply your changes during the next scheduled maintenance window:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws docdb modify-db-cluster
--region us-east-1
--db-cluster-identifier cc-prod-docdb-cluster
--db-cluster-parameter-group-name cc-prod-cluster-parameter-group
--cloudwatch-logs-export-configuration '{"EnableLogTypes":["profiler"]}'
--apply-immediately
06 The command output should return the configuration metadata for the modified database cluster:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
{
"DBCluster": {
"DBClusterIdentifier": "cc-prod-docdb-cluster",
"DBClusterParameterGroup": "cc-prod-cluster-parameter-group",
"DBSubnetGroup": "default-vpc-abcdabcd",
"Status": "available",
"Engine": "docdb",
"EngineVersion": "4.0.0",
"Port": 27017,
"PreferredBackupWindow": "00:00-00:30",
"PreferredMaintenanceWindow": "fri:04:57-fri:05:27",
...
"HostedZoneId": "ZNKXH85TT8WVW",
"StorageEncrypted": true,
"KmsKeyId": "arn:aws:kms:us-east-1:123456789012:key/abcdabcd-1234-abcd-1234-abcd1234abcd",
"DbClusterResourceId": "cluster-ABCDABCDABCDABCDABCDABCD",
"DBClusterArn": "arn:aws:rds:us-east-1:123456789012:cluster:cc-prod-docdb-cluster",
"ClusterCreateTime": "2021-02-19T10:00:00.000000+00:00",
"EnabledCloudwatchLogsExports": [
"audit",
"profiler"
],
"DeletionProtection": false
}
}
07 Repeat steps no. 1 – 6 to enable the Profiler feature for other Amazon DocumentDB database clusters available in the selected AWS region.
08 Change the AWS cloud region by updating the --region command parameter value and repeat the remediation process for other regions.