Cloud Logging for storage batch operations

This page describes how to configure and viewstorage batch operations logs by using Cloud Logging. Astorage batch operations job can be configured to generateCloud Logging log entries for each transformation job. Each log entrycorresponds to the attempted transformation of an object.

Storage batch operations support logging to both Cloud Logging andCloud Storage Cloud Audit Logs. While both options capturestorage batch operations actions, we recommend usingCloud Logging. Cloud Logging provides acentralized platform for log analysis, real-time monitoring, and advancedfiltering, offering a robust solution for managing and understanding yourbatch operation activity.

Before you begin

Verify that you have access to Cloud Logging. To use Cloud Logging, we recommendgranting theLogs Viewer (roles/logging.viewer) Identity and Access Management role. TheLogs Viewer (roles/logging.viewer) Identity and Access Management role provides the Identity and Access Management permissions required to view your Cloud Logging data.For more information about Logging access permissions, seeAccess controlwith IAM.

To verify and grant the IAM permissions, complete the following steps:

Understand logging details

When logging is enabled, storage batch operations capturethe following details:

  • Loggable action: The loggable action value is alwaystransform.

  • Loggable states: For each action, you can choose to log one or both ofthe following states:

    • SUCCEEDED: The action was successful.
    • FAILED: The action failed.

Enable logging

To enable logging, specify the actions and the states to log.

Command line

When creating a storage batch operations job withgcloudstorage batch-operations jobs create, use the--log-actions and--log-action-states flags to enable logging.

gcloud storage batch-operations jobs createJOB_NAME \  --manifest-location=MANIFEST_LOCATION \  --delete-object \  --log-actions=transform \  --log-action-states=LOG_ACTION_STATES

Where:

  • JOB_NAME is the name you want to give yourjob. For example,my-job.
  • MANIFEST_LOCATION is the location of yourmanifest. For example,gs://my-bucket/manifest.csv.
  • LOG_ACTION_STATES is a comma-separated listof states to log. For example,succeeded,failed.

REST API

Create a storage batch operationsjobwith aLoggingConfig.

{"loggingConfig":{"logActions":["TRANSFORM"],"logActionStates":["LOG_ACTION_STATES"],}}

Where:

LOG_ACTION_STATES is a comma-separatedlist of states to log. For example,"SUCCEEDED","FAILED".

View logs

To view storage batch operations logs, do the following:

Console

  1. Go to the Google Cloud navigation menu and selectLogging > Logs Explorer:

    Go to the Logs Explorer

  2. Select a Google Cloud project.

  3. From theUpgrade menu, switch fromLegacy Logs Viewer toLogs Explorer.

  4. To filter your logs to show only storage batch operations entries, typestorage_batch_operations_job into the query field and clickRun query.

  5. In theQuery results pane, clickEdit time to change the timeperiod for which to return results.

For more information on using the Logs Explorer, seeUsing theLogs Explorer.

Command line

To use the gcloud CLI to search for storage batch operationslogs, use thegcloud logging readcommand.

Specify a filter to limit your results to storage batch operations logs.

gcloudloggingread"resource.type=storage_batch_operations_job"

REST API

Use theentries.listCloud Logging API method.

To filter your results to include only storage batch operations-related entries,use thefilter field. The following is a sample JSON request object:

{"resourceNames":["projects/my-project-name"],"orderBy":"timestamp desc","filter":"resource.type=\"storage_batch_operations_job\""}

Where:

my-project-name is the name of your project.

Storage batch operations log format

