Cloud Audit Logging maintains three audit logs for each project, folder, and organization: Admin Activity, System Event and Data Access. Google Cloud Platform services write audit log entries to these logs to help you answer the questions of "who did what, where, and when?" within your GCP projects.
For a list of GCP services that write audit logs, see Services producing audit logs. All GCP services will eventually write audit logs.
Admin Activity logs
Admin Activity logs contain log entries for API calls or other administrative actions that modify the configuration or metadata of resources. For example, the logs record when VM instances and App Engine applications are created and when permissions are changed. To view the logs, you must have the Cloud Identity and Access Management (IAM) roles Logging/Logs Viewer or Project/Viewer.
Admin Activity logs are always enabled. There is no charge for your Admin Activity audit logs. For more information, see Logging usage limits.
System Event logs
System Event logs contain log entries for when Compute Engine performs a system event. For example, each live migration is recorded as a system event. To view the logs, you must have the Cloud IAM roles Logging/Logs Viewer or Project/Viewer.
System Event logs are always enabled. There is no charge for your System Event audit logs. For more information, see Logging usage limits.
Data Access logs
Data Access audit logs record API calls that create, modify, or read user-provided data. To view the logs, you must have the Cloud IAM roles Logging/Private Logs Viewer or Project/Owner.
Data Access audit logs do not record the above data-access operations on resources that are publicly shared (available to All Users or All Authenticated Users) or that can be accessed without logging into GCP.
Data Access audit logs are disabled by default because they can be quite large. Enabling the logs might result in your project being charged for the additional logs usage.
BigQuery Data Access logs are handled differently from other Data Access logs. BigQuery logs are enabled by default and cannot be disabled. They do not count against your logs allotment.
To enable and configure Data Access logs, see Configuring Data Access Logs.
For more information about logs allotments, see Logging usage limits.
Audit log entry structure
Every audit log entry in Stackdriver Logging is an object of type
LogEntry
that is characterized by the following information:
- The project or organization that owns the log entry.
- The resource to which the log entry applies. This consists of a resource type from the Monitored Resource List and additional values that denote a specific instance.
- A log name.
- A timestamp.
- A payload, which is the protoPayload type. The payload of each
audit log entry is an object of type
AuditLog
, a protocol buffer, and contains a field,serviceData
, that some services use to hold additional information.
All audit log entries contain the name of an audit log, a resource, and a service. You can use these names to filter audit log entries:
- Log name: Audit log entries belong to logs within projects, folders, and organizations. The log names are listed below:
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 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 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
Within a project, folder, or organization, these log names are typically abbreviated activity, system_event, and data_access.
Resource: Each audit log entry includes a resource of some type. For example, you can view audit log entries from a single Compute Engine VM instance or from all VM instances. For the list of resource types, see Monitored resource types.
Service: Services are individual GCP products, such as Compute Engine, Cloud SQL, or Cloud Pub/Sub. Each service is identified by name: Compute Engine is
compute.googleapis.com
, Cloud SQL iscloudsql.googleapis.com
, and so forth.Resource types belongs to a single service, but a service can have several resource types. For a list of services and resources, see Mapping services to resources.
For more details, see Audit Log Datatypes.
To understand how to read and interpret audit log entries, see Understanding audit logs.
Viewing audit logs
You have several options for viewing your audit log entries:
Basic Viewer
You can use the Logs Viewer basic interface in the GCP Console to retrieve your audit log entries. Do the following:
Go to the Stackdriver Logging > Logs (Logs Viewer) page in the GCP Console:
Select an existing GCP project at the top of the page, or create a new project.
In the first drop-down menu, select the resource type whose audit logs you wish to see. You can select a specific resource or
Global
for all resources.In the second drop-down menu, select the log type you want to see:
activity
for Admin Activity audit logs,data_access
for Data Access audit logs, andsystem_events
for System Event logs.If you do not see any of those options, then there are no audit logs of that type available in the project.
Advanced Viewer
You can use the Logs Viewer advanced interface in the GCP Console to retrieve your audit log entries. Do the following:
Go to the Stackdriver Logging > Logs (Logs Viewer) page in the GCP Console:
Select an existing GCP project at the top of the page, or create a new project.
In the first drop-down menu, select the resource type whose audit logs you wish to see. You can select a specific resource or
Global
for all resources.Click the drop-down arrow (▾) at the far right of the search-filter box and select Convert to advanced filter.
Create a filter that further specifies the log entries you want to see. To retrieve all audit logs in your project, add the following filter. Supply a valid
[PRODUCT_ID]
in each of the log names.logName = ("projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Factivity" OR "projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fsystem_events" OR "projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fdata_access")
For more details about filters, see Advanced logs filters.
API
To look at your audit log entries using the Stackdriver Logging API:
Go to the Try this API section in the documentation for the
entries.list
method.Put the following into the Request body part of the Try this API form. Clicking on this prepopulated form automatically fills the request body, but you will need to supply a valid
[PRODUCT_ID]
in each of the log names.{ "resourceNames": [ "projects/[PROJECT_ID]" ], "pageSize": 5, "filter": "logName=(projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Factivity OR projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fsystem_events OR projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fdata_access)" }
Click Execute.
For more details about filters, see Advanced logs filters.
SDK
To read your log entries using the Cloud SDK, run the following
command. Supply a valid [PRODUCT_ID]
in each of the log names.
gcloud logging read "logName=(projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Factivity OR projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fsystem_events OR projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fdata_access)
See Reading log entries for more information about using the Cloud SDK.
Using the Activity page
You can view abbreviated, project-level audit log entries in your project's Activity page in the GCP Console. See the page Home > Activity. Use Filter to select the entries you want to see. The actual audit log entries might contain more information than you see in the Activity page.
In the Activity page, where the identity performing logged actions is
redacted from the audit log entry, you see User (anonymized)
. See
User identities in audit logs for details.
Exporting audit logs
You can export audit log entries to Stackdriver Logging or to certain GCP services.
To export audit log entries outside of Stackdriver Logging, create a logs sink. Give the sink a filter that selects the audit log entries you want to export.
For more information, see Overview of Logs Exports.
Audit log retention
Individual audit log entries are kept for a specified length of time and are then deleted. The Logging Quota Policy explains how long log entries are retained. You cannot otherwise delete or modify audit logs or their entries.
Audit log type | Retention period |
---|---|
Admin Activity | 400 days |
Data Access | 30 days |
System Event | 400 days |
For longer retention, you can export audit log entries like any other Logging log entries and keep them for as long as you wish.
User identities in audit logs
Audit logs record the identity that performed the logged actions.
The identity is held in the AuthenticationInfo
field of
AuditLog objects.
In the following circumstances, the identity is unavailable or is redacted:
All audit logs: For privacy reasons, the principal email address is redacted for all read-only operations that fail with a "permission denied" error.
App Engine: Identities are not collected from the legacy App Engine API.
BigQuery: Identities and caller IP addresses are currently redacted from the audit logs, unless at least one of the following conditions are met:
- This is not a read-only access.
- The identity is a service account that belongs to the project.
- The identity is a member of the domain associated with the project.
Project domain in this context is a BigQuery setting. If you would like to change the domain associated with your project, contact BigQuery support.
There are additional rules that apply for cross-project access:
Here, the billing project is the project issuing the request, and the data project is the project whose resources are also accessed during the job. An example is query job in a billing project that reads some table data from the data project.
The billing project resource ID will be redacted from the data project log unless the projects have the same domain associated with them or are in the same organization.
Identities and caller IP addresses will be redacted from the data project log unless one of the conditions above apply, or:
- Billing project and data project have the same domain associated with them or are in the same organization, and billing project already includes the identity and caller IP address.
- The identity has permission to run queries in the project and the action
is a
job.insert
action.
If you are viewing audit logs using the Google Cloud Platform Console
Activity page, you see User (anonymized)
for any log
entries where identity is redacted or empty.
GCP services producing audit logs
The table below lists the Google Cloud Platform services that write Admin Activity or Data Access audit logs. GA indicates that a log type is Generally Available for a service; Beta indicates that a log type is available, but might be changed in backward-incompatible ways and is not subject to any SLA or deprecation policy. All GCP services will eventually write audit logs.
For a list of Stackdriver Logging API service names, see Mapping services to resources.
To enable Data Access logs, see Configuring Data Access Logs.
1: This service does not produce Data Access logs.
2: BigQuery data access logs are enabled by default and do
not count against your logs allotment.
3: This service does not produce Admin Activity logs.
4: Audits OAuth 2.0 client IDs and brands.
5: Does not yet include request/response information.
6: Audits requests to start managed import or export operations.
Audit does not include entity-specific read/write logs for those operations.