Trace audit logging information

This page describes the audit logs created by Cloud Trace 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?" Your Cloud projects contain only the audit logs for resources that are directly within the project. Other entities, such as folders, organizations, and Cloud Billing accounts, contain the audit logs for the entity itself.

For a general overview of Cloud Audit Logs, see Cloud Audit Logs. For a deeper understanding of Cloud Audit Logs, review Understanding audit logs.

Cloud Audit Logs maintains three audit logs for each Cloud project, folder, and organization:

  • Admin Activity audit logs
  • Data Access audit logs
  • System Event audit logs

Only if explicitly enabled, Trace writes 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.

Trace doesn't write Admin Activity audit logs.

Trace doesn't write System Event audit logs.

Audited operations

The following summarizes which API operations correspond to each audit log type in Trace:

Audit logs category Operations
DATA_READ cloudtrace.traces.get
cloudtrace.traces.list

Audit log format

Audit log entries—which can be viewed in Cloud Logging using the Logs Viewer, the Cloud Logging API, or the gcloud command-line tool—include the following objects:

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

    • The logName contains the project identification 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 held in the serviceData field of the AuditLog object. For details, go to Service-specific audit data.

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

Log name

Cloud Audit Logs resource names indicate the Cloud project or other Google Cloud entity that owns the audit logs, and whether the log contains Admin Activity, Data Access, or System Event audit logging data. For example, the following shows log names for a project's Admin Activity audit logs and an organization's Data Access audit logs. The variables denote project and organization identifiers.

projects/project-id/logs/cloudaudit.googleapis.com%2Factivity
organizations/organization-id/logs/cloudaudit.googleapis.com%2Fdata_access

Service name

Trace audit logs use the service name cloudaudit.googleapis.com.

For information on all logging services, go to Mapping services to resources.

Resource types

Trace audit logs use the resource type audited_resource for all audit logs.

For a list of other resource types, go to Monitored resource types.

Enabling audit logging

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 cannot be disabled).

For instructions on enabling some or all of your Data Access audit logs, see Configuring Data Access logs.

The Data Access audit logs that you enable can affect your logs pricing in Cloud Logging. Review the Pricing section on this page.

Trace doesn't write Admin Activity audit logs.

Audit log permissions

Cloud Identity and Access Management permissions and roles determine which audit logs you can view or export. Logs reside in Cloud projects and in some other entities including organizations, folders, and Cloud Billing accounts. For more information, see Understanding roles.

To view Data Access audit logs, you must have one of the following roles in the project that contains your audit logs:

If you are using audit logs from a non-project entity, such as an organization, then change the Cloud project roles to suitable organization roles.

Viewing logs

To find and view audit logs, you need to know the identifier of the 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.

The following are the audit log names; they include variables for the identifiers of the Cloud project, folder, or organization:

   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.

Console

You can use the Logs Viewer in the Cloud Console to retrieve your audit log entries for your Cloud project:

  1. In the Cloud Console, go to the Cloud Logging > Logs (Logs Viewer) page:

    Go to the Logs Viewer page

  2. From Classic, select Preview the new Logs Viewer.

  3. Select an existing Cloud project.

  4. In the Query builder pane, do the following:

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

    • From 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_events.

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

    For more details about querying using the new Logs Viewer, see Building log queries (Preview).

API

When building your queries, replace the variables with valid values, substitute the appropriate project-level, folder-level, or organization-level audit log name or identifiers as listed in the audit log names. For example, if your query includes a project-id, then the project identifier you supply must refer to the currently selected Cloud project.

To look at your audit log entries using the Logging API, 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 on 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.

For more details about querying, see Logging query language.

gcloud

The gcloud command-line tool provides a command-line interface to the Cloud Logging API. Supply a valid project-id, folder-id, or organization-id in each of the log names.

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

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

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

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

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

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

For more information about using the gcloud tool, see Reading log entries.

For a sample audit log entry and how to find the most important information in it, see Understanding audit logs.

Exporting audit logs

You can export audit logs in the same way that you export other kinds of logs. For details about how to export your logs, see Exporting logs. Here are some applications of exporting audit logs:

  • To keep audit logs for a longer period of time or to use more powerful search capabilities, you can export copies of your audit logs to Cloud Storage, BigQuery, or Pub/Sub. Using Pub/Sub, you can export 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 export logs from any or all Cloud projects in the organization.

  • If your enabled Data Access audit logs are pushing your Cloud projects over their logs allotments, you can export and exclude the Data Access audit logs from Logging. For details, see Excluding logs.

Pricing

Cloud Logging charges you for Data Access audit logs that you explicitly request. Trace doesn't write Admin Activity audit logs or System Event audit logs.

For more information on audit logs pricing, review Google Cloud's operations suite pricing.