К основному содержанию
скилл Claude Code Gemini CLI CX Codex официальный · Google

cloud-logging-cross-project-configuration — скилл для Claude Code

Скилл настраивает и помогает искать проблемы в централизованном логировании Google Cloud между проектами. Подойдёт для общих бакетов и агрегации логов при чтении.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add google/skills --skill cloud-logging-cross-project-configuration -a claude-code
Открыть на GitHub

Что делает cloud-logging-cross-project-configuration

Скилл помогает направлять логи из нескольких проектов, папок или организаций в центральный log bucket. Он также разбирает создание cross-project log sinks, настройку центрального бакета и проблемы с маршрутизацией. Для работы с конфигурацией используются команды gcloud.

Внутри есть выбор между централизованным хранением и агрегацией при чтении. Первый вариант упрощает единые запросы и позволяет ограничивать доступ через log views; второй оставляет данные в исходных ресурсах и объединяет их одним запросом. Для read-time aggregation указано ограничение: подход рассчитан на менее чем 375 проектов.

Ставьте этот скилл, если логи приходят из нескольких проектов. Для базовой настройки одного проекта он не нужен.

Какие задачи решает

  • направить логи из нескольких проектов в центральный log bucket
  • создать cross-project log sink
  • настроить централизованное хранение логов
  • сравнить хранение в одном бакете и агрегацию при чтении
  • найти причину сбоя cross-project маршрутизации

Примеры запросов агенту

  • Настрой маршрутизацию логов из `{source_project_id}` в `{central_project_id}`.
  • Создай cross-project log sink и центральный log bucket с помощью `gcloud`.
  • Сравни централизованное хранение с read-time aggregation для моей структуры проектов.

Как установить cloud-logging-cross-project-configuration

1Через Skills CLI (Vercel)

npx skills add google/skills --skill cloud-logging-cross-project-configuration -a claude-code

2Вручную: положить файлы

~/.claude/skills/cloud-logging-cross-project-configuration/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/cloud-logging-cross-project-configuration/

Из того же набора172

Весь набор →
bigquery-basics официальный google Управляет ресурсами BigQuery и запускает SQL-запросы. Подходит для создания датасетов, таблиц, представлений и базовой загрузки данных. Claude Code Gemini CLI CX Codex 17 678установок cloud-run-basics официальный google Скилл помогает управлять Cloud Run: разворачивать HTTP-сервисы, запускать задачи по событию или расписанию и вести фоновые worker pools. Claude Code Gemini CLI CX Codex 17 532установок gemini-api официальный google Подключает Gemini API из Agent Platform Google Cloud к агенту. Даёт доступ к моделям Gemini, мультимодальному вводу, вызову функций и кешированию контекста. Claude Code Gemini CLI CX Codex 17 116установок google-cloud-recipe-auth официальный Google LLC Скилл объясняет аутентификацию и права доступа в Google Cloud. Пригодится для настройки IAM, ADC и сервисных аккаунтов в разработке и продакшене. Claude Code Gemini CLI CX Codex 15 450установок google-cloud-recipe-onboarding официальный Google LLC Проводит разработчика через старт в Google Cloud: проверяет CLI, вход, проект и биллинг. Подходит для первого личного проекта. Claude Code Gemini CLI CX Codex 15 390установок cloud-sql-basics официальный google Скилл помогает создавать и объяснять Cloud SQL для MySQL, PostgreSQL и SQL Server. Пригодится при настройке базы в Google Cloud. Claude Code Gemini CLI CX Codex 14 679установок google-cloud-waf-security официальный google Скилл оценивает безопасность рабочих нагрузок в Google Cloud и предлагает меры для IAM, сетевой защиты, данных и операционной безопасности. Claude Code Gemini CLI CX Codex 14 620установок google-cloud-waf-cost-optimization официальный google Проверяет расходы Google Cloud по pillar Cost Optimization из Well-Architected Framework. Нужен для поиска простаивающих ресурсов, выбора скидок и правки размеров сервисов. Claude Code Gemini CLI CX Codex 14 266установок

Похожие

