Enabling bucket logging by using the Best-Effort option

Use the NooBaa API or the S3 API to enable bucket logging for the best-effort option.

Before you begin

Procedure

  1. Create a data bucket where you can upload the objects.
    nb bucket create data.bucket
  2. Create a log bucket where you want to store the logs for bucket operations.
    nb bucket create log.bucket
  3. Configure bucket logging on data bucket with log bucket.

    You can configure bucket logging by using the NooBaa API or the S3 API.

    • By using the NooBaa API:

      nb api bucket_api put_bucket_logging '{
         "name": "data.bucket",
         "log_bucket": "log.bucket",
         "log_prefix": "data-bucket-logs"
      }'
    • By using the S3 API:

      1. Define an alias for the S3 API command.

        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'
      2. Create a setlogging.json file in the following format:

        {
          "LoggingEnabled": {
             "TargetBucket": "<log-bucket-name>",
             "TargetPrefix": "<prefix/empty-string>"
          }
        }
      3. Configure bucket logging based on settings defined in the setlogging.json file.

        s3api_alias put-bucket-logging --endpoint <ep> --bucket <source-bucket> --bucket-logging-status file://setlogging.json --no-verify-ssl
  4. Verify whether the bucket logging is set for the data bucket in one of the following ways:
    • By using the NooBaa API:

      nb api bucket_api get_bucket_logging '{
         "name": "data.bucket"
      }'
    • By 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:

      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"}
  5. Optional: To disable bucket logging, run the following command:
    nb api bucket_api delete_bucket_logging '{
       "name": "data.bucket"
    }'