Collect Cloud Run logs
This guide explains how to export Cloud Run logs to Google Security Operations using Cloud Storage. The parser extracts fields from JSON logs, transforming them into the Unified Data Model (UDM). It handles various log formats, including HTTP request data and system audit logs, mapping relevant fields to UDM while also enriching the data with labels and metadata specific to Cloud Run.
Before You Begin
Ensure that you have the following prerequisites:
- Google SecOps instance.
- Cloud Run is set up and active in your Google Cloud environment.
- Privileged access to Google Cloud.
Create a Google Cloud Storage Bucket
- Sign in to the Google Cloud console .
-  Go to the Cloud Storage Bucketspage. 
-  Click Create. 
-  On the Create a bucketpage, enter your bucket information. After each of the following steps, click Continueto proceed to the next step: -  In the Get startedsection, do the following: - Enter a unique name that meets the bucket name requirements; for example, cloudrun-logs.
-  To enable hierarchical namespace, click the expander arrow to expand the Optimize for file oriented and data-intensive workloadssection, and then select Enable Hierarchical namespace on this bucket. 
-  To add a bucket label, click the expander arrow to expand the Labelssection. 
-  Click Add label, and specify a key and a value for your label. 
 
-  In the Choose where to store your datasection, do the following: - Select a Location type.
-  Use the location type menu to select a Locationwhere object data within your bucket will be permanently stored. 
-  To set up cross-bucket replication, expand the Set up cross-bucket replicationsection. 
 
-  In the Choose a storage class for your datasection, either select a default storage classfor the bucket, or select Autoclassfor automatic storage class management of your bucket's data. 
-  In the Choose how to control access to objectssection, select notto enforce public access prevention, and select an access control modelfor your bucket's objects. 
-  In the Choose how to protect object datasection, do the following: - Select any of the options under Data protectionthat you want to set for your bucket.
- To choose how your object data will be encrypted, click the expander arrow labeled Data encryption, and select a Data encryption method.
 
 
-  
-  Click Create. 
Configure Log Export in Cloud Run
- On the Google Cloud Welcomepage, click the Cloud Runicon.
- Search Loggingin the search bar at the top and click Enter.
- In Log Explorer, filter the logs by choosing Cloud Runin Log Nameand click Apply.
- Click More Actions > Create Sinkfrom the menu.
- Provide the following configurations: - Sink Details: enter a name and description.
- Click Next.
- Sink Destination: select Cloud Storage Bucket.
- Cloud Storage Bucket: select the bucket created earlier or create a new bucket.
- Click Next.
- Choose Logs to include in Sink: a default log is populated when you select an option in Cloud Storage Bucket.
- Click Next.
- Optional: Choose Logs to filter out of Sink: select the logs that you would like not to sink.
 
- Click Create Sink.
Set up feeds
To configure a feed, follow these steps:
- Go to SIEM Settings > Feeds.
- Click Add New Feed.
- On the next page, click Configure a single feed.
- In the Feed namefield, enter a name for the feed; for example, Cloud Run Logs.
- Select Google Cloud Storage V2as the Source type.
- Select GCP Cloud Runas the Log type.
- Click Get Service Accountas the Chronicle Service Account.
- Click Next.
-  Specify values for the following input parameters: -  Storage Bucket URI: Google Cloud storage bucket URL in  gs://my-bucket/<value>/format. This URL must end with a trailing forward slash (/).
-  Source deletion options: select deletion option according to your preference. 
-  Maximum File Age: Includes files modified in the last number of days. Default is 180 days. 
 