terraform-module-library Seth Hobson Скилл для написания переиспользуемых модулей Terraform под AWS, Azure, GCP и OCI. Пригодится, когда нужно навести порядок в облачном провижининге. Claude Code CX Codex Cursor 15 615установок firebase-crashlytics Google LLC Скилл для подключения Firebase Crashlytics к агентам в Claude Code, Cursor и других платформах. Собирает данные о падениях приложений на Android и iOS, помогает отследить ошибки через MCP-сервер Firebase CLI. Claude Code CX Codex Cursor +1 131 200установок k8s-security-policies Seth Hobson Скилл помогает задавать политики безопасности Kubernetes: сетевую изоляцию, RBAC и стандарты безопасности подов. Нужен при защите кластера. Claude Code CX Codex Cursor 14 692установок wizard Matt Pocock Скилл создаёт интерактивный bash-скрипт для ручных шагов: настройки сервисов, секретов CI и разовых миграций. Claude Code 553 369установок hyperframes-cli heygen-com Управляет проектами HyperFrames через терминал: собирает таймлайн, проверяет контраст кадров, запускает предпросмотр и рендерит видео локально или в облаке. Claude Code CX Codex Cursor +1 1 200 000установок setup-pre-commit Matt Pocock Скилл настраивает pre-commit для JavaScript-репозитория: Husky запускает форматирование, проверку типов и тесты перед коммитом. Claude Code 489 289установок using-git-worktrees Jesse Vincent Готовит изолированное рабочее дерево перед доработкой или выполнением плана. Проверяет текущий репозиторий, выбирает нативные средства платформы либо Git. Claude Code CX Codex 217 153установок finishing-a-development-branch Jesse Vincent Скилл проверяет тесты и помогает выбрать, как завершить работу в ветке: слить её, открыть Pull Request или оставить как есть. Claude Code CX Codex 214 439установок

Вопросы о cloud-logging-cross-project-configuration

Как установить cloud-logging-cross-project-configuration в Claude Code?

Выполните npx skills add google/skills --skill cloud-logging-cross-project-configuration -a claude-code. Файл скилла появится по пути ~/.claude/skills/cloud-logging-cross-project-configuration/SKILL.md.

Что делает cloud-logging-cross-project-configuration?

Скилл настраивает cross-project логирование Google Cloud: маршрутизацию в центральный log bucket, log sinks и агрегацию данных при чтении. Он также помогает разбирать проблемы с такой маршрутизацией.

Когда выбрать read-time aggregation вместо центрального хранения?

Read-time aggregation оставляет логи в ресурсах-источниках и объединяет их одним запросом. Вход описывает этот вариант как подход для менее чем 375 проектов, когда не нужна репликация данных.

Исходный текст

SKILL.md · Apache-2.0
---
name: cloud-logging-cross-project-configuration
description: >-
  Configure and troubleshoot Google Cloud cross-project centralized logging and read-time aggregation.
  Use when:
  - Setting up log routing from multiple projects/folders/organizations to a central log bucket.
  - Creating cross-project log sinks and configuring central log buckets.
  - Troubleshooting cross-project routing.
  Don't use for single-project basic configurations.
metadata:
  version: "1.0.2"
  category: CloudObservabilityAndMonitoring
---

# Configuring Cross-Project Logging

This skill describes how to use `gcloud` commands to configure Cloud Logging so
that you store log data in a central location, regardless of the point of
origin. The skill also describes how to query log data when that data is stored
in multiple projects.

> [!IMPORTANT] **Sandbox Network Limitation (CRITICAL for Agent Testing):**
> During evaluation or in restricted sandboxed environments, network traffic to
> GCP APIs is blocked. Do **NOT** run network discovery commands to find
> resource names, project IDs, or organization IDs. Always use the exact project
> IDs or placeholders provided in the user prompt or instructions, for example,
> `{project_id}`, `{source_project_id}`, `{central_project_id}`. Assume these
> resources exist and proceed directly with configuration commands. Running
> these discovery commands will cause the execution to hang and timeout.

## Attribution

