10.4. Bucket logging for Multicloud Object Gateway
Bucket logging helps you to record the S3 operations that are performed against the Multicloud Object Gateway (MCG) bucket for compliance, auditing, and optimization purposes.
Bucket logging supports the following two options:
- Best-effort - Bucket logging is recorded using UDP on the best effort basis
Guaranteed - Bucket logging with this option creates a PVC attached to the MCG pods and saves the logs to this PVC on a Guaranteed basis, and then from the PVC to the log buckets. Using this option logging takes place twice for every S3 operation as follows:
- At the start of processing the request
- At the end with the result of the S3 operation
10.4.1. Enabling bucket logging for Multicloud Object Gateway using the Best-effort option リンクのコピーリンクがクリップボードにコピーされました!
Prerequisites
- Openshift Container Platform with OpenShift Data Foundation operator installed.
Access to MCG.
For information, see Accessing the Multicloud Object Gateway with your applications.
Procedure
Create a data bucket where you can upload the objects.
nb bucket create data.bucketCreate a log bucket where you want to store the logs for bucket operations by using the following command:
nb bucket create log.bucketConfigure bucket logging on data bucket with log bucket in one of the following ways:
Using the NooBaa API
nb api bucket_api put_bucket_logging '{ "name": "data.bucket", "log_bucket": "log.bucket", "log_prefix": "data-bucket-logs" }'Using the S3 API
alias s3api_alias='AWS_ACCESS_KEY_ID=$NOOBAA_ACCESS_KEY AWS_SECRET_ACCESS_KEY=$NOOBAA_SECRET_KEY aws --endpoint https://localhost:10443 --no-verify-ssl s3api'Create a file called
setlogging.jsonin the following format:{ "LoggingEnabled": { "TargetBucket": "<log-bucket-name>", "TargetPrefix": "<prefix/empty-string>" } }Run the following command:
s3api_alias put-bucket-logging --endpoint <ep> --bucket <source-bucket> --bucket-logging-status file://setlogging.json --no-verify-ssl
Verify if the bucket logging is set for the data bucket in one of the following ways:
Using the NooBaa API
nb api bucket_api get_bucket_logging '{ "name": "data.bucket" }'Using the S3 API
s3api_alias get-bucket-logging --no-verify-ssl --endpoint <ep> --bucket <source-bucket>The S3 operations can take up to 24 hours to get recorded in the logs bucket. The following example shows the recorded logs and how to download them:
Example
s3_alias cp s3://logs.bucket/data-bucket-logs/logs.bucket.bucket_data-bucket-logs_1719230150.log - | tail -n 2 Jun 24 14:00:02 10-XXX-X-XXX.sts.openshift-storage.svc.cluster.local {"noobaa_bucket_logging":"true","op":"GET","bucket_owner":"operator@noobaa.io","source_bucket":"data.bucket","object_key":"/data.bucket?list-type=2&prefix=data-bucket-logs&delimiter=%2F&encoding-type=url","log_bucket":"logs.bucket","remote_ip":"100.XX.X.X","request_uri":"/data.bucket?list-type=2&prefix=data-bucket-logs&delimiter=%2F&encoding-type=url","request_id":"luv2XXXX-ctyg2k-12gs"} Jun 24 14:00:06 10-XXX-X-XXX.s3.openshift-storage.svc.cluster.local {"noobaa_bucket_logging":"true","op":"PUT","bucket_owner":"operator@noobaa.io","source_bucket":"data.bucket","object_key":"/data.bucket/B69EC83F-0177-44D8-A8D1-4A10C5A5AB0F.file","log_bucket":"logs.bucket","remote_ip":"100.XX.X.X","request_uri":"/data.bucket/B69EC83F-0177-44D8-A8D1-4A10C5A5AB0F.file","request_id":"luv2XXXX-9syea5-x5z"}
(Optional) To disable bucket logging, use the following command:
nb api bucket_api delete_bucket_logging '{ "name": "data.bucket" }'
10.4.2. Enabling bucket logging using the Guaranteed option リンクのコピーリンクがクリップボードにコピーされました!
Procedure
Enable Guaranteed bucket logging using the NooBaa CR in one of the following ways:
Using the default CephFS storage class update the NooBaa CR spec:
bucketLogging: { loggingType: guaranteed }Using the RWX PVC that you created:
注記Make sure that the PVC supports RWX
bucketLogging: { loggingType: guaranteed bucketLoggingPVC: <pvc-name> }