Cloud Audit Logs

Cloud Audit Logs maintains three audit logs for each Google Cloud project, folder, and organization: Admin Activity, Data Access, and System Event. Google Cloud services write audit log entries to these logs to help you answer the questions of "who did what, where, and when?" within your Google Cloud resources.

For a list of Google Cloud services that provide audit logs, go to Google services with audit logs. All Google Cloud services will eventually provide audit logs.

Admin Activity audit logs

Admin Activity audit logs contain log entries for API calls or other administrative actions that modify the configuration or metadata of resources. For example, these logs record when users create VM instances or change Cloud Identity and Access Management permissions.

To view these logs, you must have the Cloud IAM role Logging/Logs Viewer or Project/Viewer.

Admin Activity audit logs are always written; you can't configure or disable them. There is no charge for your Admin Activity audit logs. For details on logging usage limits, go to Quotas and limits.

Data Access audit logs

Data Access audit logs contain API calls that read the configuration or metadata of resources, as well as user-driven API calls that create, modify, or read user-provided resource data. Data Access audit logs do not record the 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 Google Cloud.

To view these logs, you must have the Cloud IAM roles Logging/Private Logs Viewer or Project/Owner.

Data Access audit logs are disabled by default because they can be quite large; they must be explicitly enabled to be written. Enabling the logs might result in your project being charged for the additional logs usage. For instructions on enabling and configuring Data Access audit logs, go to Configuring Data Access logs.

For details on logging usage limits, go to Quotas and limits. For details on costs you might incur, go to Pricing.

System Event audit logs

System Event audit logs contain log entries for Google Cloud administrative actions that modify the configuration of resources. System Event audit logs are generated by Google systems; they are not driven by direct user action.

To view these logs, you must have the Cloud IAM role Logging/Logs Viewer or Project/Viewer.

System Event audit logs are always written; you can't configure or disable them. There is no charge for your System Event audit logs. For details on logging usage limits, go to Quotas and limits.

Audit log entry structure

Every audit log entry in Stackdriver Logging is an object of type LogEntry. What distinguishes an audit log entry from other log entries is the protoPayload field; this field contains an AuditLog object that stores the audit logging data.

To understand how to read and interpret audit log entries, review Understanding audit logs.

Viewing audit logs

To find audit logs, you need to know the identifier of the Google Cloud project, folder, or organization for which you want to view audit logging information. You can further specify other indexed LogEntry fields, like resource.type; for details, review Finding log entries quickly.

Here are the audit log names:

   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

You have several options for viewing your audit log entries:

Basic Viewer

You can use the Logs Viewer basic interface in the Cloud Console to retrieve your audit log entries. Do the following:

  1. Go to the Stackdriver Logging > Logs (Logs Viewer) page in the Cloud Console:

    Go to the Logs Viewer page

  2. Select an existing Google Cloud project at the top of the page, or create a new project.

  3. 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.

  4. In the second drop-down menu, select the log type you want to see: activity for Admin Activity audit logs,data_accessfor Data Access audit logs, and system_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 Cloud Console to retrieve your audit log entries. Do the following:

  1. Go to the Stackdriver Logging > Logs (Logs Viewer) page in the Cloud Console:

    Go to the Logs Viewer page

  2. Select an existing Google Cloud project at the top of the page, or create a new project.

  3. 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.

  4. Click the drop-down arrow (▾) at the far right of the search-filter box and select Convert to advanced filter.

  5. Create a query that further specifies the log entries you want to see. To retrieve all audit logs in your project, add the following query. Supply a valid [PROJECT_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 queries, see Advanced logs queries.

API

To look at your audit log entries using the Logging API:

  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 on this prepopulated form automatically fills the request body, but you will 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%2Factivity OR projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fsystem_events OR projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fdata_access)"
      }
    
  3. Click Execute.

For more details about queries, see Advanced logs queries.

GCLOUD

The Cloud SDK has a group of commands, gcloud logging, that provide a command-line interface to the Stackdriver Logging API. To read your log entries, run the following command. Supply a valid [PROJECT_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 gcloud command-line tool.

Using the Activity page

You can view abbreviated, project-level audit log entries in your project's Activity page in the Cloud Console. Go to the page Home > Activity. Use Filter to select the entries you want to view. The actual audit log entries might contain more information than appears in the Activity page.

Go to the Activity page

In the Activity page, where the identity performing logged actions is redacted from the audit log entry, User (anonymized) is displayed. For more details, read User identities in audit logs on this page.

Exporting audit logs

You can export audit log entries to Stackdriver Logging or to certain Google Cloud services.

To export audit log entries outside of Logging, create a logs sink. Give the sink a query that specifies the audit log types you want to export; for query examples, go to Security logging queries.

If you want to export audit log entries for a Google Cloud organization, folder, or billing account, review Aggregated exports.

Audit log retention

Individual audit log entries are kept for a specified length of time and are then deleted. For details on how long log entries are retained by Logging, review the retention information in Quotas and limits. 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.

Caller identities in audit logs

Audit logs record the identity that performed the logged operations on the Google Cloud resource. The caller's identity is held in the AuthenticationInfo field of AuditLog objects.

In the following circumstances, the caller's principal email address is redacted from audit logs if all of these conditions are met:

  • This is a read-only operation.
  • The operation fails with a "permission denied" error.
  • If the identity is a service account, and the identity isn't a member of the Google Cloud organization associated with the resource. If the identity isn't a service account, then this condition doesn't apply.

In addition to the conditions listed above, the following applies to certain Google Cloud products:

If you are viewing audit logs using the Google Cloud Console Activity page, User (anonymized) is displayed for any log entries where identity is redacted or empty.

Google services producing audit logs

For a list of Google Cloud services that provide audit logs, go to Google services with audit logs. All Google Cloud services will eventually provide audit logs.

Bu sayfayı yararlı buldunuz mu? Lütfen görüşünüzü bildirin:

Şunun hakkında geri bildirim gönderin...

Stackdriver Logging Documentation