Compute Engine audit logging information


This document describes the audit logs created by Compute Engine as part of Cloud Audit Logs.

Overview

Google Cloud services write audit logs to help you answer the questions, "Who did what, where, and when?" within your Google Cloud resources.

Your Google Cloud projects contain only the audit logs for resources that are directly within the Google Cloud project. Other Google Cloud resources, such as folders, organizations, and billing accounts, contain the audit logs for the entity itself.

For a general overview of Cloud Audit Logs, see Cloud Audit Logs overview. For a deeper understanding of the audit log format, see Understand audit logs.

Available audit logs

The following types of audit logs are available for Compute Engine:

  • Admin Activity audit logs

    Includes "admin write" operations that write metadata or configuration information.

    You can't disable Admin Activity audit logs.

  • Data Access audit logs

    Includes "admin read" operations that read metadata or configuration information. Also includes "data read" and "data write" operations that read or write user-provided data.

    To receive Data Access audit logs, you must explicitly enable them.

  • System Event audit logs

    Identifies automated Google Cloud actions that modify the configuration of resources.

    You can't disable System Event audit logs.

For fuller descriptions of the audit log types, see Types of audit logs.

Audited operations

The following table summarizes which API operations correspond to each audit log type in Compute Engine:

Audit logs category Subtype Compute Engine operations Examples
Admin Activity audit logs N/A
  • Creating resources
  • Updating/patching resources
  • Setting/changing metadata
  • Setting/changing tags
  • Setting/changing labels
  • Setting/changing permissions
  • Setting/changing any properties of a resource (including custom verbs)
  • compute.instances.insert
  • compute.instanceGroups.removeInstances
  • compute.instances.setMetadata
  • compute.instances.setTags
  • compute.instances.setLabels
  • compute.instances.setIamPolicy
  • compute.instances.update
Data Access audit logs1 ADMIN_READ
  • Getting information about a resource
  • Listing resources
  • Listing resources across scope (aggregated list requests)
  • compute.images.get
  • compute.instances.list
  • compute.interconnectAttachments.aggregatedList
DATA_READ Get the contents of the serial port console compute.instance.getSerialPortOutput
System Event audit logs N/A
  • On host maintenance
  • Instance preemption
  • Automatic restart
  • Instance reset
  • Serial port connect/disconnect 2
  • compute.instances.migrateOnHostMaintenance
  • compute.instances.automaticRestart
  • compute.instanceGroupManagers.resizeAdvanced
  • google.ssh-serialport.v1.connect

1Data Access audit logs: Unlike audit logs for other services, Compute Engine only has ADMIN_READ data access logs and doesn't generally offer DATA_READ and DATA_WRITE logs. This is because DATA_READ and DATA_WRITE logs are only used for services that store and manage user data such as Cloud Storage, Spanner, and Cloud SQL, and this doesn't apply to Compute Engine. There is one exception to this rule: instance.getSerialPortOutput does generate a DATA_READ log because the method reads data directly from the VM instance.

2Serial port connect/disconnect: For more information about serial console audit logs, see Viewing serial console audit logs.

Data redaction in audit logs

Audit logs record the request and response data of the API actions that were performed. However, in the following circumstances, the request or response info is unavailable or is redacted:

  • For instance.setMetadata and project.setCommonInstanceMetadata API requests, the metadata portion of the request body is redacted to avoid logging sensitive information sent in the metadata.
  • Sensitive fields are redacted from requests, such as private keys for SSL certificates and customer-supplied encryption keys for disks.
  • For get and list responses, the response body is redacted to avoid logging private information.

Audit log format

Audit log entries include the following objects:

  • The log entry itself, which is an object of type LogEntry. Useful fields include the following:

    • The logName contains the resource ID and audit log type.
    • The resource contains the target of the audited operation.
    • The timeStamp contains the time of the audited operation.
    • The protoPayload contains the audited information.
  • The audit logging data, which is an AuditLog object held in the protoPayload field of the log entry.

  • Optional service-specific audit information, which is a service-specific object. For earlier integrations, this object is held in the serviceData field of the AuditLog object; later integrations use the metadata field.

