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

# GCP Cloud Logging

> Forward Google Cloud Logging entries into Squasher with the GCP drain endpoint.

Squasher accepts Cloud Logging entry JSON, so you can forward batched or single log entries from your GCP delivery step into a Squasher project.

## Overview

<Note>
  Send the Cloud Logging JSON body from your forwarder or delivery step. Squasher accepts either an
  `entries` array or a single top-level log entry.
</Note>

## Prerequisites

* A Squasher project ID
* A Squasher drain key or log connector key for that project
* Access to create or update a Cloud Logging sink or Logs Router filter
* A delivery step that can POST Cloud Logging JSON to Squasher

## Endpoint URL

```text theme={null}
https://ingest.squasher.ai/v1/drain/gcp/{project_id}
```

## Authentication

Send your drain key in the `x-squasher-key` header on every request.

```http theme={null}
x-squasher-key: sq_pk_your_drain_key
Content-Type: application/json
```

## Payload Format

The GCP drain accepts batched entries and direct single-entry requests.

<CodeGroup>
  ```json Batched entries theme={null}
  {
    "logName": "projects/demo/logs/run.googleapis.com%2Fstdout",
    "entries": [
      {
        "severity": "ERROR",
        "textPayload": "Unhandled exception in worker",
        "timestamp": "2024-03-21T12:00:00Z"
      }
    ]
  }
  ```

  ```json Single entry theme={null}
  {
    "logName": "projects/demo/logs/custom",
    "severity": "CRITICAL",
    "jsonPayload": {
      "message": "database connection lost",
      "component": "worker"
    },
    "timestamp": "2024-03-21T12:05:00Z"
  }
  ```
</CodeGroup>

## Setup Steps

<Steps>
  <Step title="Create or update the sink">
    In **Logging > Logs Router**, create a sink or filter that selects the Cloud Logging streams you want to forward.
  </Step>

  <Step title="Choose the delivery step">
    Use the forwarding step that will POST the Cloud Logging JSON body to Squasher.
  </Step>

  <Step title="Send the payload to Squasher">
    Configure that delivery step to call the GCP drain endpoint with the `x-squasher-key` header and the Cloud Logging JSON body shown above.
  </Step>
</Steps>

## Working cURL Example

Use this example to verify the drain before you wire in your Cloud Logging delivery flow.

```bash theme={null}
PROJECT_ID="your-project-id"
SQUASHER_KEY="sq_pk_your_drain_key"

curl -X POST "https://ingest.squasher.ai/v1/drain/gcp/${PROJECT_ID}" \
  -H "Content-Type: application/json" \
  -H "x-squasher-key: ${SQUASHER_KEY}" \
  -d '{
    "logName": "projects/demo/logs/run.googleapis.com%2Fstdout",
    "entries": [
      {
        "severity": "ERROR",
        "textPayload": "Unhandled exception in worker",
        "timestamp": "2024-03-21T12:00:00Z"
      }
    ]
  }'
```

A successful request returns `202 Accepted`.

## Agent handoff

```text theme={null}
Set up Cloud Logging forwarding to Squasher for project <project_id>. Use a project-specific drain or connector key, verify with one batched entry payload, and ask before changing sink filters or delivery routing.
```