**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
MUST read [Usage Attribution](references/attribution.md). For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix `gcloud` with
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:cloud-logging-cross-project-configuration)"`
and append `agent-skills/1.0 (skill:cloud-logging-cross-project-configuration)` to `User-Agent` headers.

## Safety and Confirmation Tiers (CRITICAL)

Before executing any commands on behalf of the user, you MUST adhere to the
following safety tiers based on the action requested:

1.  **Tier R: Read-Only**
    *   **Description:** Commands that only read state or query logs.
    *   **Example commands:**
        *   `gcloud logging read`
        *   `gcloud logging buckets list`
    *   **Rule:** No confirmation needed. You may execute these commands
        immediately to gather information.
2.  **Tier M: Mutation (Non-Billing)**
    *   **Description:** Configuration modifications or free metadata creations
        that do not incur direct storage or billing costs and do not affect
        resource security/access policies.
    *   **Example commands:**
        *   `gcloud logging views create`
        *   `gcloud logging views update`
        *   `gcloud logging scopes create`
        *   `gcloud logging buckets create`
    *   **Rule:** No confirmation needed. You may execute these commands
        immediately to apply configurations.
3.  **Tier B: Billing and Security-Sensitive Mutations (High-Risk)**
    *   **Description:** Operations that create billing-inducing resources or
        integrations, or modify security and IAM access control policies
        (presenting a risk of privilege escalation).
    *   **Example commands:**
        *   `gcloud logging metrics create`
        *   `gcloud logging links create`
        *   `gcloud projects add-iam-policy-binding`
    *   **Rule:** **Interactive confirmation required.** These commands create
        resources that incur billing costs or alter security access. You MUST
        present the exact, literal command and receive user confirmation before
        executing. NEVER execute in the same turn as asking.
4.  **Tier D: Causes irreversible data loss**
    *   **Description:** Actions that permanently discard or delete logs, for
        example sink exclusions.
    *   **Example commands:**
        *   `gcloud logging buckets delete`
        *   `gcloud logging sinks update --add-exclusion`
    *   **Rule:** **Explicit typed confirmation required.** These commands
        discard or delete logs immediately and irreversibly, or they may result
        in log data not being stored. You MUST ask for explicit typed
        confirmation, for example, "Yes, discard logs", and halt execution until
        the user replies.

## Decision Matrix: Centralized Storage vs. Distributed Storage with Read-Time Aggregation

Use this decision matrix to evaluate and choose between **Centralized Storage**
and **Read-Time Aggregation**. With centralized storage, log data is routed to
one log bucket, regardless of where the data originates. You write queries
against the centralized log bucket. With read-time aggregation, log data is
stored by the resource where it originates. However, a single query aggregates
the data by querying all resources.

After you have determined the optimal architecture for handling cross-project
logs, follow the corresponding configuration steps detailed below.

| Criterion             | Centralized Storage      | Read-Time Aggregation    |
| :-------------------- | :----------------------- | :----------------------- |
| **GCP Project Scale** | Scales to thousands of   | Best for < 375 projects. |
:                       : projects.                :                          :
| **Log Storage**       | Consolidated in a single | Resides in originating   |
:                       : log bucket.              : resources.               :
| **SQL Analytics**     | Easy; unified querying   | Hard; requires querying  |
:                       : via Observability        : multiple log buckets.    :
:                       : Analytics.               :                          :
| **Access Control**    | Scoped access via log    | Requires IAM access to   |
:                       : views on the centralized : all views on resources   :
:                       : log bucket.              : that store log data.     :
| **Configuration**     | Options vary based on    | Will not interfere with  |
: **Complexity**        : Project, Folder,         : bucket-based log-based   :
:                       : Organization structure.  : metrics.                 :
| **Cost**              | Potential for duplicate  | Cost-effective; no data  |
:                       : storage of log buckets   : replication.             :
:                       : if exclusions aren't     :                          :
:                       : set.                     :                          :

## Architecture

### Centralized Storage (Log Routing)

```mermaid
graph LR
    subgraph "Source Project(s)"
        Log[Resource Logs] --> Sink["Sink: route-to-central-project"]
    end

    subgraph "Central Project"
        Sink --> Bucket["Bucket: central-logs-bucket (us-central1)"]
    end
```