For other fields in these objects, and how to interpret them, review Understand audit logs.

Log name

Cloud Audit Logs log names include resource identifiers indicating the Google Cloud project or other Google Cloud entity that owns the audit logs, and whether the log contains Admin Activity, Data Access, Policy Denied, or System Event audit logging data.

The following are the audit log names, including variables for the resource identifiers:

   projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Factivity
   projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fdata_access
   projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fsystem_event
   projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fpolicy

   folders/FOLDER_ID/logs/cloudaudit.googleapis.com%2Factivity
   folders/FOLDER_ID/logs/cloudaudit.googleapis.com%2Fdata_access
   folders/FOLDER_ID/logs/cloudaudit.googleapis.com%2Fsystem_event
   folders/FOLDER_ID/logs/cloudaudit.googleapis.com%2Fpolicy

   billingAccounts/BILLING_ACCOUNT_ID/logs/cloudaudit.googleapis.com%2Factivity
   billingAccounts/BILLING_ACCOUNT_ID/logs/cloudaudit.googleapis.com%2Fdata_access
   billingAccounts/BILLING_ACCOUNT_ID/logs/cloudaudit.googleapis.com%2Fsystem_event
   billingAccounts/BILLING_ACCOUNT_ID/logs/cloudaudit.googleapis.com%2Fpolicy

   organizations/ORGANIZATION_ID/logs/cloudaudit.googleapis.com%2Factivity
   organizations/ORGANIZATION_ID/logs/cloudaudit.googleapis.com%2Fdata_access
   organizations/ORGANIZATION_ID/logs/cloudaudit.googleapis.com%2Fsystem_event
   organizations/ORGANIZATION_ID/logs/cloudaudit.googleapis.com%2Fpolicy

Service name

Compute Engine audit logs uses the following service names:

  • compute.googleapis.com
  • ssh-serialport.googleapis.com
  • oslogin.googleapis.com

For a list of all the Cloud Logging API service names and their corresponding monitored resource type, see Map services to resources.

Resource types

Compute Engine audit logs use the following resource types for audit logs:

Resource type category Description Examples
API resource This resource logs API operations. api
Audited resource This resource logs Google Cloud operations. The audited resource type is mostly used for new operations that do not fit into the other categories. audited_resource
Autoscaler This resource logs autoscaler operations. autoscaler
Deployment resource This resource logs deployment operations. deployment
Cloud Deployment Manager resources (deployment_manager_*)

This resource logs Cloud Deployment Manager operations.

The deployment_manager_* resource types map to the Cloud Deployment Manager resources. For a full list of Cloud Deployment Manager resources, see Cloud Deployment Manager API overview.

  • deployment_manager_manifest
  • deployment_manager_operation
  • deployment_manager_resource
  • deployment_manager_type
Compute Engine resources (gce_*)

This resource logs Compute Engine operations.

The gce_* resource types map to the Compute Engine resources. For a full list of Compute Engine resources, see Compute Engine API overview.

  • gce_instance
  • gce_backend_service
  • gce_operation
  • gce_instance_group
  • gce_firewall_rule
  • gce_snapshot
  • gce_route
  • gce_disk
  • gce_health_check
Network security resource This resource logs Network security policy operations. network_security_policy
Cloud VPN resources (vpn_*) This resource logs Cloud VPN operations.
  • vpn_gateway
  • vpn_tunnel

For a list of all the Cloud Logging monitored resource types and descriptive information, see Monitored resource types.

Caller identities

The IP address of the caller is held in the RequestMetadata.caller_ip field of the AuditLog object. Logging might redact certain caller identities and IP addresses.

For information about what information is redacted in audit logs, see Caller identities in audit logs.

Enable audit logging

System Event audit logs are always enabled; you can't disable them.

Admin Activity audit logs are always enabled; you can't disable them.

Data Access audit logs are disabled by default and aren't written unless explicitly enabled (the exception is Data Access audit logs for BigQuery, which can't be disabled).

For information about enabling some or all of your Data Access audit logs, see Enable Data Access audit logs.

