# How to send data to the Google Cloud Pub/Sub

![](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2F8H5jyrdCKDedGCrNuYIh%2Fimage.png?alt=media\&token=b3a1b86a-6e1c-440a-a8e6-2618713cce44)

{% hint style="success" %}
**Benefits of the Google Cloud Pub/Sub output connector**:

* Directly stream device data from akenza to **Google Cloud Pub/Sub** and subsequently process it in **Google Cloud Pub/Sub**
* Easily process **low-power device** data e.g. LoRaWAN device data in **Google Cloud Pub/Sub**
  {% endhint %}

In this tutorial, you will learn, how to send data to [**Google Cloud Pub/Sub**](https://cloud.google.com/pubsub/docs/overview). The following steps are explained in more detail:

1. [Setup a **Google Cloud Pub/Sub**](#1.-setup-a-gcp)
2. [Add an akenza service account](#2.-add-akenza-service-account)
3. [Setup a **Data Flow** in akenza ](#3.-setup-a-data-flow-in-akenza)
4. [Setup a subscription](#4.-setup-a-subscription)
5. [Useful Links](#5.-useful-links)

### 1. Setup a **Google Cloud Pub/Sub**

First, you will need to set up a project on the **Google Cloud Console**.

1.1 If you are new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how the products perform in real-world scenarios.

1.2 Set up a **Cloud Console project** in a PubSub section <https://cloud.google.com/pubsub>. Create or select a project and enable the **Pub/Sub API** for that project. You can view and manage these resources at any time in the [Cloud Console](https://console.cloud.google.com/).

1.3 Set up a topic where your data shall be sent to. Go to the Pub/Sub topics page in the Cloud Console. [Go to the Pub/Sub topics page](https://console.cloud.google.com/cloudpubsub/topicList) and select *Create a topic*.

In the **Topic ID** field, provide a unique topic name, for example, `MyTopic` and select *Save*.

### 2. Add an akenza service account

Navigate to your Project settings and select on **IAM** policy section. Select *+ Add* and paste the akenza publisher service account key. Give the role of a **Pub/Sub Publisher.**

![IAM section ](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2FOK5nB4hHeFA1mGquvSdn%2Fscreely-1634934954255_gcp.png?alt=media\&token=c0cb4b91-cbc7-4664-9a82-b4878d10b829)

### 3. Setup a Data Flow in akenza

Create a new **Data Flow** in akenza with Google Cloud Pub/Sub as output connector. Define a **Connector Name** and insert the **topic id** obtained from the project. Optionally use a custom payload.

![Google Pub/Sub template](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2FH2ShhIYuHiYCoMN1Bh2Y%2Fscreely-1640897030669%20google%20OC.png?alt=media\&token=6cc146f9-f231-49fb-b5b8-9425f3db123c)

[Create a new device](https://docs.akenza.io/akenza.io/how-to-create-a-working-environment/how-to-connect-a-device) using the Data Flow and start sending data.

### 4. Setup a Subscription

In your Pub/Sub section go to **Subscriptions**, select *Create Subscription*, give it a name, and select the previously created topic.

Following steps to view device data:

* Click on the created topic
* Scroll down to the bottom of the topic details
* There are three tabs, select **Messages**&#x20;
* Open the dropdown on the bottom "Select a Cloud Pub/Sub Subscription to pull messages from \*" and select the subscription previously created
* Click *Pull* to fetch the messages which can then be filtered in **Filter** options and sorted by various p

### 5. Useful Links

* [Google Cloud Pub/Sub on akenza](https://docs.akenza.io/akenza.io/get-started/your-data-flow/connectors/streaming/google-cloud-pub-sub)

{% embed url="<https://cloud.google.com/pubsub>" %}


---

# 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.akenza.io/akenza.io/tutorials/create-enterprise-solutions/how-to-send-data-to-the-google-cloud-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.