-  Storage Bucket URI: Google Cloud storage bucket URL in  
-  Click Next. 
-  Review your new feed configuration in the Finalizescreen, and then click Submit. 
UDM Mapping Table
| Log Field | UDM Mapping | Logic | 
|---|---|---|
| httpRequest.latency | target.resource.attribute.labels.[] | The value of httpRequest.latencyfrom the raw log is used as the value for a label with keyhttp_request_latencywithintarget.resource.attribute.labels. | 
| httpRequest.protocol | network.application_protocol | If httpRequest.protocolcontainsHTTP, the UDM field is set toHTTP. | 
| httpRequest.remoteIp | principal.asset.ip | The value of httpRequest.remoteIpfrom the raw log is used. | 
| httpRequest.remoteIp | principal.ip | The value of httpRequest.remoteIpfrom the raw log is used. | 
| httpRequest.requestMethod | network.http.method | The value of httpRequest.requestMethodfrom the raw log is used. | 
| httpRequest.requestSize | network.sent_bytes | The value of httpRequest.requestSizefrom the raw log is converted to an unsigned integer and used. | 
| httpRequest.requestUrl | target.url | The value of httpRequest.requestUrlfrom the raw log is used. | 
| httpRequest.responseSize | network.received_bytes | The value of httpRequest.responseSizefrom the raw log is converted to an unsigned integer and used. | 
| httpRequest.serverIp | target.asset.ip | The value of httpRequest.serverIpfrom the raw log is used. | 
| httpRequest.serverIp | target.ip | The value of httpRequest.serverIpfrom the raw log is used. | 
| httpRequest.status | network.http.response_code | The value of httpRequest.statusfrom the raw log is converted to an integer and used. | 
| httpRequest.userAgent | network.http.parsed_user_agent | The value of httpRequest.userAgentfrom the raw log is parsed as a user agent string. | 
| httpRequest.userAgent | network.http.user_agent | The value of httpRequest.userAgentfrom the raw log is used. | 
| insertId | metadata.product_log_id | The value of insertIdfrom the raw log is used. | 
| labels.instanceId | additional.fields.[] | The value of labels.instanceIdis used as the value for a label with keyinstanceIdwithinadditional.fields. | 
| labels.run.googleapis.com_execution_name | additional.fields.[] | The value of labels.run.googleapis.com_execution_nameis used as the value for a label with keyexecution_namewithinadditional.fields. | 
| labels.run.googleapis.com_task_attempt | additional.fields.[] | The value of labels.run.googleapis.com_task_attemptis used as the value for a label with keytask_attemptwithinadditional.fields. | 
| labels.run.googleapis.com_task_index | additional.fields.[] | The value of labels.run.googleapis.com_task_indexis used as the value for a label with keytask_indexwithinadditional.fields. | 
| logName | metadata.product_event_type | The value of logNamefrom the raw log is used. | 
| resource.labels.configuration_name | target.resource.attribute.labels.[] | The value of resource.labels.configuration_nameis used as the value for a label with keyconfiguration_namewithintarget.resource.attribute.labels. | 
| resource.labels.job_name | additional.fields.[] | The value of resource.labels.job_nameis used as the value for a label with keyjob_namewithinadditional.fields. | 
| resource.labels.location | target.location.name | The value of resource.labels.locationfrom the raw log is used. | 
| resource.labels.project_id | target.resource.attribute.labels.[] | The value of resource.labels.project_idis used as the value for a label with keyproject_idwithintarget.resource.attribute.labels. | 
| resource.labels.revision_name | target.resource.attribute.labels.[] | The value of resource.labels.revision_nameis used as the value for a label with keyrevision_namewithintarget.resource.attribute.labels. | 
| resource.labels.service_name | target.resource.attribute.labels.[] | The value of resource.labels.service_nameis used as the value for a label with keyservice_namewithintarget.resource.attribute.labels. | 
| resource.type | target.resource.resource_subtype | The value of resource.typefrom the raw log is used. | 
| severity | security_result.severity | If the value of severitymatchesInfo(case-insensitive), the UDM field is set toINFORMATIONAL. | 
| textPayload | additional.fields.[] | The value of textPayloadis used as the value for a label with keyTextpayloadwithinadditional.fields. | 
| timestamp | metadata.event_timestamp | The value of timestampfrom the raw log is parsed as a timestamp. | 
| timestamp | timestamp | The value of timestampfrom the raw log is parsed as a timestamp. Determined by parser logic based on the presence of certain fields. Defaults toGENERIC_EVENT. Ifhas_principal_ip,has_target_ip, andhttpRequest.protocolmatchesHTTP, it's set toNETWORK_HTTP. Hardcoded toGCP_RUN. Hardcoded toGCP_RUN. Hardcoded toGoogle Cloud Platform. Hardcoded toGOOGLE_CLOUD_PLATFORM. | 
Need more help? Get answers from Community members and Google SecOps professionals.