### Read-Time Aggregation (Log Scopes)

```mermaid
graph LR
    subgraph "Source Project 1"
        Log1[Resource Logs] --> Bucket1["Bucket: _Default"]
    end

    subgraph "Source Project 2"
        Log2[Resource Logs] --> Bucket2["Bucket: _Default"]
    end

    subgraph "Scoping Project (No Log Storage)"
        Scope["Log scope: central-query-scope"]
        Scope -.-> View1["_AllLogs View on Bucket1"]
        Scope -.-> View2["_AllLogs View on Bucket2"]
    end
```

## Setup Steps: Centralized Storage (Log Routing)

Use these steps to route logs from one or more source projects to a central log
bucket in a project. Create or select the Google Cloud project that you will use
for storing your log data. This is the central project.

### 1. Create log bucket in central project (Tier M)

Create a custom log bucket with Log Analytics enabled.

> [Tip] Use regional log buckets, for example, set the location to
> `us-central1`. Don't use the `global` location. This approach ensures
> compatibility with Observability Analytics and SQL querying.

```bash
gcloud logging buckets create {bucket_id} \
    --project={central_project_id} \
    --location={region} \
    --retention-days={retention_days} \
    --enable-analytics
```

### 2. Create log sink in central project (Tier M)

Create a project-level sink in the central project pointing to the central log
bucket. This sink routes logs that land in the central project's Log Router into
the central log bucket.

Assuming the newly created bucket is specifically for centralizing data from
other projects (and the central project is not one of the source projects), the
central sink should exclude the central project's own logs. Include the
`_Required` audit log exclusions on this central sink to avoid redundancy
between `{bucket_id}` and the `_Required` bucket.

```bash
gcloud logging sinks create {sink_name} \
    logging.googleapis.com/projects/{central_project_id}/locations/{region}/buckets/{bucket_id} \
    --project={central_project_id} \
    --exclusion=filter='logName:"projects/{central_project_id}/"' \
    --exclusion=filter='LOG_ID("cloudaudit.googleapis.com/activity")' \
    --exclusion=filter='LOG_ID("externalaudit.googleapis.com/activity")' \
    --exclusion=filter='LOG_ID("cloudaudit.googleapis.com/system_event")' \
    --exclusion=filter='LOG_ID("externalaudit.googleapis.com/system_event")' \
    --exclusion=filter='LOG_ID("cloudaudit.googleapis.com/access_transparency")' \
    --exclusion=filter='LOG_ID("externalaudit.googleapis.com/access_transparency")'
```

### 3. Create log sink in source resource (Tier M)

To route logs to the central project, you must create a log sink in each source
organization, folder, or project. While you can configure a sink to route only a
subset of logs using the `--log-filter` argument, recommended practice is to
route all non-audit logs, and then restrict access or partition logs at the
destination using custom Log Views on the centralized log bucket.

*   **For an organization-level log sink**

    ```bash
    gcloud logging sinks create {sink_name} \
        logging.googleapis.com/projects/{central_project_id} \
        --organization={source_organization_id} \
        --include-children \
        --exclusion=filter='LOG_ID("cloudaudit.googleapis.com/activity")' \
        --exclusion=filter='LOG_ID("externalaudit.googleapis.com/activity")' \
        --exclusion=filter='LOG_ID("cloudaudit.googleapis.com/system_event")' \
        --exclusion=filter='LOG_ID("externalaudit.googleapis.com/system_event")' \
        --exclusion=filter='LOG_ID("cloudaudit.googleapis.com/access_transparency")' \
        --exclusion=filter='LOG_ID("externalaudit.googleapis.com/access_transparency")'
    ```

*   **For project-level log sinks**

    ```bash
    gcloud logging sinks create {sink_name} \
        logging.googleapis.com/projects/{central_project_id} \
        --project={source_project_id} \
        --exclusion=filter='LOG_ID("cloudaudit.googleapis.com/activity")' \
        --exclusion=filter='LOG_ID("externalaudit.googleapis.com/activity")' \
        --exclusion=filter='LOG_ID("cloudaudit.googleapis.com/system_event")' \
        --exclusion=filter='LOG_ID("externalaudit.googleapis.com/system_event")' \
        --exclusion=filter='LOG_ID("cloudaudit.googleapis.com/access_transparency")' \
        --exclusion=filter='LOG_ID("externalaudit.googleapis.com/access_transparency")'
    ```

