# Collect data from Google Pub/Sub

{% hint style="info" %}
See the changelog of the **Google Pub/Sub** Listener [here](/listeners/google-pub-sub-listener.md).
{% endhint %}

{% hint style="warning" %}
The **Google Pub/Sub** Listener is a **Pull** Listener and therefore should not be used in environments with more than one cluster.
{% endhint %}

## Overview

Onum supports integration with [Google Pub/Sub](https://cloud.google.com/pubsub/docs/overview).

Google Pub/Sub is an asynchronous and scalable messaging service that decouples services producing messages from services processing those messages. Pub/Sub allows services to communicate asynchronously.

Select **Google Pub/Sub** from the list of Listener types and click **Configuration** to start.

## Google Cloud Storage Setup

To source data from Google Cloud Pub/Sub you need to have a Google Cloud project, appropriate roles and permissions to run Pub/Sub, and enable the Pub/Sub API.

See [Google Cloud Pub/Sub documentation](https://cloud.google.com/pubsub/docs) for help on how to set these up.

## Onum Setup

{% stepper %}
{% step %}
Log in to your Onum tenant and click **Listeners > New listener**.
{% endstep %}

{% step %}
Double-click the **Google Pub/Sub** Listener.
{% endstep %}

{% step %}
Enter a **Name**<mark style="color:$primary;">**\***</mark> for the new Listener. Optionally, add a **Description** and some **Tags** to identify the Listener.
{% endstep %}

{% step %}
The **Project ID**<mark style="color:red;">**\***</mark> is a unique string with the following format: `my-project-123456`. To get it:  &#x20;

1. Go to the Google Cloud Console.
2. In the top left corner, click on the **project drop-down** next to the Google Cloud logo (where your current project name is shown).
3. Each project will have a **Project Name** and a **Project ID**.
4. You can also find it in the **Settings** tab on the left-hand side.
   {% endstep %}

{% step %}
Enter your **Subscription Name**<mark style="color:red;">**\***</mark>

1. Go to **Pub/Sub** in the **Google Cloud Console**.
2. In the top left corner, click on the **menu** and select **View all Products**.
3. Then go to **Analytics** and find **Pub/Sub**. Click it to go to Pub/Sub (you can also use the search bar and type `Pub/Sub`).
4. In the **Pub/Sub** dashboard, select the **Subscriptions** tab on the left.
5. The **Subscription Name** will be displayed in this list.
   {% endstep %}

{% step %}
The Google Cloud connector uses OAuth 2.0 credentials for authentication and authorization. Select the **Credentials File**<mark style="color:$primary;">**\***</mark> from your [Secrets](https://docs.onum.com/administration/tenant-menu) or click **New secret** to generate a new one.

1. To find the **Google Cloud credentials file**, go to **Settings > Interoperability**.
2. Scroll down to the **Service Account** area.
3. You need to generate and download a **service account key** from the Google Cloud Console. You will not be able to view this key, so you must have it copied somewhere already. Otherwise, create one here and save it to paste here.
4. To see existing Service Accounts, go to the menu in the top left and select **APIs & Services > Credentials**.
   {% endstep %}

{% step %}
Decide whether or not to activate the bulk message option using the **Enabled**<mark style="color:red;">**\***</mark> field.&#x20;

Then, choose the required **Message Format** and enter the characters you want to use as delimiters in the **Delimiter Char Codes** field, if required. A delimiter character code refers to the numerical representation (usually in ASCII or Unicode) of a delimiter.
{% endstep %}

{% step %}
Finally, click **Create labels**. Optionally, you can set labels to be used for internal Onum routing of data. By default, data will be set as **Unlabeled**.

{% hint style="info" %}
Learn more about labels in [this article](/the-workspace/listeners/labels.md).
{% endhint %}
{% endstep %}

{% step %}
Click **Create listener** when you're done.
{% endstep %}
{% endstepper %}

## Output Ports <a href="#ports" id="ports"></a>

The **Google Pub/Sub** Listener has two output ports:

* **Default port** - Events are sent through this port if no error occurs while processing them.
* **Error port** - Events are sent through this port if an error occurs while processing them.


---

# 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.onum.com/the-workspace/listeners/listener-integrations/collect-data-from-google-cloud-products/collect-data-from-google-pub-sub.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.