Permissions and roles

IAM permissions and roles determine your ability to access audit logs data in Google Cloud resources.

When deciding which Logging-specific permissions and roles apply to your use case, consider the following:

  • The Logs Viewer role (roles/logging.viewer) gives you read-only access to Admin Activity, Policy Denied, and System Event audit logs. If you have just this role, you cannot view Data Access audit logs that are in the _Default bucket.

  • The Private Logs Viewer role(roles/logging.privateLogViewer) includes the permissions contained in roles/logging.viewer, plus the ability to read Data Access audit logs in the _Default bucket.

    Note that if these private logs are stored in user-defined buckets, then any user who has permissions to read logs in those buckets can read the private logs. For more information about log buckets, see Routing and storage overview.

For more information about the IAM permissions and roles that apply to audit logs data, see Access control with IAM.

View logs

You can query for all audit logs or you can query for logs by their audit log name. The audit log name includes the resource identifier of the Google Cloud project, folder, billing account, or organization for which you want to view audit logging information. Your queries can specify indexed LogEntry fields, and if you use the Log Analytics page, which supports SQL queries, then you can view your query results as a chart.

For more information about querying your logs, see the following pages:

You can view audit logs in Cloud Logging by using the Google Cloud console, the Google Cloud CLI, or the Logging API.

Console

In the Google Cloud console, you can use the Logs Explorer to retrieve your audit log entries for your Google Cloud project, folder, or organization:

  1. In the navigation panel of the Google Cloud console, select Logging, and then select Logs Explorer:

    Go to Logs Explorer

  2. Select an existing Google Cloud project, folder, or organization.

  3. To display all audit logs, enter either of the following queries into the query-editor field, and then click Run query:

    logName:"cloudaudit.googleapis.com"
    
    protoPayload."@type"="type.googleapis.com/google.cloud.audit.AuditLog"
    
  4. To display the audit logs for a specific resource and audit log type, in the Query builder pane, do the following:

    • In Resource type, select the Google Cloud resource whose audit logs you want to see.

    • In Log name, select the audit log type that you want to see:

      • For Admin Activity audit logs, select activity.
      • For Data Access audit logs, select data_access.
      • For System Event audit logs, select system_event.
      • For Policy Denied audit logs, select policy.
    • Click Run query.

    If you don't see these options, then there aren't any audit logs of that type available in the Google Cloud project, folder, or organization.

    If you're experiencing issues when trying to view logs in the Logs Explorer, see the troubleshooting information.

    For more information about querying by using the Logs Explorer, see Build queries in the Logs Explorer. For information about summarizing log entries in the Logs Explorer by using Duet AI, see Summarize log entries with Duet AI assistance.

gcloud

The Google Cloud CLI provides a command-line interface to the Logging API. Supply a valid resource identifier in each of the log names. For example, if your query includes a PROJECT_ID, then the project identifier you supply must refer to the currently selected Google Cloud project.

To read your Google Cloud project-level audit log entries, run the following command:

gcloud logging read "logName : projects/PROJECT_ID/logs/cloudaudit.googleapis.com" \
    --project=PROJECT_ID

To read your folder-level audit log entries, run the following command:

gcloud logging read "logName : folders/FOLDER_ID/logs/cloudaudit.googleapis.com" \
    --folder=FOLDER_ID

To read your organization-level audit log entries, run the following command:

gcloud logging read "logName : organizations/ORGANIZATION_ID/logs/cloudaudit.googleapis.com" \
    --organization=ORGANIZATION_ID

To read your Cloud Billing account-level audit log entries, run the following command:

gcloud logging read "logName : billingAccounts/BILLING_ACCOUNT_ID/logs/cloudaudit.googleapis.com" \
    --billing-account=BILLING_ACCOUNT_ID

Add the --freshness flag to your command to read logs that are more than 1 day old.

For more information about using the gcloud CLI, see gcloud logging read.

API

When building your queries, supply a valid resource identifier in each of the log names. For example, if your query includes a PROJECT_ID, then the project identifier you supply must refer to the currently selected Google Cloud project.

