2026.10 2026.08 2026.07 2026.06 2026.05 2026.04 2026.02 2026.01
2026.10 2026.08 2026.07 2026.06 2026.05 2026.04 2026.02 2026.01

Configure the PubSub Beat

Collect Account Information from the GCP Console

The following information is required to configure Google for Beats:

  • Project ID

  • Credential file for a particular GCP account

  • Topic Name

  • Subscription Name (also referred to as Subscription ID)

Create a Role For a Project 

  1. Open the GCP Console: https://console.cloud.google.com.

  2. On the left-side menu, click IAM & Admin, and then click Roles.

  3. In the center pane, click Create Role.

  4. Enter the basic information requested for the role.

  5. Click Add Permissions and select the following permissions:

    • pubsub.subscriptions.consume

    • pubsub.subscriptions.get

    • pubsub.subscriptions.create

    • pubsub.topics.attachSubscription

    If you have set subscription.create: false in pubsubbeat.yml file (the default value for subscription.create is true) and you are using an existing subscription, you can add the following permissions:

    • pubsub.subscriptions.consume

    • pubsub.subscriptions.get

    • pubsub.subscriptions.update

  6. Click Add, and then Create.

Generate a Credential File

  1. Open the GCP Console: https://console.cloud.google.com.

  2. On the top menu bar, select the project to collect logs from.

    image-20260924-215556.png

To create a project, see the instructions provided by Google here: https://cloud.google.com/resource-manager/docs/creating-managing-projects

The Select a project dialog box appears

  1. Make a note of the Project ID.

    image-20260924-215642.png
  2. From the left-side menu, click APIs & Services, and then click Credentials.

  3. In the center pane, click Create credentials, and then click Service account.

  4. In the Create service account section, enter a service account name and optional description.

  5. In the Permissions section, select the role you created.

  6. Click Done.

  7. Locate your service account on the Service accounts page, click the vertical ellipsis (⋮) at the end of the row, and select Manage Keys

  8. Click Add key, then Create new key, then select Key type: JSON

  9. Click Create.

  10. Save the file somewhere you can easily access it.

Regarding the four secrets needed to configure the PubSub beat (ClientId, ClientEmail, PrivateKey, PrivateKeyId):

    • The collector moves into an ERROR state for a wrong ClientEmail and PrivateKey.

    • The collector does not move into an ERROR state for a wrong ClientId and PrivateKeyId, although it does not collect any logs.

Configure a Topic and Subscription 

For further information on this topic, see the official Google Cloud Pub/Sub documentation: https://cloud.google.com/pubsub/docs/admin

  1. In the GCP console, select the project in which you want to create a topic.

  2. Expand the main menu on the left and scroll to the Big Data section. 

  3. Click Pub/Sub, and then click Topics.

  4. On the top of the center pane, click Create Topic.

    If you already have a topic configured, you can skip these steps. Make a note of the Topic ID you want to use.

  5. In the Topic ID field, type a unique name.
    Make a note of this Topic ID.

  6. Click Create Topic.

    image-20260924-215807.png
  7. In the topics grid view, click the three-dot (...) menu to the right of the topic to which you want to add a subscription.

If you already have a subscription configured, you can skip these steps on creating a subscription. Make a note of the Subscription ID you want to use.

  1. Click Create subscription.

  2. In the Subscription ID field, type a unique name.

  3. Make a note of this Subscription ID.

  4. Configure the subscription with the default settings, and then click Create.

Alternatively, you can skip creating a subscription and instead create the subscription when you configure and start the PubSub beat.

After you configure and run the beat, a subscription is automatically created under the Topic ID you provided in the beat configuration step.

To create a subscription automatically through beats, you must have subscription.create: true # (the default option) in the pubsubbeat.yml along with the following permissions to the assigned role in GSuite admin:

    • pubsub.subscriptions.consume

    • pubsub.subscriptions.get

    • pubsub.subscriptions.create

    • pubsub.topics.attachSubscription

For more details regarding role, refer to Create a Role For a Project above.

Log Routing Architecture

This section describes how to capture, filter, and export logs from any Google Cloud service (including Vertex AI, Model Armor, and Cloud Discovery Engine) into a Pub/Sub topic.
Depending on your organizational requirements, you can choose between a Single-Project or Multi-Project architecture.

Architecture Options

Feature

Single-Project Architecture

Multi-Project Architecture

Best For

Development, Testing, and Small-Scale Apps

Enterprise, Security, and Compliance-heavy apps

Logic

