Cloud Audit Logs for Connect Gateway let you track administrative and
data-access operations on your resources to help you monitor access and
configuration changes. You can query these logs in the Logs Explorer and
check which Connect Gateway API methods generate Cloud Audit Logs.

For more information about Cloud Audit Logs,
see the following documents:

- [Types of audit logs](https://docs.cloud.google.com/logging/docs/audit.md.txt#types)
- [Audit log entry structure](https://docs.cloud.google.com/logging/docs/audit.md.txt#audit_log_entry_structure)
- [Storing and routing audit logs](https://docs.cloud.google.com/logging/docs/audit.md.txt#storing_and_routing_audit_logs)
- [Cloud Logging pricing summary](https://docs.cloud.google.com/stackdriver/pricing#logs-pricing-summary)
- [Enable Data Access audit logs](https://docs.cloud.google.com/logging/docs/audit/configure-data-access.md.txt)

<br />

## Service name

To view the Connect Gateway audit logs, do the following:

1. In the Google Cloud console, go to the Logs Explorer page:

   [Go to Logs Explorer](https://console.cloud.google.com/logs/query)
2. Copy and paste the following query into the **Query** field of the
   Logs Explorer, and then click **Run query**.

   ```
       protoPayload.serviceName="connectgateway.googleapis.com"
     
   ```

## Methods by permission type

> [!NOTE]
> Connect Gateway audit logs are enabled by turning on audit logging for `gkehub.googleapis.com`.

Each IAM permission has a `type` property, whose value is an enum
that can be one of four values: `ADMIN_READ`, `ADMIN_WRITE`,
`DATA_READ`, or `DATA_WRITE`. When you call a method,
Connect Gateway generates an audit log whose category is dependent on the
`type` property of the permission required to perform the method.

Methods that require an IAM permission with the `type` property value
of `DATA_READ`, `DATA_WRITE`, or `ADMIN_READ` generate
[Data Access](https://docs.cloud.google.com/logging/docs/audit.md.txt#data-access) audit logs.

Methods that require an IAM permission with the `type` property value
of `ADMIN_WRITE` generate
[Admin Activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity) audit logs.
API methods in the following list that are marked with (LRO) are long-running operations (LROs). These methods usually generate two audit log entries: one when the operation starts and another when it ends. For more information see [Audit logs for long-running operations](https://docs.cloud.google.com/logging/docs/audit/understanding-audit-logs.md.txt#lro).

| Permission type | Methods |
|---|---|
| `ADMIN_READ` | `google.cloud.gkeconnect.gateway.v1.GatewayControl.GenerateCredentials` `google.cloud.gkeconnect.gateway.v1.GatewayService.GetResource` `google.cloud.gkeconnect.gateway.v1beta1.GatewayControl.GenerateCredentials` `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.GetResource` |
| `ADMIN_WRITE` | `google.cloud.gkeconnect.gateway.v1.GatewayService.DeleteResource` `google.cloud.gkeconnect.gateway.v1.GatewayService.PatchResource` `google.cloud.gkeconnect.gateway.v1.GatewayService.PostResource` `google.cloud.gkeconnect.gateway.v1.GatewayService.PutResource` `google.cloud.gkeconnect.gateway.v1.GatewayService.Stream` `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.DeleteResource` `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PatchResource` `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PostResource` `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PutResource` `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.Stream` |

## API interface audit logs

For information about how and which permissions are evaluated for each method,
see the Identity and Access Management documentation for Connect Gateway.

### `google.cloud.gkeconnect.gateway.v1.GatewayControl`

The following audit logs are associated with methods belonging to
`google.cloud.gkeconnect.gateway.v1.GatewayControl`.

#### `GenerateCredentials`

- **Method** : `google.cloud.gkeconnect.gateway.v1.GatewayControl.GenerateCredentials`  
- **Audit log type** : [Data access](https://docs.cloud.google.com/logging/docs/audit.md.txt#data-access)  
- **Permissions** :
  - `gkehub.gateway.generateCredentials - ADMIN_READ`
- **Method is a long-running or streaming operation** : No.  
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1.GatewayControl.GenerateCredentials"
  `  

### `google.cloud.gkeconnect.gateway.v1.GatewayService`

The following audit logs are associated with methods belonging to
`google.cloud.gkeconnect.gateway.v1.GatewayService`.

#### `DeleteResource`

- **Method** : `google.cloud.gkeconnect.gateway.v1.GatewayService.DeleteResource`  
- **Audit log type** : [Admin activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity)  
- **Permissions** :
  - `gkehub.gateway.delete - ADMIN_WRITE`
- **Method is a long-running or streaming operation** : No.  
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1.GatewayService.DeleteResource"
  `  

#### `GetResource`

- **Method** : `google.cloud.gkeconnect.gateway.v1.GatewayService.GetResource`  
- **Audit log type** : [Data access](https://docs.cloud.google.com/logging/docs/audit.md.txt#data-access)  
- **Permissions** :
  - `gkehub.gateway.get - ADMIN_READ`
- **Method is a long-running or streaming operation** : [**Streaming RPC**](https://docs.cloud.google.com/logging/docs/audit/understanding-audit-logs.md.txt#streaming)   
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1.GatewayService.GetResource"
  `  

#### `PatchResource`

- **Method** : `google.cloud.gkeconnect.gateway.v1.GatewayService.PatchResource`  
- **Audit log type** : [Admin activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity)  
- **Permissions** :
  - `gkehub.gateway.patch - ADMIN_WRITE`
- **Method is a long-running or streaming operation** : No.  
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1.GatewayService.PatchResource"
  `  

#### `PostResource`

- **Method** : `google.cloud.gkeconnect.gateway.v1.GatewayService.PostResource`  
- **Audit log type** : [Admin activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity)  
- **Permissions** :
  - `gkehub.gateway.post - ADMIN_WRITE`
- **Method is a long-running or streaming operation** : No.  
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1.GatewayService.PostResource"
  `  

#### `PutResource`

- **Method** : `google.cloud.gkeconnect.gateway.v1.GatewayService.PutResource`  
- **Audit log type** : [Admin activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity)  
- **Permissions** :
  - `gkehub.gateway.put - ADMIN_WRITE`
- **Method is a long-running or streaming operation** : No.  
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1.GatewayService.PutResource"
  `  

#### `Stream`

- **Method** : `google.cloud.gkeconnect.gateway.v1.GatewayService.Stream`  
- **Audit log type** : [Admin activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity)  
- **Permissions** :
  - `gkehub.gateway.stream - ADMIN_WRITE`
- **Method is a long-running or streaming operation** : [**Streaming RPC**](https://docs.cloud.google.com/logging/docs/audit/understanding-audit-logs.md.txt#streaming)   
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1.GatewayService.Stream"
  `  

### `google.cloud.gkeconnect.gateway.v1beta1.GatewayControl`

The following audit logs are associated with methods belonging to
`google.cloud.gkeconnect.gateway.v1beta1.GatewayControl`.

#### `GenerateCredentials`

- **Method** : `google.cloud.gkeconnect.gateway.v1beta1.GatewayControl.GenerateCredentials`  
- **Audit log type** : [Data access](https://docs.cloud.google.com/logging/docs/audit.md.txt#data-access)  
- **Permissions** :
  - `gkehub.gateway.generateCredentials - ADMIN_READ`
- **Method is a long-running or streaming operation** : No.  
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1beta1.GatewayControl.GenerateCredentials"
  `  

### `google.cloud.gkeconnect.gateway.v1beta1.GatewayService`

The following audit logs are associated with methods belonging to
`google.cloud.gkeconnect.gateway.v1beta1.GatewayService`.

#### `DeleteResource`

- **Method** : `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.DeleteResource`  
- **Audit log type** : [Admin activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity)  
- **Permissions** :
  - `gkehub.gateway.delete - ADMIN_WRITE`
- **Method is a long-running or streaming operation** : No.  
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1beta1.GatewayService.DeleteResource"
  `  

#### `GetResource`

- **Method** : `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.GetResource`  
- **Audit log type** : [Data access](https://docs.cloud.google.com/logging/docs/audit.md.txt#data-access)  
- **Permissions** :
  - `gkehub.gateway.get - ADMIN_READ`
- **Method is a long-running or streaming operation** : [**Streaming RPC**](https://docs.cloud.google.com/logging/docs/audit/understanding-audit-logs.md.txt#streaming)   
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1beta1.GatewayService.GetResource"
  `  

#### `PatchResource`

- **Method** : `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PatchResource`  
- **Audit log type** : [Admin activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity)  
- **Permissions** :
  - `gkehub.gateway.patch - ADMIN_WRITE`
- **Method is a long-running or streaming operation** : No.  
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PatchResource"
  `  

#### `PostResource`

- **Method** : `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PostResource`  
- **Audit log type** : [Admin activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity)  
- **Permissions** :
  - `gkehub.gateway.post - ADMIN_WRITE`
- **Method is a long-running or streaming operation** : No.  
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PostResource"
  `  

#### `PutResource`

- **Method** : `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PutResource`  
- **Audit log type** : [Admin activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity)  
- **Permissions** :
  - `gkehub.gateway.put - ADMIN_WRITE`
- **Method is a long-running or streaming operation** : No.  
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PutResource"
  `  

#### `Stream`

- **Method** : `google.cloud.gkeconnect.gateway.v1beta1.GatewayService.Stream`  
- **Audit log type** : [Admin activity](https://docs.cloud.google.com/logging/docs/audit.md.txt#admin-activity)  
- **Permissions** :
  - `gkehub.gateway.stream - ADMIN_WRITE`
- **Method is a long-running or streaming operation** : [**Streaming RPC**](https://docs.cloud.google.com/logging/docs/audit/understanding-audit-logs.md.txt#streaming)   
- **Filter for this method** : `
  protoPayload.methodName="google.cloud.gkeconnect.gateway.v1beta1.GatewayService.Stream"
  `  

## Kubernetes audit logging

In addition to Cloud Audit Logs, [Kubernetes audit logging](https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/) 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 and 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 are logged
by that cluster.