### 4. Grant IAM permissions to sink writers (Tier B)

> [!IMPORTANT] **Security Action (Tier B):** Granting IAM permissions changes
> access control policy and must be explicitly confirmed by the user before
> execution.

To allow the source sinks to route logs to the central project's router, and to
allow the central sink to write logs to the central bucket:

1.  **Grant Logs Writer permission to the source sink:** Retrieve the
    `writerIdentity` of the source log sink and grant it
    `roles/logging.logWriter` on the central project.

    ```bash
    # Get the writer identity of the source sink
    gcloud logging sinks describe {sink_name} \
        --project={source_project_id} \
        --format="value(writerIdentity)"
    ```

    The output is the `{source_writer_identity}` value (for example
    `serviceAccount:...`) for the following command:

    ```bash
    # Grant Logs Writer permissions on the central project
    gcloud projects add-iam-policy-binding {central_project_id} \
        --member={source_writer_identity} \
        --role=roles/logging.logWriter
    ```

2.  **Grant Bucket Writer permission to the central sink:** Retrieve the
    `writerIdentity` of the central log sink and grant it
    `roles/logging.bucketWriter` on the central project.

    ```bash
    # Get the writer identity of the central sink
    gcloud logging sinks describe {central_sink_name} \
        --project={central_project_id} \
        --format="value(writerIdentity)"
    ```

    The output is the `{central_writer_identity}` value for the following
    command:

    ```bash
    # Grant Bucket Writer permissions on the central project
    gcloud projects add-iam-policy-binding {central_project_id} \
        --member={central_writer_identity} \
        --role=roles/logging.bucketWriter
    ```

### 5. Create custom Log Views on the central bucket (Tier M)

To partition logs or restrict access by log ID or project (since all logs were
routed to the same central bucket), create custom Log Views on the central
bucket.

*   **Filter by log ID:**

    ```bash
    gcloud logging views create {view_id} \
        --bucket={bucket_id} \
        --location={region} \
        --project={central_project_id} \
        --log-filter='LOG_ID("{log_id}")'
    ```

*   **Filter by source project:**

    ```bash
    gcloud logging views create {view_id} \
        --bucket={bucket_id} \
        --location={region} \
        --project={central_project_id} \
        --log-filter='project_id="{source_project_id}"'
    ```

### Verify Centralized Log Routing (Tier R)

To verify that logs are being routed from the source projects to the central
regional log bucket:

1.  **Write a test log in the source project:**

    ```bash
    gcloud logging write {test_log_id} "Test log entry for verification" \
        --severity=WARNING \
        --project={source_project_id}
    ```

2.  **Read the test log from the central log bucket:** For regional log buckets,
    you **must** specify the `--view` flag. Because the default view `_Default`
    only contains logs matching the default filter, you should query the
    **`_AllLogs`** view or your custom log view on the central bucket:

    ```bash
    gcloud logging read 'logName:"projects/{source_project_id}/logs/{test_log_id}"' \
        --bucket={bucket_id} \
        --location={region} \
        --view=_AllLogs \
        --project={central_project_id}
    ```

--------------------------------------------------------------------------------

## Setup Steps: Read-Time Aggregation (Log Scopes)

Create or select a Google Cloud project that you will use for querying your log
data. This is the scoping project. Use these steps to configure a log scope. Log
scopes let you issue a query for log data that is stored in multiple projects.

### 1. Create a custom Log View (Optional but recommended) (Tier M)

Create a Log View in the source project to restrict which logs are accessible.

> [!IMPORTANT] **Gotcha:** Log View filters can only contain specific
> restrictions. Refer to
> https://docs.cloud.google.com/logging/docs/logs-views.md.txt#view-filter

