Audit logging  |  Cloud Search  |  Google for Developers (2024)

This page describes the audit logs created by Cloud Search as part ofCloud Audit Logs.

Overview

Google Cloud services write audit logs to help you answer the questions,"Who did what, where, and when" within your resources. Your Cloud projectscontain 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, seeCloud Audit Logs. For a deeperunderstanding of Cloud Audit Logs, reviewUnderstanding audit logs.

Cloud Audit Logs provides the following audit logs for each Cloud project,folder, and organization:

  • Admin Activity audit logs containing entries corresponding to methodsperforming Admin write operations. The methods corresponding toAdmin Activity:Admin write operations are covered in an upcomingAudited operations section.
  • Data Access audit logs containing entries corresponding to methods performingAdmin read, Data write, and Data read operations. The methods corresponding toData Access:Admin read, Data Access:Data write, Data Access:Data readoperations are covered in an upcoming Audited operations section.
  • System Event audit logs
  • Policy Denied audit logs

Cloud Search writes Admin Activity audit logs, which record operations thatmodify the configuration or metadata of a resource. You can't disable AdminActivity audit logs.

Only ifexplicitly enabled,Cloud Search writes Data Access audit logs. Data Access audit logs contain APIcalls that read the configuration or metadata of resources, as well asuser-driven API calls that create, modify, or read user-provided resource data.

Cloud Search doesn't write System Event audit logs.

Cloud Search doesn't write Policy Denied audit logs.

Audited operations

The following summarizes which API operations correspond to each audit log typein Cloud Search:

Audit logs categoryCloud Search operations
Admin Activity: Admin writeindexing.datasources.updateSchema
indexing.datasources.deleteSchema
settings.datasources.create
settings.datasources.delete
settings.datasources.update
settings.searchapplications.create
settings.searchapplications.delete
settings.searchapplications.reset
settings.searchapplications.update
settings.updateCustomer
cloudsearch.IdentitySourceService.create
cloudsearch.IdentitySourceService.update
cloudsearch.IdentitySourceService.delete
Data Access: Admin readindexing.datasources.getSchema
settings.datasources.get
settings.datasources.list
settings.searchapplications.get
settings.searchapplications.list
settings.getCustomer
cloudsearch.IdentitySourceService.get
cloudsearch.IdentitySourceService.list
Data Access: Data writeindexing.datasources.items.delete
indexing.datasources.items.deleteQueueItems
indexing.datasources.items.index
indexing.datasources.items.poll
indexing.datasources.items.push
indexing.datasources.items.unreserve
indexing.datasources.items.upload
media.upload
Data Access: Data readindexing.datasources.items.get
indexing.datasources.items.list
operations.get
operations.list
debug.datasources.items.checkAccess
debug.datasources.items.searchByViewUrl
stats.getIndex
stats.getQuery
stats.getSession
stats.getUser
stats.index.datasources.get
stats.query.searchapplications.get
stats.session.searchapplications.get
stats.user.search applications.get
debug.identitysources.items.listForunmappedidentity
debug.identitysources.unmappedids.list
debug.datasources.items.unmappedids.list
query.sources.list
query.suggest
query.search
stats.getSearchapplication

Audit log format

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

The log entry itself, which is an object of typeLogEntry.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 anAuditLogobject 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 theAuditLog object; later integrations use the metadata field.

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

Log name

Cloud Audit Logs resource names indicate the Cloud project or other Google Cloudentity that owns the audit logs, and whether the log contains Admin Activity,Data Access, Policy Denied, or System Event audit logging data. For example, the followingshows log names for project-level Admin Activity audit logs and an organization'sData Access audit logs. The variables denote project and organizationidentifiers.

projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Factivityorganizations/ORGANIZATION_ID/logs/cloudaudit.googleapis.com%2Fdata_access

Service name

Cloud Search audit logs use the service name cloudsearch.googleapis.com.

Resource types

Cloud Search audit logs use the resource type audited_resource for all auditlogs.

For a list of other resource types, seeMonitored resource types.

Enable audit logging

By default, audit logging is disabled for Cloud Search API. To enable auditlogging for Google Cloud Search:

  1. (optional) If you haven't created a Google Cloud Platform project to storelogs, refer toConfigure access to the Google Cloud Search API.

  2. Obtain the project ID for the Google Cloud where youwant to store the logs. To learn how to obtain a project ID, refer toIdentifying projects.

  3. To enable audit logging for a specific API, you need to determine its logcategory to enable. For APIs and their corresponding categories, refer toAudited operations earlier in this document.

  4. Use theupdateCustomer()REST API method to update the auditLogSettings with the log categories toenable:

    1. Obtain an OAuth 2.0 access token from the Google Authorization Server. Forinformation about obtaining the token, refer to step 2 ofUsing OAuth 2.0 to Access Google APIs.Use one of the following OAuth scopes while obtaining the access token:

      • https://www.googleapis.com/auth/cloud_search.settings.indexing
      • https://www.googleapis.com/auth/cloud_search.settings
      • https://www.googleapis.com/auth/cloud_search
    2. Run the following curl command.

    curl --request PATCH \'https://cloudsearch.googleapis.com/v1/settings/customer?updateMask=auditLoggingSettings&key=[YOUR_API_KEY]' \--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \--header 'Content-Type: application/json' \--data '{"auditLoggingSettings": { "project": "projects/PROJECT_ID", "CATEGORY1": "true", "CATEGORY2": "true" } }'

    Where:

    • YOUR_ACCESS_TOKEN is OAuth 2.0 access token obtained in step 4a.
    • PROJECT_ID is the project ID obtained in step 2.
    • CATEGORY1, CATEGORY2, are the categories you chose to enable instep 3. Valid values are logAdminReadActions, logDataWriteActions, andlogDataReadActions. Admin write actions are enabled by default and cannot bedisabled. If you want audit logging for query methods, you must enable theData read category.

    After updating AuditLoggingSettings, further requests to Cloud Search APIgenerate an audit log in the project ID specified in AuditLoggingSettings.

  5. Audit logging for query methods requires the Data read category to be enabled(done in step 4). To enable audit logging for query methods(query.sources.list, query.suggest and query.search) follow theseadditional steps:

    1. For each search application for which you want to enable audit logging,retrieve the name. The name must be in the form ofsearchapplications/<search_application_id>.

    2. Use the name to call settings.searchapplications.update withenableAuditLog set to true.

  6. To enable audit logging for calls from cloudsearch.google.com, ensurethe Data read category is enabled (step 4). Additionally, performstep 5b with a name of searchapplications/default .

