Google Pub/Sub
What Is Google Pub/Sub?
Google Pub/Sub is a fully managed messaging service that facilitates asynchronous communication between distributed systems. It uses a publish/subscribe model, where producers send messages to a topic, and subscribers consume those messages. Pub/Sub is designed for high-throughput, low-latency message delivery, making it suitable for real-time event-driven architectures, data pipelines, and streaming analytics. It supports features such as message filtering, dead-letter topics, and at-least-once delivery, ensuring reliability and fault tolerance. Seamless integration with Google Cloud services enhances its utility for building scalable, resilient applications.
What are the benefits of integrating MetaRouter with Pub/Sub?
- Real-time Data Streaming: Enables real-time delivery of event data from MetaRouter to Google Pub/Sub for immediate processing.
- Scalable Architecture: Supports high-throughput data publishing, allowing the system to handle large volumes of event data efficiently.
- Seamless Integration: Works natively with Google Cloud services, simplifying downstream analytics, processing, and storage.
Capabilities and Considerations
- Workload Identity: If your MetaRouter deployment runs on Google Kubernetes Engine (GKE), you can authenticate with Pub/Sub using Workload Identity instead of a JSON service account key. Workload Identity allows your MetaRouter pods to authenticate directly with Google Cloud APIs without managing static credentials, providing a more secure and maintenance-free authentication method. This is the recommended path.
- Workload Identity is supported only for clusters running in Google Cloud (GKE). Deployments hosted outside of GCP must use the Service Account JSON key authentication method.
- Event Publishing: The integration publishes all collected event data to a specified Google Pub/Sub topic for further processing.
- Global Expressions: Supports global transformations or enrichments via Lua expressions in the playbook configuration.
- Google Cloud Integration: Fully compatible with other Google Cloud services, such as BigQuery and Dataflow, for advanced data handling.
- Initial Setup Complexity: Configuration of credentials, project IDs, and topic names must be precise to avoid integration errors.
Limitations
- Single Topic: Event data is published to a single, pre-defined topic.
- No Built-in Filtering: The integration itself does not perform event filtering; filtering must be implemented downstream or through Pub/Sub's native features.
Getting Started - From Your Google Pub/Sub Account
Step 1: Finding the Project ID
Finding the Project ID
- In the Google Cloud Console:
- Navigate to your project by clicking on the dropdown menu in the top navigation bar.
- The Project ID is listed next to the project name.
- Copy the Project ID and use it for the
projectIDfield in the YAML. - For more information, see:
- In addition, you can find the Project ID in your downloaded credentials JSON file, listed under the
project_idfield.
Step 2: Choose Your Authentication Method
Path A — Workload Identity Flow
-
If you are using the Workload Identity flow, please reach out to your MetaRouter representative. We will generate a service account email for you.
-
Assign the necessary roles to the service account email provided by the MetaRouter team. You will need to grant at least the "Pub/Sub Publisher" role.
-
Leave the
CREDENTIALSfield empty in your MetaRouter Pub/Sub integration configuration. When no credentials are provided, the integration automatically falls back to GCP default credentials, which Workload Identity supplies.
Path B — Service Account Key Flow
- Create a Service Account:
- Go to the Google Cloud Console.
- Navigate to IAM & Admin > Service Accounts.
- Click Create Service Account.
- Enter a name, description, and click Create and Continue.
- You will need to grant at least the "Pub/Sub Publisher" role.
- Click Done to complete the service account setup.
- Download the JSON Key:
- Locate the newly created service account in the list.
- Click the three-dot menu next to the account and select Manage Keys.
- Click Add Key > Create New Key, and select the JSON format.
- Download the JSON file. This file contains the credentials needed for the
credentialsfield in the YAML.
- Secure the Credentials: Store the JSON file securely and provide its path or contents as the
credentialsin the YAML configuration. - For detailed instructions, refer to:
Step 3: Creating and Identifying the Pub/Sub Topic
- Create a New Topic (if not already created):
- Go to Pub/Sub in the Google Cloud Console.
- Click Create Topic.
- Enter a topic name and click Create.
- Find the Topic Name:
- In the Pub/Sub section, locate your topic in the list.
- Copy the full topic name (e.g.,
projects/my-project-id/topics/my-topic).
- Extract only the topic name (e.g.,
my-topic) for thetopicfield in the playbook configuration. - For detailed guidance, refer to:
Getting Started - From Your MetaRouter Account
Adding a Google Pub/Sub integration.
From the integration library, add a Google Pub/Sub integration. Then, fill out the Connection Parameters:
| Connection Parameter | Description |
|---|---|
CREDENTIALS | A JSON file containing the service account's authentication details for accessing Pub/Sub. Leave empty if using Workload Identity authentication (see above in Getting Started section). |
PROJECT_ID | The unique identifier for your Google Cloud project hosting the Pub/Sub topic. |
TOPIC | The destination in Pub/Sub where event data is published for subscribers to consume. |
Event Mappings
By default, the playbook includes a global Lua expression:
lua
CopyEdit
return inputThis configuration ensures that all events are forwarded to Pub/Sub exactly as received, without modifications.
You can customize this behavior by modifying the Lua expression to transform event data as needed. Additionally, event filtering can be applied within the playbook configuration, similar to other MetaRouter integrations.
All events are published to the single Pub/Sub topic specified in the TOPIC parameter, and any additional routing or filtering must be handled downstream by Pub/Sub subscribers.
Additional Google Pub/Sub Documentation
Updated 7 days ago