> ## Documentation Index
> Fetch the complete documentation index at: https://docs.struct.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Cloud

> GCP logs and metrics.

Connect Google Cloud so Struct Agent can query logs and metrics for the selected projects. Use the catalog’s grant instructions and verify access to the intended resources.

## Inspect access and existing connections

Use a claimed workspace with permission to configure connections.

```bash theme={null}
struct whoami --json
struct connections catalog gcloud --json
struct connections list --json
```

Use the catalog's current fields, choices and permission requirements. Reuse an existing healthy connection instead of creating a duplicate.

## Connect with the CLI

Supply credentials from approved secret storage through `GCP_SERVICE_ACCOUNT_KEY`. The catalog describes which are needed for the selected authentication method. Do not put literal secrets in shell arguments or chat.

Print the setup material first:

```bash theme={null}
struct connect gcloud --print-commands --project my-project
```

An authorized operator runs the generated provider commands after checking the account and scope. Printing them does not apply grants. Preserve generated identifiers (such as an AWS External ID or Snowflake key-pair ID), then run the returned connection command with the real values.

## Verify and recover

Use the returned connection ID:

```bash theme={null}
struct connections show CONNECTION_ID --json
struct connections test CONNECTION_ID --json
```

Inspect `ok`, `health` and missing permissions, not only the exit code. `struct connections grant-command CONNECTION_ID` prints repair instructions where supported; have an authorized operator apply them. For expired OAuth links, start the connection command again and use the new link. Do not reconnect to a different account silently.

Verify a bounded operation for the requested job. Connection health proves checked access; it does not prove telemetry arrival, an investigation or alert delivery.

## What Struct reads

Cloud Logging entries filtered by resource, severity, and time, including GKE and Cloud Run logs, plus Cloud Monitoring metrics.

## PromQL and Managed Service for Prometheus

Struct uses your existing Google Cloud connection to query PromQL in the connected
project's metrics scope. PromQL supports native Cloud Monitoring metrics as well
as Prometheus metrics; no additional Prometheus connection or token is needed.
The existing Monitoring read and alert-policy roles cover these operations.

Struct can preserve PromQL evidence, run watches, and manage native PromQL alert
policies. Each PromQL policy has one condition; multiple signals use separate
policies. Kubernetes-managed Rules, ClusterRules, and GlobalRules are a separate
inventory, inspected only through configured Kubernetes connections. Inaccessible
cluster inventories are reported as uninspected.

## Permissions

The service account needs Cloud Asset Viewer, Service Usage Consumer, Logs Viewer and Monitoring Viewer to read, plus Monitoring AlertPolicy Editor, Monitoring NotificationChannel Editor and Logs Configuration Writer for Auto Monitors to create alert policies. Optionally, Cloud Run Viewer, Compute Viewer, Kubernetes Engine Cluster Viewer and Cloud SQL Viewer let Struct confirm deleted resources. The setup command grants all eleven and enables the core APIs Struct calls.

### Infrastructure inventory

List deployed resources through Cloud Asset Inventory.

| Granted by | Used for |
| - | - |
| **Cloud Asset Viewer** (`roles/cloudasset.viewer`) | Listing deployed resources and their configuration through Cloud Asset Inventory. |
| **Service Usage Consumer** (`roles/serviceusage.serviceUsageConsumer`) | Calling Cloud Asset Inventory on behalf of the project. |

Permissions Struct uses: `cloudasset.assets.listResource`, `cloudasset.assets.searchAllResources`, `serviceusage.services.use`.

### Resource configuration

Read resource configuration from Cloud Asset Inventory.

Granted by: **Cloud Asset Viewer** (`roles/cloudasset.viewer`).

Permissions Struct uses: `cloudasset.assets.listResource`.

### Metrics

Discover metrics and read time series through Cloud Monitoring filters or PromQL in the connected metrics scope.

Granted by: **Monitoring Viewer** (`roles/monitoring.viewer`).

Permissions Struct uses: `monitoring.metricDescriptors.list`, `monitoring.timeSeries.list`, `monitoring.monitoredResourceDescriptors.list`.

### Logs

Read application logs, including GKE and Cloud Run logs.

Granted by: **Logs Viewer** (`roles/logging.viewer`).

