Connecting to Google Pub/Sub

Use the following steps to setup the Google Pub/Sub Integration.

Create your PubSub Topic

  1. Go to the Cloud Pub/Sub topics page in the GCP Console.
  2. Click Create Topic, enter a name and complete adding your new topic. Once completed, make note of the complete topic string shown in Topic details - you will need this information later when setting up the Integration.
    GPubSub4.png
    GPubSub5.png

Setup your Cloud Storage Account Service key

In this step we will setup an account key which will then be used by the Integration so that it can publish events.

  1. In the Google Cloud console and go to IAM & admin and select the Service accounts option.
    mceclip3.png
  2. Click on Create Service Account.
    mceclip4.png
  3. Give the account an appropriate Name and description. The Service account ID will be generated automatically for you during this step - you can leave it as the default.
    mceclip5.png

    Click Create to create the service account and continue.
  4. On the Permissions screen that appears, give the account the permission Pub/Sub Publisher so that it can publish events.
    mceclip6.png

     Click Continue and then Done to complete creating the service account.
  5. Locate the Service account you created, click on the 3-dot menu and select Create Key.
    mceclip7.png
  6. In the popup that appears, you can leave it as JSON and click Create. This will download a json file containing the private key information that we need when setting up the integration.
    mceclip8.png
  7. Open the downloaded json file. You will need to copy the entire contents from this file when asked during integration setup.
    mceclip9.png

Create the Integration

  1. Log into your account on the IoT in a Box portal.
  2. Select the Integrations option and then select the Google PubSub integration.
  3. Enter the following information to complete the integration:
    • Name: Enter a name for this integration. In case you have multiple integrations, this will help uniquely identify it in the list.
    • Topic: Enter the complete topic string for your topic.
      np_lightbulb_1247022_000000.png Be sure that you copy the complete string, including both topic & project id here.

    • Service Account Key: Paste the entire contents of the service key file, as obtained above.
      np_lightbulb_1247022_000000.png Paste the entire contents of the json private key file here.

      mceclip0.png

 After saving the Integration, you will see it shown in your list of integrations.

GPubSub1.PNG

  • You can then edit the integration to make any changes needed.
  • You can also toggle the Integration on/off at any time from here as well. Disabling the integration will stop new data from being sent to the PubSub topic.

Verifying things are working

You can verify the integration is working by adding a Subscription in GCP and then pulling messages for the topic.

np_lightbulb_1247022_000000.png Note: Data is published in reading and alert messages, one for each new event, recorded in JSON format.

As an example, you can use the GCP console and then use the following query to pull messages for your subscription. Note that this query only pulls in messages one at a time.

gcloud pubsub subscriptions pull --auto-ack your-subscription-string-here

GPubSub6.png

GPubSub3b.PNG