A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/storage/docs/audit-logging below:

Cloud Audit Logs with Cloud Storage

This page provides supplemental information for using Cloud Audit Logs with Cloud Storage. Use Cloud Audit Logs to generate logs for API operations performed in Cloud Storage.

Note: Cloud Audit Logs is separate from Cloud Storage usage logs. Both features provide information about who accesses your Cloud Storage resources, but Cloud Audit Logs is the recommended method for doing so. Overview

Google Cloud services write audit logs to help you answer the questions, "Who did what, where, and when?" within your Google Cloud resources. You can also attach custom information to audit logs for more granular information about how your resources are accessed.

Your Google Cloud projects contain only the audit logs for resources that are directly within the Google Cloud project. Other Google Cloud resources, such as folders, organizations, and billing accounts, contain the audit logs for the entity itself.

For a general overview of Cloud Audit Logs, see Cloud Audit Logs overview. For a deeper understanding of the audit log format, see Understand audit logs.

Available audit logs

The following types of audit logs are available for Cloud Storage:

In addition to audit logs for Cloud Storage, Cloud Audit Logs can create audit logs for Storage Insights. Storage Insights audit logs are generated whenever inventory report configurations are created, updated, and fetched, and when inventory reports are fetched.

For fuller descriptions of the audit log types, see Types of audit logs.

Audited operations

The following table summarizes which Cloud Storage operations correspond to each audit log type:

Note: The following table provides an approximate mapping of Cloud Storage operations to Cloud Audit Logs logs. Cloud Audit Logs logs are generated based on the IAM permissions that get checked in the course of completing the Cloud Storage request. This means that some Cloud Storage requests can generate more than one Cloud Audit Logs log. Refer to the Cloud Storage page IAM permissions for JSON methods for a list of permissions that apply to different methods. Audit log type Sub-type Cloud Storage operations Admin Activity ADMIN_WRITE Data Access ADMIN_READ Data Access DATA_READ Data Access DATA_WRITE System Event

1 Admin Activity audit logs are not generated if/when ACLs are initially set at object creation. Additionally, if an object ACL is set to public, audit logs are not generated for reads or writes to that object or its ACL.

2 These operations involve both reading and writing data. As a result, these operations each generate two log entries.

3 Bucket relocate might not start immediately after the initial request. The system event log gets written when the process actually begins.

Restrictions

The following restrictions apply to Cloud Audit Logs with Cloud Storage:

If you need logging capabilities in one of these cases, consider using Cloud Storage usage logs.

Audit log format

Audit log entries include the following components:

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

Log name

Cloud Audit Logs log names include resource identifiers indicating the Google Cloud project or other Google Cloud entity that owns the audit logs, and whether the log contains Admin Activity or Data Access audit logging data.

The following are the audit log names, including variables for the resource identifiers:

   projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Factivity
   projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fdata_access

   folders/FOLDER_ID/logs/cloudaudit.googleapis.com%2Factivity
   folders/FOLDER_ID/logs/cloudaudit.googleapis.com%2Fdata_access

   billingAccounts/BILLING_ACCOUNT_ID/logs/cloudaudit.googleapis.com%2Factivity
   billingAccounts/BILLING_ACCOUNT_ID/logs/cloudaudit.googleapis.com%2Fdata_access

   organizations/ORGANIZATION_ID/logs/cloudaudit.googleapis.com%2Factivity
   organizations/ORGANIZATION_ID/logs/cloudaudit.googleapis.com%2Fdata_access
Note: The part of the log name following /logs/ must be URL-encoded. The forward-slash character, /, must be written as %2F. Service name

Cloud Storage audit logs use the service name storage.googleapis.com.

Storage Insights audit logs use the service name storageinsights.googleapis.com.

For a list of all the Cloud Logging API service names and their corresponding monitored resource type, see Map services to resources.

Resource types

Cloud Storage audit logs use the resource type gcs_bucket.

For a list of all the Cloud Logging monitored resource types and descriptive information, see Monitored resource types.

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

For information about enabling some or all of your Data Access audit logs, see Configure Data Access audit logs.

Permissions and roles

IAM permissions and roles determine your ability to access audit logs data in Google Cloud resources.