Once enabled, logs can be viewed in the Logs Explorer section of the Google CloudConsole. Use the following filter to view only Cloud Search audit logs:

protoPayload.serviceName="cloudsearch.googleapis.com"

For information about how to view logs, refer toLogs explorer overview.

Audit log permissions

Identity and Access Management permissions and roles determine which audit logsyou can view or export. Logs reside in Cloud projects and in some other entitiesincluding organizations, folders, and Cloud Billing accounts. For moreinformation, seeUnderstanding roles.

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

  • Project Owner, Project Editor, or Project Viewer
  • The LoggingLogs Viewerrole
  • Acustom IAM role withthe logging.logEntries.list IAM permission

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

  • Project Owner
  • Logging'sPrivate Logs Viewer role
  • A custom IAM rolewith the logging.privateLogEntries.list IAM permission

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.

View logs

To find and view audit logs, you need to know the identifier of the Cloudproject, folder, or organization for which you want to view audit logginginformation. You can further specify other indexedLogEntryfields, like resource.type; for details, reviewBuild queries in the Logs Explorer.

The following are the audit log names; they include variables for theidentifiers 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 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 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

You have several options for viewing your audit log entries.

Console

You can use the Logs Explorer in the Cloud Consoleto retrieve your audit log entries for your Cloud project:

  1. In the Cloud Console, go to theLogging > Logs Explorer page.

    Go to the Logs Explorer page

  2. On the Logs Explorer page, select an existing Cloud project.

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

    • In Resource, select the Google Cloud resource type whoseaudit 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.

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

    For more details about querying using the new Logs Explorer, seeBuild queries in the Logs Explorer.

gcloud

The gcloud provides a command-line interface to theLogging API. Supply a validPROJECT_ID, FOLDER_ID,or ORGANIZATION_ID in each of the log names.

To read your Google Cloud project-level audit log entries, runthe 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

For more information about using the gcloud tool, seegcloud logging read.

API

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

To use the Logging API to look at your audit log entries, do thefollowing:

  1. Go to the Try this API section in the documentation for theentries.listmethod.

  2. Put the following into the Request body part of the Try thisAPI form. Clicking on this prepopulated formautomatically fills the request body, but you need tosupply a valid PROJECT_ID in each of the lognames.

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

For more details about querying, seeLogging query language.

For a sample audit log entry and how to find the most importantinformation in it, seeUnderstanding 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, seeExporting logs.Here are some applications of exporting audit logs:

  • To keep audit logs for a longer period of time or to use more powerful searchcapabilities, 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 createaggregated sinksthat can export logs from any or all Cloud projects in the organization.

  • If your enabled Data Access audit logs are pushing your Cloud projects overtheir logs allotments, you can export and exclude the Data Access audit logsfrom Logging. For details, seeExcluding logs.

Pricing and retention

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

For more information about audit logs pricing, seeGoogle Cloud's operations suite pricing.

The storage duration associated with Cloud Search audit logs are:

  • Admin Activity logs (or Admin Write) - These logs are retained for 400 days.
  • Data Access logs (Admin Read, Data Write and Data Read) - These logs areretained for 30 days.

For more information about storage duration, seeLogs retention periods.

Current limitations

Cloud Search audit logging has these current limitations:

  • The size of log entry must be less than 512 KB. If the size grows beyond 512KB, then the response is dropped from the log entry. If that doesn't reduce thesize to 512 KB or lower, the request is dropped. Finally, if the size stillexceeds 512 KB, the log entry is dropped.

  • Response bodies aren't logged for list(), get() and suggest() methods.However, response statuses are available.

  • Only Query API calls from cloudsearch.google.com (if enabled) and customersearch applications are logged.

  • For search() calls, only Query, RequestOptions and DataSourceRestrictionare logged in the request. In the response, only the url and metadata (source andobjectType) for each SearchResult are audited.

  • Calls issued to the Cloud Search backend and corresponding to data exportaren’t audited.

Audit logging  |  Cloud Search  |  Google for Developers (2024)
Top Articles
Latest Posts
Article information

Author: The Hon. Margery Christiansen

Last Updated:

Views: 5362

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: The Hon. Margery Christiansen

Birthday: 2000-07-07

Address: 5050 Breitenberg Knoll, New Robert, MI 45409

Phone: +2556892639372

Job: Investor Mining Engineer

Hobby: Sketching, Cosplaying, Glassblowing, Genealogy, Crocheting, Archery, Skateboarding

Introduction: My name is The Hon. Margery Christiansen, I am a bright, adorable, precious, inexpensive, gorgeous, comfortable, happy person who loves writing and wants to share my knowledge and understanding with you.