Source and Sink live in the same project.

Source and Sink live in different projects.

Setup

Simple; no cross-project permissions required.

Advanced; requires cross-project Identity Access Management (IAM).

Use Case

Isolating logs for a specific application.

Centralizing logs for a whole department or organization.

Option 1: Single-Project Architecture

Use this when the Application, the Pub/Sub Topic, and the Log Sink all reside in the same project.

Step 1: Create the Pub/Sub Topic

  1. Navigate to Pub/Sub in the Google Cloud Console.

  2. Click Create Topic.

  3. Enter a unique Topic ID (e.g., app-logs-internal).

  4. Click Create.

Step 2: Create the Log Sink

  1. Navigate to Logging > Log Router.

  2. Click Create Sink.

  3. Sink Name: Enter a unique name (e.g., app-to-pubsub-sink).

  4. Sink Destination: Select Pub/Sub and select the Topic created in Step 1.

  5. Inclusion Filter: Add appropriate filters or leave it blank to fetch all ingested logs.

  6. (Optional.) Choose logs to filter out of sink.

  7. Click Create.

Step 3: Grant Permissions

  1. Go to the Pub/Sub page, select your Topic, and click the vertical ellipsis (⋮) at the end of the row.

  2. Click View Permissions > Add Principle.

  3. New Principals: Paste the Writer Identity email from the Log Router (find it in the "View Sink Details" of the sink you just created; it should look like this: service-XXXXXXXXXX@gcp-sa-logging.iam.gserviceaccount.com).

  4. Role: Select Pub/Sub Publisher.

  5. Click Save.

Option 2: Multi-Project Architecture

Use this when the Application is in one project, but the Pub/Sub Topic is in a dedicated "Logging" or "Security" project.

Step 1: Create the Topic in the Logging Project

  1. Navigate to the Logging Project in the Google Cloud Console.

  2. Navigate to Pub/Sub and create a new Topic.

  3. Note the Topic ID.

Step 2: Create the Sink in the Source Project

  1. Navigate to the Source Project (where the Google Cloud Services lives).

  2. Navigate to Logging > Log Router.

  3. Click Create Sink.

  4. Sink Name: Enter a unique name.

  5. Sink Destination: Select Pub/Sub. Select the Topic created in the Logging Project.

  6. Inclusion Filter: Add appropriate filters or leave it blank to fetch all ingested logs

  7. (Optional) Choose logs to filter out of sink

  8. Click Create.

Step 3: Grant Cross-Project Permissions

Because the data is moving between two different projects, you must authorize the Source Project to write to the Logging Project:

  1. Go to the Logging Project and select the Topic.

  2. Click Permissions > Grant Access.

  3. New Principals: Paste the Writer Identity email from the Sink created in the Source Project (Should look like service-XXXXXXXXXX@gcp-sa-logging.iam.gserviceaccount.com).

  4. Role: Select Pub/Sub Publisher.

  5. Click Save.

Export Logs with the Log Viewer

  1. In the GCP console, from the left-side menu, scroll to the Operations section.

  2. Click Logging, and then click Logs Router.

  3. In the center pane, select an existing GCP project.
    The following screenshot shows an example of the Logs Router page, where several log sinks have already been configured:

    image-20260924-220214.png

If you have not yet configured any log sinks, the message "No log sinks are configured" appears.

Logs Router User Interface

The Logs Router interface contains a table summary of exports. Each table row contains information corresponding to some of the sink properties described in Logs Exports:

  • Sink Name. The sink's identifier in the current project.

  • Destination. The location where the exported log entries are written.

  • Writer Identity. The service account that logging uses to write log entries to the destination. This service account must have permission to write to the export destination.

  • Creation Time. The timestamp of the sink when it was created.

Each row has a menu on the right with the following options:

  • Edit Sink. Opens an Edit Sink pane where you can change the sink's parameters.

  • Delete Sink. Allows you to delete the sink and stop the logs export.

  • View Filter. Displays the sink's query. Click Edit to change the sink's properties or query.

The search-query box above the table allows you to query your sinks by text search, or by Sink Name, Destination, or Writer Identity. For example, the following shows a search on Destination: bigquery with options to concatenate other sink properties using the argument OR (AND is the default):

image-20260924-220338.png

Create a Log Sink at the Organization Level and the Project Level 

Instead of creating a log sink on each and every service, you can create a log sink at the organization and project level. This enables you to automatically redirect logs from all resources in that project to a desired destination.

For more information, see https://cloud.google.com/logging/docs/export/aggregated_sinks .

