Connect for Anthos audit logging

This page describes the audit logs created by Connect for Anthos 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 each contain only the audit logs for resources that are directly within the project. Other entities, such as folders, organizations, and billing accounts, each contain the audit logs for the entity itself.

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

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

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

Connect for Anthos writes Admin Activity audit logs, which record operations that modify the configuration or metadata of a resource. You can't disable Admin Activity audit logs.

Only if explicitly enabled, Connect for Anthos 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.

Connect for Anthos doesn't write System Event audit logs.

Audited operations

The following summarizes which API operations correspond to each audit log type in Connect for Anthos:

Audit logs category Operations
Admin activity logs gkehub.googleapis.com:
  • CreateMembership
  • DeleteMembership
  • UpdateMembership
Data Access audit logs (ADMIN_READ) gkehub.googleapis.com:
  • ListMemberships
  • GetMembership
  • GenerateConnectManifest
Data Access audit logs (DATA_READ) gkeconnect.googleapis.com:
  • EgressService.Egress

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:

    • logName contains the project identification and audit log type
    • resource contains the target of the audited operation
    • timeStamp contains the time of the audited operation
    • 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, plus how to interpret them, review Understanding audit logs.

Log name

Cloud Audit Logs resource names indicate the project or other 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:

projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Factivity
organizations/[ORGANIZATION_ID]/logs/cloudaudit.googleapis.com%2Fdata_access

Service name

Connect for Anthos audit logs are enabled by turning on audit logging for gkehub.googleapis.com and generate audit logs with service name gkeconnect.googleapis.com.

For more details on logging services, go to Mapping services to resources.

Resource types

Connect for Anthos audit logs use the resource type audited_resource for all audit logs.

For a full list, go to Monitored resource types.

Enabling audit logging

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

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

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

Audit log permissions

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

To view Admin Activity audit logs, you must have one of the following Cloud IAM roles in the project that contains your audit logs:

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 Project roles to suitable organization roles.

Viewing logs

To find and view 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

The examples below use project-level queries. If you wish to look at audit logs at the organization level or folder level, substitute the appropriate folder-level or organization-level audit log name or identifiers as listed in the audit log names.

You have several options for viewing your audit log entries.

Cloud Console

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

  1. Go to the Google Cloud's operations suite 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.

  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 don't see any of those options, then there are no audit logs of that type available in the project.

If you want to restrict an existing search to only audit logs, do the following:

  1. On the search-filter box, click the drop-down arrow (▾) and select Convert to advanced filter.

  2. In the text box that appears, add the following query below the resource.type line. Note that the project-id you supply must refer to the currently selected Google Cloud project; otherwise, the query won't work.

        logName : "projects/project-id/logs/cloudaudit.googleapis.com"
    

    If you want to see all the available audit logs for your project, only include the above in your query. For more details about queries, see Advanced logs queries.

API

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 queries, see Advanced logs queries.

GCLOUD

The Cloud SDK has a group of commands, gcloud logging, that provide a command-line interface to the Cloud 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"

See Reading log entries for more information about using the gcloud command-line tool.

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

Exporting audit logs

You can export audit logs in the same way you export other kinds of logs. For details about how to export your logs, go to 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 projects in the organization.

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

Pricing

Cloud Logging does not charge you for audit logs that cannot be disabled, including all Admin Activity audit logs. Cloud Logging charges you for Data Access audit logs that you explicitly request.

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

Kubernetes audit logging

In addition to Cloud Audit Logs, Kubernetes audit logging provides a way for administrators to retain, query, process, and alert on events that occur in registered clusters. Administrators can use the logged information to do forensic analysis, real-time alerting, or for cataloging how a fleet of clusters are being used and by whom.

The Connect Agent talks to the local API server running in the registered cluster, and each cluster will have its own set of Kubernetes audit logs. All actions that users perform from the UI through Connect for Anthos are logged by that cluster.