---
title: Google Cloud Pub/Sub Integration Guide
slug: bhdo-v1/google-cloud-pubsub-integration-guide
createdAt: 2022-11-24T18:24:54.000Z
---

Review the following guide for setting up an integration between Belden Horizon Data Operations and [Google Pub/Sub service](https://cloud.google.com/pubsub/docs/overview).&#x20;

Once the integration is set up, you can use it for the following:&#x20;

- Publishing data from a topic in your edge device to a *Subscription&#x20;*&#x74;opic in the Google Cloud Platform
- Subscribing to data published by a *Publication&#x20;*&#x74;opic in the Google Cloud Platform

:::hint{type="info"}
**Note**: As of Belden Horizon Data Operations version 3.11.3, you can use the following authentication methods to configure the Google Cloud Pub/Sub connector:

- Using GCP Auth type Service Account Key
- Using GCP Auth type Workload Identity Federation
:::

# Before You Begin

- You need to create a Google Service Account. Make sure the account has the correct roles and permissions required for setting up the connection.&#x20;
- Refer to the following Google resources for learning more about Pub/Sub and configuring connections:
  - [Google Pub/Sub service](https://cloud.google.com/pubsub/docs/overview)
  - [Configure Private Google Access for on-premises hosts > Domain Options ](https://cloud.google.com/vpc/docs/configure-private-google-access-hybrid#config-choose-domain)(information regarding private access to GCP services)
  - [Supported products and limitations > Pub/Sub ](https://cloud.google.com/vpc-service-controls/docs/supported-products#table_pubsub)(information regarding private access to GCP services)
  - [SDK on Publish Settings](https://pkg.go.dev/cloud.google.com/go/pubsub#PublishSettings)
  - [Publish messages to topics](https://cloud.google.com/pubsub/docs/publisher)

# Set up the Outbound Connection (Publish to Google Pub/Sub)

Follow the steps below to set up the outbound connection.&#x20;

## Step 1: Create Publication Topic in Google Cloud Platform

In the Google Cloud Platform, create a *publication&#x20;*&#x74;opic. A matching *subscription&#x20;*&#x74;opic is created automatically, with the *-sub* suffix appended to the topic name.

## Step 2: Add Device

Follow the steps to [Connect a Device](docId\:T-cWPe0_Jsfw5-aoj8WPP). The device will be used to store tags that will be eventually used to create outbound topics in the connector. Make sure to select the **Enable Data Store** check box.&#x20;

## Step 3: Add Tags

After connecting the device in Belden Horizon Data Operations, you can [Add Tags](docId\:Wpe2HMXelARLBnhWbuChY) to the device. Create tags that you want to use to create outbound topics for the connector.&#x20;

## Step 4: Add the Google Cloud Pub/Sub Connector

Follow the steps to [Add a Connector](docId\:rrskXSXVcBZSd6UWyJ-yv) and select the **Google Cloud Pub/Sub Connector** provider.&#x20;

For more information about message publication settings, see the [SDK on Publish Settings](https://pkg.go.dev/cloud.google.com/go/pubsub#PublishSettings).&#x20;

Configure the following parameters.&#x20;

- **Name**: Enter a name for the connector.&#x20;
- **Service Account Key (.json)**: Create a service account key in your Google Cloud Platform in JSON format. Copy all the content from the JSON file and paste it here.&#x20;
  - For Belden Horizon Data Operations version 3.10.0 and later, you have the option to upload a file.&#x20;
  - For Belden Horizon Data Operations version 3.11.3 and later, you have the option to use Workload Identity Federation authorization in the service-account key file.&#x20;
- **The project ID of the cloud project**: Copy the ID from your Google Cloud Platform and paste it here.&#x20;
- **The private key ID of the cloud project**: Copy the key ID from your Google Cloud Platform and paste it here.&#x20;
- **The client email of the cloud project**: Enter the email from your Google Cloud Platform.&#x20;
- **Integration Topic**: Copy the name of the *Publication&#x20;*&#x74;opic (without the "-sub" suffix) from your Google Cloud Platform and paste it here.
- **Show Custom Attributes**: For Belden Horizon Data Operations version 3.11.0 and later, you can add custom attributes in key/value pairs for further data processing. Refer to the following to learn more:
  - [Use Custom Attributes in the Google Cloud Pub/Sub Connector](docId\:xOijefJQiI074iTmIA7gu)
  - Google documentation for [Using attributes](https://cloud.google.com/pubsub/docs/publisher#using-attributes)
- **Parallel Publish Count**: The number of messages being published simultaneously. The default value is **100**. &#x20;
- **Parallel byte threshold**: The minimum size of a batch (in bytes) for the batch to be published. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Publish count threshold**: The minimum number of messages in a batch for the batch to be published. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Publish delay threshold (Milliseconds)**: The maximum time that the client will attempt to publish a batch of messages. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Throttling limit**: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.&#x20;
- **Persistent storage**: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Belden Horizon Data Operations when cloud providers are online. &#x20;

## Step 5: Enable the Connector

If you see a *Failed&#x20;*&#x73;tatus, review the [Connector Logs](docId\:wciGtqYdwS5P7BnDd7LId) and any relevant error messages.&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/vAqK-046vdh4I0e1y9cfX/i5gg7oIjHGVdtiVFcVxq1_google.png" size="60" width="370" height="345" position="center" showCaption="false"}

If you see a *Failed&#x20;*&#x73;tatus, review the [Connector Logs](docId\:wciGtqYdwS5P7BnDd7LId) and any relevant error messages.&#x20;

## Step 6: Create Outbound Topics for Connector

You will now need to import the tags you added in Step 2 to the connector as topics.&#x20;

**To create outbound topics:**

1. Click the connector tile.
   The connector *Dashboard&#x20;*&#x61;ppears.&#x20;
2. Click the **Topics&#x20;**&#x74;ab.&#x20;
3. Click the **Import from DeviceHub** tags icon.&#x20;
   The *DeviceHub Import&#x20;*&#x64;ialog box appears.

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/4fC8yaOKctxiiTvUDGfWu_import-from-devicehub.png" size="80" width="1148" height="570" position="center" showCaption="false"}
4. Select all the tags to import and click **Import**.&#x20;

After importing the tag(s), do the following:

- Edit the tag and configure the **Remote Data Topic**. Copy and paste the name of the *Subscription&#x20;*&#x74;opic  (with the `-sub` suffix) from your Google Cloud Platform. &#x20;
- Make sure the connector has a CONNECTED status.&#x20;

## Step 7: Enable Topics

Because you imported DeviceHub tags for a *CONNECTED* connector, all topics will be disabled.&#x20;

To enable the topics, return to the Topics tab and click the **Enable all topics** icon.&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/Bgs6D9yH8dU8qzJycO9lv_enable-all-topics.png" size="80" width="1148" height="570" caption="Enable all topics icon" position="center" showCaption="true"}

## Step 8: Verify Connection in Google Cloud Platform

**To verify the connection in Google Cloud Platform:**

1. Pull the *subscription&#x20;*&#x74;opic to see messages it receives from the Belden Horizon Data Operations outbound topics created previously.&#x20;

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/-VdXPYXn3ue8QmzOVGPMD_pubsubmsg1000x272.png" size="80" width="1000" height="272" caption="List of Belden Horizon Data Operations outbound topics" position="center" showCaption="true"}
2. View the *subscription&#x20;*&#x73;tatistics.&#x20;

   ![](https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/u-2c_cHty2BoX6BGFJBKN_pubsubgraph1000x235.png "Graph of subscription statistic")

# Set up the Inbound Connection (Subscribe to Google Pub/Sub)

Follow the steps below to set up the inbound connection.&#x20;

See [Publish messages to topics](https://cloud.google.com/pubsub/docs/publisher) to learn more about publishing messages in Google Pub/Sub.&#x20;

## Step 1: Create Publication Topic in Google Cloud Platform

In the Google Cloud Platform, create a *publication&#x20;*&#x74;opic.

## Step 2: Add the Google Cloud Pub/Sub Connector

Follow the steps to [Add a Connector](docId\:rrskXSXVcBZSd6UWyJ-yv) and select the **Google Cloud Pub/Sub Connector** provider.&#x20;

Configure the following parameters.&#x20;

- **Name**: Enter a name for the connector.&#x20;
- **Service Account Key (.json)**: Create a service account key in your Google Cloud Platform in JSON format. Copy all the content from the JSON file and paste it here. For Belden Horizon Data Operations version 3.10.0 and later, you have the option to upload a file.&#x20;
- **The project ID of the cloud project**: Copy the ID from your Google Cloud Platform and paste it here.&#x20;
- **The private key ID of the cloud project**: Copy the key ID from your Google Cloud Platform and paste it here.&#x20;
- **The client email of the cloud project**: Enter the email from your Google Cloud Platform.&#x20;
- **Integration Topic**: Copy the name of the *Publication&#x20;*&#x74;opic from your Google Cloud Platform and paste it here.
- **Show Custom Attributes**: For Belden Horizon Data Operations version 3.11.0 and later, you can add custom attributes in key/value pairs for further data processing. Refer to the following to learn more:
  - [Use Custom Attributes in the Google Cloud Pub/Sub Connector](docId\:xOijefJQiI074iTmIA7gu)
  - Google documentation for [Using attributes](https://cloud.google.com/pubsub/docs/publisher#using-attributes)
- **Parallel Publish Count**: The number of messages being published simultaneously. The default value is **100**. &#x20;
- **Parallel byte threshold**: The minimum size of a batch (in bytes) for the batch to be published. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Publish count threshold**: The minimum number of messages in a batch for the batch to be published. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Publish delay threshold (Milliseconds)**: The maximum time that the client will attempt to publish a batch of messages. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Throttling limit**: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.&#x20;
- **Persistent storage**: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Belden Horizon Data Operations when cloud providers are online. &#x20;

## Step 3: Enable the Connector

After adding the connector, click the toggle in the connector tile to enable it.&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/vAqK-046vdh4I0e1y9cfX/BFmT61TZsy0574SQKMmm0_google.png" size="60" width="370" height="345" position="center" showCaption="false"}

If you see a *Failed&#x20;*&#x73;tatus, review the [Connector Logs](docId\:wciGtqYdwS5P7BnDd7LId) and any relevant error messages.&#x20;

## Step 4: Create Inbound Topics for Connector

You will now need to create a topic in Belden Horizon Data Operations from the Google Cloud Platform publication topic created in Step 1.&#x20;

**To create inbound topics:&#x20;**

1. Navigate to **Integration**.&#x20;
2. Click the connector tile.&#x20;
3. Click the **Topics&#x20;**&#x74;ab.&#x20;
4. Click th&#x65;**&#x20;Add a new subscription** icon.
   The *Data Integration* dialog box appears.

   ![](https://api.archbee.com/api/optimize/vAqK-046vdh4I0e1y9cfX/P4Nc2AUXvs50fzxjGbDNE_googleaddsubscriptionbhdo.png)
5. Configure the following parameters.&#x20;
   - **Data Direction**: Select **Remote to Local - Inbound**.&#x20;
   - **Local Data Topic**: Enter a name for the topic name in Belden Horizon Data Operations.&#x20;
   - **Remote Data Topic**: Copy and paste the *Publication&#x20;*&#x74;opic from your Google Cloud Platform.&#x20;
   - **Enable**: Select the toggle to enable the topic.&#x20;
6. Click **Yes&#x20;**&#x74;o add the topic.&#x20;
7. From the connector tile, ensure the connector is not disabled and still shows a CONNECTED status. Also verify the topic shows an *Enabled&#x20;*&#x73;tatus.&#x20;

![](https://api.archbee.com/api/optimize/vAqK-046vdh4I0e1y9cfX/BLV3Y-fER1UFg3USwanrb_image.png)

## Step 5: Send Messages in Google Cloud Platform

Start sending messages through the *publication&#x20;*&#x74;opic (created in Step 1) from the Google Cloud Platform. See [Publish messages to topics](https://cloud.google.com/pubsub/docs/publisher) to learn more.&#x20;

## Step 6: Verify Connection in Belden Horizon Data Operations

You can do one of the following to verify the connection in Belden Horizon Data Operations. When configuring the Flow or application, use the th&#x65;**&#x20;Local Data Topic** name configured in Step 4.&#x20;

- [Create a Flow](docId\:MOkTG91ETOVhHW2Py7HpK) to view the messages coming from Google Pub/Sub through the connector you created.&#x20;
- Visualize the incoming data using one of the dedicated [Applications](docId:4C6C0l74Y63oZ6hzOj1EN) such as Grafana.&#x20;