Permissions Struct uses: `logging.logEntries.list`.

### Infrastructure change history

Read Admin Activity and System Event audit logs.

Granted by: **Logs Viewer** (`roles/logging.viewer`).

Permissions Struct uses: `logging.logEntries.list`.

### Existing alerts

Read existing alert policies and notification channels.

Granted by: **Monitoring Viewer** (`roles/monitoring.viewer`).

Permissions Struct uses: `monitoring.alertPolicies.list`, `monitoring.alertPolicies.get`, `monitoring.notificationChannels.list`.

### Manage monitoring

Create and maintain the alert policies, log-based metrics and the notification channel that delivers alerts to Struct.

| Granted by | Used for |
| - | - |
| **Monitoring AlertPolicy Editor** (`roles/monitoring.alertPolicyEditor`) | Creating alert policies. It does not include creating notification channels. |
| **Monitoring NotificationChannel Editor** (`roles/monitoring.notificationChannelEditor`) | Creating the channel that delivers alerts to Struct. |
| **Logs Configuration Writer** (`roles/logging.configWriter`) | Creating log-based metrics. |

Permissions Struct uses: `monitoring.alertPolicies.create`, `monitoring.alertPolicies.update`, `monitoring.alertPolicies.delete`, `monitoring.notificationChannels.create`, `logging.logMetrics.create`, `logging.logMetrics.get`, `logging.logMetrics.update`, `logging.logMetrics.delete`.

### Confirm deleted resources

Confirm that a Cloud Run service, Compute Engine instance, GKE cluster or Cloud SQL instance was deleted. Only needed if you want deleted resources to leave inventory right away; without these, Struct keeps them until it can confirm.

| Granted by | Used for |
| - | - |
| **Cloud Run Viewer** (`roles/run.viewer`) | `run.services.get` |
| **Compute Viewer** (`roles/compute.viewer`) | `compute.instances.get` |
| **Kubernetes Engine Cluster Viewer** (`roles/container.clusterViewer`) | `container.clusters.get` |
| **Cloud SQL Viewer** (`roles/cloudsql.viewer`) | `cloudsql.instances.get` |

Permissions Struct uses: `run.services.get`, `compute.instances.get`, `container.clusters.get`, `cloudsql.instances.get`.

* Struct's core APIs are Cloud Asset, Cloud Resource Manager, Cloud Monitoring and Cloud Logging. The setup and grant commands enable them with `gcloud services enable cloudasset.googleapis.com cloudresourcemanager.googleapis.com monitoring.googleapis.com logging.googleapis.com --project <project-id>`. If one is disabled, the permission check marks the reads that go through it as unverified and names the disabled API. Auto Monitors write access is checked from IAM permissions only, so it can still show verified while an API is disabled.
* Confirming deleted resources also calls the Cloud Run, Compute Engine, Kubernetes Engine and Cloud SQL Admin APIs (`run.googleapis.com`, `compute.googleapis.com`, `container.googleapis.com`, `sqladmin.googleapis.com`). The setup command does not enable them. Each is already on in a project that uses that service; if one is off, Struct keeps that kind of resource in inventory until it can confirm the deletion.
* Whoever runs the setup or grant command needs `serviceusage.services.enable` in the project to enable the APIs (for example the Service Usage Admin role) and `resourcemanager.projects.setIamPolicy` to grant the roles (for example Project IAM Admin). If enabling an API fails, the command stops before granting any role and exits non-zero.

### How to grant

> [accordion] Enable the APIs and grant the roles
>
> ```bash theme={null}
> gcloud services enable cloudasset.googleapis.com cloudresourcemanager.googleapis.com monitoring.googleapis.com logging.googleapis.com --project <project-id> &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/cloudasset.viewer &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/serviceusage.serviceUsageConsumer &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/logging.viewer &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/monitoring.viewer &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/monitoring.alertPolicyEditor &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/monitoring.notificationChannelEditor &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/logging.configWriter &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/run.viewer &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/compute.viewer &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/container.clusterViewer &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/cloudsql.viewer
> ```

Replace the values in angle brackets.

Permission catalog version `2026-11-04.1`. See [permission changes](https://docs.struct.ai/reference/permission-changes.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.