When deciding which Logging-specific permissions and roles apply to your use case, consider the following:

For more information about the IAM permissions and roles that apply to audit logs data, see Access control with IAM.

Note: Access Control Lists (ACLs) cannot be used to grant users access to view Admin Activity or Data Access audit logs. Viewing logs

You can query for all audit logs or you can query for logs by their audit log name. The audit log name includes the resource identifier of the Google Cloud project, folder, billing account, or organization for which you want to view audit logging information. Your queries can specify indexed LogEntry fields. For more information about querying your logs, see Build queries in the Logs Explorer

The Logs Explorer lets you view filter individual log entries. If you want to use SQL to analyze groups of log entries, then use the Log Analytics page. For more information, see:

Most audit logs can be viewed in Cloud Logging by using the Google Cloud console, the Google Cloud CLI, or the Logging API. However, for audit logs related to billing, you can only use the Google Cloud CLI or the Logging API.

Console

In the Google Cloud console, you can use the Logs Explorer to retrieve your audit log entries for your Google Cloud project, folder, or organization:

Note: You can't view audit logs for Cloud Billing accounts in the Google Cloud console. You must use the API or the gcloud CLI.
  1. In the Google Cloud console, go to the Logs Explorer page:

    Go to Logs Explorer

    If you use the search bar to find this page, then select the result whose subheading is Logging.

  2. Select an existing Google Cloud project, folder, or organization.

  3. To display all audit logs, enter either of the following queries into the query-editor field, and then click Run query:

    logName:"cloudaudit.googleapis.com"
    
    protoPayload."@type"="type.googleapis.com/google.cloud.audit.AuditLog"
    
  4. To display the audit logs for a specific resource and audit log type, in the Query builder pane, do the following:

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

    If you're experiencing issues when trying to view logs in the Logs Explorer, see the troubleshooting information.

    For more information about querying by using the Logs Explorer, see Build queries in the Logs Explorer.

gcloud

The Google Cloud CLI provides a command-line interface to the Logging API. Supply a valid resource identifier in each of the log names. For example, if your query includes a PROJECT_ID, then the project identifier you supply must refer to the currently selected Google Cloud project.

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

To read your Cloud Billing account-level audit log entries, run the following command:

gcloud logging read "logName : billingAccounts/BILLING_ACCOUNT_ID/logs/cloudaudit.googleapis.com" \
    --billing-account=BILLING_ACCOUNT_ID

Add the --freshness flag to your command to read logs that are more than 1 day old.

For more information about using the gcloud CLI, see gcloud logging read.

REST

When building your queries, supply a valid resource identifier in each of the log names. For example, if your query includes a PROJECT_ID, then the project identifier you supply must refer to the currently selected Google Cloud project.

For example, to use the Logging API to view your project-level audit log entries, 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 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.

You can attach custom information to requests for inclusion in audit logs by including the x-goog-custom-audit-KEY: VALUE header in your request. XML API requests additionally support the usage of a x-goog-custom-audit-KEY=VALUE query parameter. Custom information is added to the metadata field of the protoPayload in the audit log entry.

When adding custom audit information, note the following considerations:

The following list shows examples of key-value pairs you can include in header entries:

