Google Pub/Sub Service Connector

Connecting Google Pub Sub to a Waylay Broker

Prerequisites

  • Access to GCP (Google Cloud Platform)
  • Service account of Pub/Sub
  • IoT connected device
  • Waylay Broker url

Main building blocks of this integration are presented below: alt text

Abstract

Say your organisation has some devices that are connected in Google Pub/Sub and that the devices are configured to push their telemetry data to a Topic or multiple Topics. How does one connect this data on these topic to a Waylay Environment for creating rules and templates? The service connector allows you to bridge the connection between Google PubSub and your Waylay environment fairly easy!

All one needs to do is to download this service connector as a Docker image and run it with a file that contains the environment variables.

The command for running the docker is as followed:

docker run -p 3000:3000 --rm --name connector --env-file=PathToFile/connectorFile googleIoTConnectorDockerImage

Create a file and insert the configurable variables listed below.

Configuration of Google PubSub Connector

The following environment variables have to be configured:

Var Default Description
PORT 3000 Port
PARSE_MODE Flattening JSON objects or not (value can be ‘flat’ or not filled in)
GOOGLE_APPLICATION_CREDENTIALS Google Application Credentials for Pub/Sub. Must be a JSON type key.
PROJECT_ID Google Project ID
PUBSUB_TOPICS Google PubSub Topics names (seperated by ;)
PUBSUB_SUBSCRIPTION Google PubSub Subscription name
TENANT_ID TenantId of your organisation
APPLICATION_SECRET Secret of your application
APPLICATION_ID Id of your application
AUTH_URL Waylay accounts url
BROKER_URL URL of your broker

GOOGLE_APPLICATION_CREDENTIALS


Make a google service account for Pub/Sub and specifiy a relative path to that JSON file.

alt text

Example:

GOOGLE_APPLICATION_CREDENTIALS="/Users/user/Desktop/pubsub.json"

PROJECT_ID


Unique Google Project Id

PUBSUB_TOPICS


Name of the PubSub Topic for where this service needs to pull messages from. This can be multiple Topics at once seperated by ;.

Example:

PUBSUB_TOPICS=Topic1;Topic2

PUBSUB_SUBSCRIPTION


Name of the PubSub subscription. Can be any name, the name of the subscription gets postfixes with an unique id.

Example:

PUBSUB_SUBSCRIPTION=test Will resolve in PUBSUB_SUBSCRIPTION=test-cab0fd64-eec0-4625-a982-94f0d4d8b28a

PARSE_MODE


This will convert nested JSON objects into flat (key, value) objects so that all metric are stored in the timeseries database.

value : PARSE_MODE='flat' or not specified