All storage batch operations-specific fields are contained within ajsonPayload object. While the exact content ofjsonPayload varies based onthejob type, there is a common structure shared across allTransformActivityLog entries. This section outlines the common log fields andthen details the operation-specific fields.

  • Common log fields

    The following fields appear in all logs:

    jsonPayload:{"@type":"type.googleapis.com/google.cloud.storagebatchoperations.logging.TransformActivityLog","completeTime":"YYYY-MM-DDTHH:MM:SS.SSSSSSSSSZ","status":{"errorMessage":"String indicating error","errorType":"ENUM_VALUE","statusCode":"ENUM_VALUE"},"logName":"projects/PROJECT_ID/logs/storagebatchoperations.googleapis.com%2Ftransform_activity","receiveTimestamp":"YYYY-MM-DDTHH:MM:SS.SSSSSSSSSZ","resource":{"labels":{"location":"us-central1","job_id":"BATCH_JOB_ID","resource_container":"RESOURCE_CONTAINER",// ... other labels},"type":"storagebatchoperations.googleapis.com/Job"},// Operation-specific details will be nested here (for example,// "DeleteObject", "PutObjectHold", "RewriteObject", "PutMetadata")// Each operation-specific object will also contain the following// object: "objectMetadataBefore": {//   "gcsObject": {//     "bucket": "BUCKET_NAME",//     "generation": "GENERATION_NUMBER",//     "objectKey": "OBJECT_PATH"//   }// }}

    The following table describes each of the common log fields:

    Common log fieldsTypeDescription
    @typeStringSpecifies the type of the log entry's payload and indicates that the log represents aTransformActivityLog for storage batch operations.
    completeTimeTimestampThe ISO 8601-compliant timestamp at which the operation completed.
    statusObjectProvides information about the result of the batch operation activity.
    status.errorMessageStringAn error message if the operation fails. The error message appears only if thestatus.statusCode value isnotOK.
    status.errorTypeStringThe error type. The error type appears only if thestatus.statusCode value isnotOK.
    status.statusCodeStringThe status code of the operation. The operation is successful if the value isOK; any other value indicates failure.
    logNameStringThe full resource name of the log, indicating the project and the log stream.
    receiveTimestampTimestampThe timestamp when the log entry was received by the logging system.
    resourceObjectInformation about the resource that generated the log entry.
    resource.labelsObjectKey-value pairs providing additional identifying information about the resource.
    resource.typeStringThe type of resource that generated the log.
    objectMetadataBeforeObjectContains metadata of the object before the batch operation was attempted.
    objectMetadataBefore.gcsObjectObjectDetails about the object.
    objectMetadataBefore.gcsObject.bucketStringThe name of the bucket where the object resides.
    objectMetadataBefore.gcsObject.generationStringThe generation number of the object before the operation.
    objectMetadataBefore.gcsObject.objectKeyStringThe full path of the object within the bucket.
  • Operation-specificjsonPayload contents

    The difference between log entries for different batch operations lies in the top-level object nested within thejsonPayload. Only one of the following objects is available in a given log entry, corresponding to the specific batch operation performed:

    • Delete object (DeleteObject)

      jsonPayload:{"DeleteObject":{"objectMetadataBefore":{"gcsObject":{"bucket":"test-bucket","generation":"1678912345678901","objectKey":"test_object.txt"}}}}
    • Put object hold (PutObjectHold)

      jsonPayload:{"PutObjectHold":{"objectMetadataBefore":{"gcsObject":{"bucket":"test-bucket","generation":"1678912345678901","objectKey":"test_object.txt"}},"temporaryHoldAfter":True,"eventBasedHoldAfter":True}}
    • Rewrite object (RewriteObject)

      jsonPayload:{"RewriteObject":{"objectMetadataBefore":{"gcsObject":{"bucket":"test-bucket","generation":"1678912345678901","objectKey":"test_object.txt"}},"kmsKeyVersionAfter":"projects/my-gcp-project/locations/us-central1/keyRings/my-keyring-01/cryptoKeys/my-encryption-key/cryptoKeyVersions/1"}}
    • Put metadata (PutMetadata)

      jsonPayload:{"PutMetadata":{"objectMetadataBefore":{"gcsObject":{"bucket":"test-bucket","generation":"1678912345678901","objectKey":"test_object.txt"}},"content_disposition_after":"attachment; filename=\"report_final.pdf\"","content_encoding_after":"gzip","content_language_after":"en-US","content_type_after":"application/pdf","cache_control_after":"public, max-age=3600","custom_time_after":"2025-06-27T10:00:00Z","custom_metadata_after":{"project":"marketing","version":"2.0","approvedBy":"Admin"}}}

    The following table describes the operation-specific log fields:

    Operation-specific log fieldsTypeDescription
    PutObjectHoldObjectIndicates a hold operation on an object.
    PutObjectHold.temporaryHoldAfterBooleanIf the value isTrue, it indicates that a temporary hold was applied to the object after the storage batch operations job completed. Valid values areTrue orFalse.
    PutObjectHold.eventBasedHoldAfterBooleanIf the value isTrue, it indicates that an event-based hold was applied to the object after the storage batch operations job completed. Valid values areTrue orFalse.
    RewriteObjectObjectIndicates a rewrite operation on an object.
    RewriteObject.kmsKeyVersionAfterStringThe Cloud Key Management Service key version used after the rewrite job. ThekmsKeyVersionAfter field is populated if the object's encryption key changed as a result of the rewrite. It's an optional field, meaning it might not be present if the Cloud KMS key version remained unchanged after the rewrite.
    PutMetadataObjectIndicates a metadata update operation on an object.
    PutMetadata.content_disposition_afterStringSpecifies theContent-Disposition header value after the completion of thePutMetadata job. It's an optional field and is only populated if the content disposition was set or modified.
    PutMetadata.content_encoding_afterStringSpecifies theContent-Encoding header value after the completion of thePutMetadata job. It's an optional field and is only populated if the content encoding was set or modified.
    PutMetadata.content_language_afterStringSpecifies theContent-Language header value after the completion of thePutMetadata job. It's an optional field and is only populated if the content language was set or modified.
    PutMetadata.content_type_afterStringSpecifies theContent-Type header value after the completion of thePutMetadata job. It's an optional field and is only populated if the content type was set or modified.
    PutMetadata.cache_control_afterStringSpecifies theCache-Control header value after the completion of thePutMetadata job. It's an optional field and is only populated if the cache control was set or modified.
    PutMetadata.custom_time_afterStringSpecifies theCustom-Time header value after the completion of thePutMetadata job. It's an optional field and is only populated if the custom time was set or modified.
    PutMetadata.custom_metadata_afterMap (key: string, value: string)Contains a map ofCustom- Metadata key-value pairs after the transformation. This field includes any user-defined metadata that was set or modified on the object. It allows for flexible storage of additional metadata.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.