Example requests Command line
gcloud storage hash gs://example_bucket/example_object.jpeg --additional-headers=x-goog-custom-audit-job="job name",x-goog-custom-audit-user="test user"
Client libraries REST APIs JSON API
curl -X GET "https://storage.googleapis.com/storage/v1/b/example_bucket/o/example_object" \
-H "Authorization: Bearer ya29.AHES6ZRVmB7fkLtd1XTmq6mo0S1wqZZi3-Lh_s-6Uw7p8vtgSwg" \
-H "x-goog-custom-audit-job: job name" \
-H "x-goog-custom-audit-user: test user"
XML API
curl -X GET "https://storage.googleapis.com/example_bucket/example_object" \
-H "Authorization: Bearer ya29.AHES6ZRVmB7fkLtd1XTmq6mo0S1wqZZi3-Lh_s-6Uw7p8vtgSwg" \
-H "x-goog-custom-audit-job: job name" \
-H "x-goog-custom-audit-user: test user"
Signed URL requests
curl -X GET 'storage.googleapis.com/example_bucket?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=example%40example-project.iam.gserviceaccount.com%2F20181026%2Fus-central1%2Fstorage%2Fgoog4_request&X-Goog-Date=20181026T181309Z&X-Goog-Expires=900&X-Goog-SignedHeaders=host,x-goog-custom-audit-job,x-goog-custom-audit-user&X-Goog-Signature=247a2aa45f169edf4d187d54e7cc46e4731b1e6273242c4f4c39a1d2507a0e58706e25e3a85a7dbb891d62afa8496def8e260c1db863d9ace85ff0a184b894b117fe46d1225c82f2aa19efd52cf21d3e2022b3b868dcc1aca2741951ed5bf3bb25a34f5e9316a2841e8ff4c530b22ceaa1c5ce09c7cbb5732631510c20580e61723f5594de3aea497f195456a2ff2bdd0d13bad47289d8611b6f9cfeef0c46c91a455b94e90a66924f722292d21e24d31dcfb38ce0c0f353ffa5a9756fc2a9f2b40bc2113206a81e324fc4fd6823a29163fa845c8ae7eca1fcf6e5bb48b3200983c56c5ca81fffb151cca7402beddfc4a76b133447032ea7abedc098d2eb14a7' \
-H "x-goog-custom-audit-job: job name" \
-H "x-goog-custom-audit-user: test user"

Note that the custom audit headers must also be included in X-Goog-SignedHeaders.

To create a signed URL request that supports the addition of custom audit headers, the custom audit headers you want to use in the request must also be included when you generate the signed URL. For example:

gcloud storage sign-url gs://example_bucket/example_object.jpeg --private-key-file=example-key.json --duration=10m --headers=x-goog-custom-audit-job:"job name",x-goog-custom-audit-user="test user"

You can also use client libraries to generate the signed URL when you set custom headers.

As an alternative to using signed headers, you can use query parameters to pass custom audit entries.

curl -X GET 'storage.googleapis.com/example_bucket?X-Goog-Custom-Audit-Key=Value&X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=example%40example-project.iam.gserviceaccount.com%2F20181026%2Fus-central1%2Fstorage%2Fgoog4_request&X-Goog-Date=20181026T181309Z&X-Goog-Expires=900&X-Goog-SignedHeaders=host&X-Goog-Signature=247a2aa45f169edf4d187d54e7cc46e4731b1e6273242c4f4c39a1d2507a0e58706e25e3a85a7dbb891d62afa8496def8e260c1db863d9ace85ff0a184b894b117fe46d1225c82f2aa19efd52cf21d3e2022b3b868dcc1aca2741951ed5bf3bb25a34f5e9316a2841e8ff4c530b22ceaa1c5ce09c7cbb5732631510c20580e61723f5594de3aea497f195456a2ff2bdd0d13bad47289d8611b6f9cfeef0c46c91a455b94e90a66924f722292d21e24d31dcfb38ce0c0f353ffa5a9756fc2a9f2b40bc2113206a81e324fc4fd6823a29163fa845c8ae7eca1fcf6e5bb48b3200983c56c5ca81fffb151cca7402beddfc4a76b133447032ea7abedc098d2eb14a7'

These query parameters must be included when you generate the signed URL. For example:

gcloud storage sign-url gs://example_bucket/example_object.jpeg --private-key-file=example-key.json --duration=10m --query-params=x-goog-custom-audit-job=job_name,x-goog-custom-audit-user=test_user
Example log entry
protoPayload: {
  @type: "type.googleapis.com/google.cloud.audit.Auditlog",
  ...
  metadata: {
    audit_context: {
      app_context: "EXTERNAL",
      audit_info: {
        x-goog-custom-audit-job: "job name",
        x-goog-custom-audit-user: "test user"
      }
    }
  }
}

For more information on the fields included in the protoPayload object with the type type.googleapis.com/google.cloud.audit.Auditlog, see the AuditLog reference documentation.

Route audit logs

You can route audit logs to supported destinations in the same way that you can route other kinds of logs. Here are some reasons you might want to route your audit logs:

For instructions about routing logs, see Configure and manage sinks .

Pricing

For information about Cloud Logging pricing, see Google Cloud Observability pricing: Cloud Logging.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4