Configure Gemini Enterprise Model Armor Logs via PubSub

Model Armor logs will be collected under the Syslog - Open Collector - GCP PubSub Gemini Enterprise - Model Armor log source.

Complete this section before configuring Model Armor logging. Creating the Gemini Enterprise app requires the Model Armor template resource name, so the two steps are linked.

Prerequisites

  • IAM role roles/modelarmor.admin assigned to your account on the GCP project.

  • Model Armor API enabled:

    image-20260910-075832.png

    OR

    gcloud services enable modelarmor.googleapis.com --project=YOUR_PROJECT_ID
    

Step 1: Create a Model Armor Template

This step creates the template and retrieves the resource name needed to link it to your Gemini Enterprise app. Detailed logging configuration for this template is covered in the Configure Model Armor Log Ingestion section below.

  1. In the GCP Console, navigate to Security → Model Armor.

  2. Click Create template.

  3. Specify a Template ID and select a Region.
    Make a note of the region; your Gemini Enterprise app must be created in the same region.

  4. Choose Stable for Filter Versions

  5. In the Detections section, enable Prompt injection and jailbreak detection, Malicious URL Detection, and Sensitive data protection based on your requirements.

  6. Under Responsible AI, configure content filters based on your requirements.

  7. In Configure logging, select Prompts and responses.

  8. Click Create.

  9. After creation, open the template details page. In the Resource name field, click the copy icon to copy the full resource path.
    Save this value; you will need it in the next step.

image-20260924-220615.png

Step 2: Create the Gemini Enterprise App

  1. In the GCP Console, navigate to Gemini Enterprise (Agent Builder / Vertex AI Agent Platform).

  2. Click Create app.

  3. Enter an App name and ensure the selected Location matches the region you used for the Model Armor template.

  4. Click Create.

  5. Once the app is created, open Configurations → Assistant tab.

  6. Enable the option Enable Model Armor.

  7. In the Gemini Model Armor template field, paste the resource name path you copied in Step 1.

  8. Complete any remaining required configurations.

  9. Click Save and publish.

image-20260924-220706.png


Step 3: Record the App ID

  1. Navigate to the Apps page in Gemini Enterprise / Agent Builder.

  2. Locate your newly created app in the list.

  3. Copy the value in the ID column.
    Make a note of this App ID; you will need it when configuring the PubSub beat subscription.

Step 4: Enable Data Write Audit Logs for Cloud Discovery Engine

By default, only Admin Activity audit logs are enabled. Gemini Enterprise app interactions are captured under the Cloud Discovery Engine API and require Data Write logging to be turned on.

  1. In the GCP Console, navigate to IAM & Admin → Audit Logs.

  2. Search for Cloud Discovery Engine API in the service list.

  3. Enable the Data write audit log type.

  4. Click Save.

image-20260924-220755.png

Step 5: Verify Model Armor Logs in Cloud Logging

In Cloud Logging → Logs Explorer, confirm events are flowing:

resource.labels.template_id="Endpoints-ModelArmor-Template"

Configure Gemini Enterprise Agent Space (Vertex AI Agent) Logs via Pubsub

Agent Space logs will be collected under the existing Syslog - Open Collector - GCP PubSub Audit log source.

Step 1: Enable APIs on Agent Platform

In the GCP Console, go to Agent Platform and click on Enable APIs:

image-20260924-220855.png

Step 2: Enable Data Access Audit Logs (Crucial)

By default, only Admin Activity audit logs are enabled. To also capture DATA_READ and DATA_WRITE events for Vertex AI:

  1. In the GCP Console, navigate to IAM & Admin → Audit Logs.

  2. Find Vertex AI API in the service list.

  3. Enable the Data Read and Data Write checkboxes.

  4. Click Save.

Step 3: Verify Agent Space Logs in Cloud Logging

In Cloud Logging → Logs Explorer, confirm events are flowing:

protoPayload.serviceName="aiplatform.googleapis.com"

Configure a Combined Log Router Sink for Model Armor and Agent Space

Create a new, dedicated PubSub topic and subscription for this sink rather than reusing an existing one. Adding Model Armor and Agent Space logs, especially the broad logName:”cloudaudit.googleapis.com” clause, to an existing topic will inflate its message volume, mix incompatible log shapes, and may cause partial ingestion if other Beat instances share the same subscription.

Next Steps

Follow the topic and subscription creation steps in Configure a Topic and Subscription above, then create a new Log Router sink pointing to that topic using the inclusion filter below. Follow the sink creation steps in Configure and Export Logs for Multiple Projects in One Topic as a reference.