```bash
gcloud logging views create {view_id} \
    --bucket={bucket_id} \
    --location={region} \
    --project={source_project_id} \
    --log-filter='LOG_ID("{log_id}")'
```

*   `{bucket_id}`: for example, `_Default`
*   `{region}`: for example, `global`
*   `{view_id}`: for example, `app-logs-view`
*   If you want to allow access to all logs in the log bucket, omit the
    `--log-filter` flag.

### 2. Create a log scope in the scoping project (Tier M)

Create a log scope in the scoping project listing the source resources, which
may be projects or specific log views.

```bash
gcloud logging scopes create {log_scope_id} \
    --project={scoping_project_id} \
    --resource-names={resource_names}
```

*   `{log_scope_id}`: for example, `central-query-scope`
*   `{resource_names}`: Comma-separated list of log views. For example,
    `projects/source-project-1/locations/global/buckets/_Default/views/app-logs-view,projects/source-project-2/locations/global/buckets/_Default/views/app-logs-view`.
    You can include up to 100 views in the scope.

### 3. Update Default Observability Scope (Optional) (Tier M)

Link the log scope to the project's default observability scope so it is used by
default in Logs Explorer.

```bash
gcloud observability scopes update _Default \
    --project={scoping_project_id} \
    --location=global \
    --log-scope=//logging.googleapis.com/projects/{scoping_project_id}/locations/global/logScopes/{log_scope_id}
```

### 4. Grant IAM permissions to users (Tier B)

Unlike centralized routing, permissions are checked at query time on all source
projects. Users running queries must have:

*   `roles/logging.viewAccessor` granted on the specific Log View (with IAM
    conditions) or `roles/logging.viewer` on the source projects.
*   Access to the scoping project.

## Troubleshooting Cross-Project Log Routing and Sink Permission Failures

If logs are not appearing in a central project's bucket after configuring
centralized logging:

### 1. Verify Log Router Sink Filters in Source Resource

*   Ensure that the log sink's filter matches the logs you expect to route.

    > [!IMPORTANT] **Gotcha:** Standard filter expressions like `logName:abc` or
    > `logName="projects/{project_id}/logs/abc"` can fail to match in log sinks.
    > **Always** use `LOG_ID("abc")` for precise matching in log sink filters.

*   Verify that you have not configured an exclusion filter that accidentally
    discards these logs.

### 2. Verify and Grant Writer Identity Permissions (Most Common Cause)

The log sink's writer identity service account in the source project must be
explicitly granted the necessary permissions on the central resource.

*   **Step A: Get the Writer Identity**

    ```bash
    gcloud logging sinks describe {sink_name} \
        --project={source_project_id} \
        --format="value(writerIdentity)"
    ```

*   **Step B: Grant the Permission in the Central Project (Tier B)**

    > [!IMPORTANT] **Security Action (Tier B):** Granting IAM permissions
    > changes access control policy and must be explicitly confirmed by the user
    > before execution.

    *   **For Cloud Logging Buckets (standard):** Grant
        `roles/logging.bucketWriter`:

        ```bash
        gcloud projects add-iam-policy-binding {central_project_id} \
            --member={writer_identity} \
            --role=roles/logging.bucketWriter
        ```

    *   **For GCS Buckets:** Grant `roles/storage.objectCreator` on the GCS
        bucket.

    *   **For Pub/Sub Topics:** Grant `roles/pubsub.publisher` on the Pub/Sub
        topic.

    *   **For BigQuery Datasets:** Grant `roles/bigquery.dataEditor` on the
        BigQuery dataset.

--------------------------------------------------------------------------------

## References and Supporting Links

*   [GCP Cloud Logging - Routing and Storage Overview](https://docs.cloud.google.com/logging/docs/routing/overview.md.txt)
*   [GCP Cloud Logging - Log Scopes](https://docs.cloud.google.com/logging/docs/log-scope/create-and-manage.md.txt)
*   [GCP Cloud Logging - Custom Log Views](https://docs.cloud.google.com/logging/docs/logs-views.md.txt)

© google · Apache-2.0 · google/skills

Смотрите также

Спонсоры проекта

Компании, которые помогают держать аналитику открытой