# Google Cloud Pub/Sub (Push)

### Description

Receive messages from a Google Cloud PubSub topic and generate logs from the result.

{% hint style="warning" %}
**IMPORTANT**

The OpenTelemetry receiver this source uses is in development and is subject to change.
{% endhint %}

### Supported Platforms

| Platform | Supported |
| -------- | --------- |
| Linux    | ✓         |
| Windows  | ✓         |
| macOS    | ✓         |

### Configuration Table

<table><thead><tr><th width="159.75">Parameter</th><th width="104.8046875">Type</th><th width="213.46875">Default</th><th>Description</th></tr></thead><tbody><tr><td>listen_address</td><td><code>string</code></td><td>0.0.0.0</td><td>The IP address to listen on.</td></tr><tr><td>listen_port</td><td><code>int</code></td><td>8090</td><td>TCP port to receive Google Cloud Pub/Sub requests.</td></tr><tr><td>encoding_extension</td><td><code>extension</code></td><td><pre><code>type: googlecloudlogentry_encoding
parameters:
- name: cloud_logging_json_handling
  value: json
- name: cloud_logging_proto_handling
  value: json
</code></pre></td><td>The extension to use for parsing the payload.</td></tr><tr><td>enable_tls</td><td><code>bool</code></td><td>false</td><td>Whether or not to use TLS.</td></tr><tr><td>cert_file</td><td><code>string</code></td><td></td><td>Path to the TLS certificate file for the server.</td></tr><tr><td>key_file</td><td><code>string</code></td><td></td><td>Path to the TLS private key file for the server.</td></tr><tr><td>mutual_tls</td><td><code>bool</code></td><td>false</td><td>Whether or not to require client TLS authentication (mTLS).</td></tr><tr><td>ca_file</td><td><code>string</code></td><td></td><td>Path to the certificate authority file for authenticating client certificates.</td></tr><tr><td>include_metadata</td><td><code>bool</code></td><td>false</td><td>Propagates the incoming connection's metadata to downstream consumers.</td></tr><tr><td>enable_cors</td><td><code>bool</code></td><td>false</td><td>Enable Cross-Origin Resource Sharing support for HTTP requests.</td></tr><tr><td>cors_allowed_origins</td><td><code>strings</code></td><td><code>[]</code></td><td>A list of origins a cross-domain request can be executed from.</td></tr><tr><td>cors_allowed_headers</td><td><code>strings</code></td><td><code>[]</code></td><td>The allowed headers sets what headers will be allowed in CORS requests.</td></tr><tr><td>cors_max_age</td><td><code>int</code></td><td>0</td><td>Indicates how long (in seconds) the results of a preflight request can be cached.</td></tr></tbody></table>

**Authentication**

The service account used by the collector should have the `Pub/Sub Subscriber` permission to read from the subscription. Additionally, make sure the subscription channel being received from is configured with `Push` delivery.

Authentication is handled via the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. This should point to a file containing the service account key for the project.

To set this for the collector, you need to modify the service file depending on your OS.

**Linux**

Use a [Systemd override](https://wiki.archlinux.org/title/systemd):

```bash
sudo systemctl edit observiq-otel-collector
```

Then run the following command to reload the systemd configuration:

```bash
sudo systemctl daemon-reload
sudo systemctl restart observiq-otel-collector
```

**Windows**

Start powershell as administrator and run the following command:

```powershell
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\observiq-otel-collector" /v Environment /t REG_MULTI_SZ /d "GOOGLE_APPLICATION_CREDENTIALS=<path to key file>" /f
```

Then restart the collector service:

```powershell
Restart-Service observiq-otel-collector
```

**MacOS**

Add `GOOGLE_APPLICATION_CREDENTIALS` to the `EnvironmentVariables` dict in the launchd service file `/Library/LaunchDaemons/com.observiq.collector.plist` (other values are shown for context):

```xml
<key>EnvironmentVariables</key>
<dict>
    <key>GOOGLE_APPLICATION_CREDENTIALS</key>
    <string><path to key file></string>
    <key>OIQ_OTEL_COLLECTOR_HOME</key>
    <string>/opt/observiq-otel-collector/</string>
    <key>OIQ_OTEL_COLLECTOR_STORAGE</key>
    <string>/opt/observiq-otel-collector/storage</string>
</dict>
```

Then restart the collector:

```bash
sudo launchctl unload /Library/LaunchDaemons/com.observiq.collector.plist
sudo launchctl load /Library/LaunchDaemons/com.observiq.collector.plist
```

### Example Configuration

In this example, we are parsing log data from the given PubSub subscription.

#### Web Interface

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2FGkH8GSAHwmX6O3FgGMe7%2Fimage.png?alt=media&#x26;token=6a395a0d-ca05-4943-8617-be8a0648f494" alt=""><figcaption></figcaption></figure>

#### Standalone Source

```yaml
apiVersion: bindplane.observiq.com/v1
kind: Source
metadata:
    name: pubsubpush
spec:
    type: googlecloudpubsubpush:1
    parameters:
        - name: listen_address
          value: 0.0.0.0
        - name: listen_port
          value: 8090
        - name: encoding_extension
          value:
            disabled: false
            parameters:
                - name: cloud_logging_json_handling
                  value: json
                - name: cloud_logging_proto_handling
                  value: json
            type: googlecloudlogentry_encoding
        - name: enable_tls
          value: false
        - name: cert_file
          value: ""
        - name: key_file
          value: ""
        - name: mutual_tls
          value: false
        - name: ca_file
          value: ""
        - name: include_metadata
          value: false
        - name: enable_cors
          value: false
        - name: cors_allowed_origins
          value: []
        - name: cors_allowed_headers
          value: []
        - name: cors_max_age
          value: 0
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bindplane.com/integrations/sources/google-cloud-pub-sub-push.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