Combined Inclusion Filter

Paste this filter string into the Inclusion Filter field when creating or editing your Log Router sink:

(
  resource.type="audited_resource"
  AND protoPayload.serviceName="aiplatform.googleapis.com"
  AND protoPayload.resourceName=~"<yourappname>"
)
OR
(
  resource.type="audited_resource"
  AND resource.labels.service="discoveryengine.googleapis.com"
  AND resource.labels.method="google.cloud.discoveryengine.v1main.AssistantService.StreamAssist"
  AND protoPayload.resourceName=~"<yourappname>"
)
OR
(
  resource.type="modelarmor.googleapis.com/SanitizeOperation"
  AND jsonPayload.operationType="SANITIZE_USER_PROMPT"
  AND labels."modelarmor.googleapis.com/client_correlation_id"=~"<yourappname>"
)

Optional. Independent Log Streams (Recommended for High-Volume/Security Teams)

For large-scale deployments, we recommend routing Model Armor and Agent Space logs to separate Pub/Sub topics. This ensures that security guardrail events (Model Armor) do not mix with conversation and reasoning data (Agent Space), allowing for cleaner monitoring and distinct alerting rules.

Option 1: Security & Guardrail Stream (Model Armor)

Use this filter for monitoring PII leaks, prompt injections, and safety violations.

(resource.type="audited_resource" 
 AND (resource.labels.service="discoveryengine.googleapis.com" 
      OR resource.type="modelarmor.googleapis.com/SanitizeOperation")
 AND protoPayload.resourceName=~"<yourappname>")
OR
(resource.type="modelarmor.googleapis.com/SanitizeOperation"
 AND jsonPayload.operationType="SANITIZE_USER_PROMPT"
 AND labels."modelarmor.googleapis.com/client_correlation_id"=~"<yourappname>")

Option 2: Agent Reasoning & Interaction Stream (Agent Space)

Use this for monitoring how the agent is responding, which tools it is calling, and its reasoning steps.

When monitoring the Agent Space (Vertex AI), you will see two primary types of interactions. Depending on your needs, you may want to filter for one or both.

GenerateContent (The Conversation)

This is the actual "Intelligence" of the agent. It captures the prompt sent by the user and the response generated by the Gemini model.

Use this filter to audit what the AI is saying, to debug why an agent is giving a wrong answer, or to provide "History" to your users.

resource.type="audited_resource"
AND protoPayload.serviceName="aiplatform.googleapis.com"
AND protoPayload.methodName=~"GenerateContent"
AND protoPayload.resourceName=~"<yourappname>"
CountTokens (The Pre-flight Check)

Before the AI generates a response, the system calculates the "Token Count" to ensure the request fits within the model's limits.

Use this filter for Cost Monitoring and Input Validation. If a user sends a prompt that is too long, this log will show you how many tokens were attempted.

resource.type="audited_resource"
AND protoPayload.serviceName="aiplatform.googleapis.com"
AND protoPayload.methodName=~"CountTokens"
AND protoPayload.resourceName=~"<yourappname>"

For data isolation and privacy, the protoPayload.resourceName=~”<yourappname>” filter is mandatory. Google Cloud is a multi-tenant environment; omitting this filter may cause your PubSub topic to ingest logs from other customers' applications. Always include your unique App ID to prevent data leakage.

When using the resourceName filter to isolate logs, the resource identity depends on which service you query. Do not use the same ID for both services.

Filtering Agent Space logs by "App ID" hides the log because Agent Space logs are associated with the model, not the app container.

Service

What resourceName represents

Example value

Model Armor

The application ID

The App ID assigned to the Gemini app (you were asked to keep it in earlier steps)

Agent Space

The model resource

projects/.../locations/.../publishers/google/models/gemini-1.5-flash

Log Volume and “Noisy” Data Gemini interactions (specifically CountTokens and GenerateContent) generate a high volume of logs. If you combine these with other high-traffic application logs in the same PubSub topic, you may hit Publishing Quotas or cause “Log Pollution”, making it difficult to isolate specific application errors. We recommend a dedicated topic for AI-related logs.

Audit logs will only appear if Data Access Audit Logs are enabled. Ensure you have followed the instructions in the Create a Gemini Enterprise App and Enable Data Access Audit Logs sections to ensure DATA_READ and DATA_WRITE are active for both the Vertex AI and Cloud Discovery Engine APIs.