For example, to use the Logging API to view your project-level audit log entries, do the following:

  1. Go to the Try this API section in the documentation for the entries.list method.

  2. Put the following into the Request body part of the Try this API form. Clicking this prepopulated form automatically fills the request body, but you need to supply a valid PROJECT_ID in each of the log names.

    {
      "resourceNames": [
        "projects/PROJECT_ID"
      ],
      "pageSize": 5,
      "filter": "logName : projects/PROJECT_ID/logs/cloudaudit.googleapis.com"
    }
    
  3. Click Execute.

Sample queries

To find audit logs for Compute Engine, use the following queries in the Logs Explorer:

Query name Expression
Host error
resource.type="gce_instance"
protoPayload.serviceName="compute.googleapis.com"
(protoPayload.methodName:"compute.instances.hostError" OR
  operation.producer:"compute.instances.hostError")
log_id("cloudaudit.googleapis.com/system_event")
resource.labels.instance_id="INSTANCE_ID"
severity="INFO"
Host maintenance
resource.type="gce_instance"
protoPayload.serviceName="compute.googleapis.com"
(protoPayload.methodName:"OnHostMaintenance" OR
  operation.producer:"OnHostMaintenance")
log_id("cloudaudit.googleapis.com/system_event")
resource.labels.instance_id="INSTANCE_ID"
severity=INFO
Host migrated
resource.type="gce_instance"
protoPayload.serviceName="compute.googleapis.com"
(protoPayload.methodName:"compute.instances.migrateOnHostMaintenance" OR
  operation.producer:"compute.instances.migrateOnHostMaintenance")
log_id("cloudaudit.googleapis.com/system_event")
resource.labels.instance_id="INSTANCE_ID"
severity=INFO
Instance terminated or preempted
resource.type="gce_instance"
protoPayload.methodName=~"compute.instances.(guestTerminate|preempted)"
log_id("cloudaudit.googleapis.com/activity")
resource.labels.instance_id="INSTANCE_ID"
Instance terminated by guest OS
resource.type="gce_instance"
protoPayload.serviceName="compute.googleapis.com"
(protoPayload.methodName:"compute.instances.guestTerminate" OR
  operation.producer:"compute.instances.guestTerminate")
log_id("cloudaudit.googleapis.com/system_event")
resource.labels.instance_id="INSTANCE_ID"
severity=INFO
Instance terminated on host maintenance
resource.type="gce_instance"
protoPayload.serviceName="compute.googleapis.com"
(protoPayload.methodName:"compute.instances.terminateOnHostMaintenance" OR
  operation.producer:"compute.instances.terminateOnHostMaintenance")
log_id("cloudaudit.googleapis.com/system_event")
resource.labels.instance_id="INSTANCE_ID"
severity=INFO
Instance created
resource.type="gce_instance"
protoPayload.methodName:"compute.instances.insert"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.request.name="INSTANCE_NAME"
Instance name deleted
resource.type="gce_instance"
protoPayload.methodName:"compute.instances.delete"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.resourceName:"INSTANCE_NAME"
Instance ID deleted
resource.type="gce_instance"
protoPayload.methodName:"compute.instances.delete"
log_id("cloudaudit.googleapis.com/activity")
resource.labels.instance_id="INSTANCE_ID"
Instance restarted
resource.type="gce_instance"
protoPayload.methodName=~
  "compute.instances.(stop|reset|automaticRestart|
  guestTerminate|instanceManagerHaltForRestart)"
(log_id("cloudaudit.googleapis.com/activity")
  OR log_id("cloudaudit.googleapis.com/system_event"))
resource.labels.instance_id="INSTANCE_ID"
Persistent disk created
resource.type="gce_disk"
protoPayload.methodName:"compute.disks.insert"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.request.name="PD_NAME"
Persistent disk deleted
resource.type="gce_disk"
protoPayload.methodName:"compute.disks.delete"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.resourceName="PD_NAME"
Nodes added in sole tenant nodes
resource.type="gce_node_group"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.methodName=~("compute.nodeGroups.addNodes" OR 
  "compute.nodeGroups.insert")
resource.labels.node_group_id="NODE_GROUP_ID"
Autoscale events in sole tenant nodes
resource.type="gce_node_group"
log_id("cloudaudit.googleapis.com/system_event")
protoPayload.methodName=~("compute.nodeGroups.deleteNodes" OR 
  "compute.nodeGroups.addNodes")
resource.labels.node_group_id="NODE_GROUP_ID"
Snapshot taken manually
resource.type="gce_disk"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.methodName:"compute.disks.createSnapshot"
protoPayload.request.sourceDisk:"PD_NAME"
protoPayload.request.name="SNAPSHOT_NAME"
Scheduled snapshot taken
resource.type="gce_disk"
log_id("cloudaudit.googleapis.com/system_event")
protoPayload.methodName="ScheduledSnapshots"
protoPayload.response.operationType="createSnapshot"
protoPayload.response.targetLink="PD_NAME"
Snapshot deleted manually
resource.type="gce_snapshot"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.methodName:"compute.snapshots.delete"
protoPayload.resourceName:"SNAPSHOT_NAME"
Snapshot schedule created
resource.type="gce_resource_policy"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.methodName:"compute.resourcePolicies.insert"
protoPayload.request.name="SCHEDULE_NAME"
Snapshot schedule deleted
resource.type="gce_resource_policy"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.methodName:"compute.resourcePolicies.delete"
protoPayload.request.name="SCHEDULE_NAME"
Snapshot schedule attached
resource.type="gce_disk"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.methodName:"compute.disks.addResourcePolicies"
protoPayload.request.resourcePolicys:"SCHEDULE_NAME"
protoPayload.resourceName:"PD_NAME"
Snapshot schedule detached
resource.type="gce_disk"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.methodName:"compute.disks.removeResourcePolicies"
protoPayload.request.resourcePolicys:"SCHEDULE_NAME"
protoPayload.resourceName:"PD_NAME"
Instance removed or added from instance group
resource.type="gce_instance_group"
protoPayload.methodName:"compute.instanceGroups.*"
log_id("cloudaudit.googleapis.com/activity")
resource.labels.instance_group_name="INSTANCE_GROUP_NAME"
Instance template set or updated for a managed instance group
resource.type="gce_instance_group_manager"
log_id("cloudaudit.googleapis.com/activity")
protoPayload.methodName="v1.compute.instanceGroupManagers.setInstanceTemplate"
resource.labels.instance_group_manager_name="INSTANCE_GROUP_NAME"
Managed instance group autoscaler scale in and out
resource.type="autoscaler"
resource.labels.project_id="PROJECT"
resource.labels.autoscaler_name="AUTOSCALER_NAME"
Firewall rule deleted
resource.type="gce_firewall_rule" AND
log_id("cloudaudit.googleapis.com/activity") AND
protoPayload.methodName:"firewalls.delete"

To use the sample queries, do the following:

  1. Replace the variables with your own project information, then copy the expression using the clipboard icon .

  2. In the navigation panel of the Google Cloud console, select Logging, and then select Logs Explorer:

    Go to Logs Explorer

  3. Enable Show query to open the query-editor field, then paste the expression into the query-editor field:

    The query editor where you enter sample queries.

  4. Click Run query. Logs that match your query are listed in the Query results pane.

Route audit logs

You can route audit logs to supported destinations in the same way that you can route other kinds of logs. Here are some reasons you might want to route your audit logs:

  • To keep audit logs for a longer period of time or to use more powerful search capabilities, you can route copies of your audit logs to Cloud Storage, BigQuery, or Pub/Sub. Using Pub/Sub, you can route to other applications, other repositories, and to third parties.

  • To manage your audit logs across an entire organization, you can create aggregated sinks that can route logs from any or all Google Cloud projects in the organization.

  • If your enabled Data Access audit logs are pushing your Google Cloud projects over your log allotments, you can create sinks that exclude the Data Access audit logs from Logging.

For instructions about routing logs, see Route logs to supported destinations.

Pricing

For more information about pricing, see Cloud Logging pricing summary.