Pub/Sub Source
Onboarding Google Cloud Pub/Sub as a Data Transport log source in the Panther Console
Last updated
Onboarding Google Cloud Pub/Sub as a Data Transport log source in the Panther Console
Last updated
With Google Cloud Pub/Sub as a log source, Panther can pull log data directly from Pub/Sub topics.
Panther pulls from a dedicated subscription and authenticates by way of a Service Account.
In the left-hand navigation bar of your Panther Console, click Configure > Log Sources.
In the upper-right corner, click Create New.
Click the Custom Log Formats tile.
On the Google Cloud Pub/Sub tile, click Start.
On the "Configure your source" page, fill in the fields:
Name: Enter a descriptive name for the log source.
Log Types: Select the Log Types Panther should use to parse your logs.
Note: At least one Log Type must be selected from the dropdown menu.
Click Setup.
On the "Infrastructure & Credentials" page, follow the steps to create the required infrastructure components. You can do it with a Terraform template, or if you do not want to use Terraform, you can follow our alternative documentation to complete the infrastructure components process manually.
Create the required infrastructure in your GCP cloud.
Download the Terraform Template.
Fill out the fields in the panther.tfvars
file with your configuration:
project_id: The ID of your GCP project.
topic_name: Topic name to be created. Data will need to be published here.
subscription_id: Name for the subscription Panther will use to consume from the topic.
gcp_region: Region of the GCP Infrastructure.
panther_service_account_id: The ID of the service account that Panther will use.
panther_service_account_display_name: The display name of the service account that Panther will use.
Initialize the directory with terraform init
Run terraform apply -var-file="production.tfvars"
to create the resources
Note: If the topic you want to pull from already exists in your infrastructure, you can remove the relevant parts from the terraform template.
Generate a JSON keyfile for the just-created service account. gcloud iam service-accounts keys create keyfile.json [email protected]
You can find the key file in the output of the Terraform run.
Provide the configuration details and the JSON Keyfile to Panther.
Drag and drop or upload the JSON key into the correct field in Step 2.
Paste in your Pub/Sub Subscription ID, found in the Subscriptions section of your Google Cloud account.
Click Setup. You will be directed to a success screen:
You can optionally enable one or more Detection Packs.
The Trigger an alert when no events are processed setting defaults to YES. We recommend leaving this enabled, as you will be alerted if data stops flowing from the log source after a certain period of time. The timeframe is configurable, with a default of 24 hours.
If you choose to create the infrastructure components manually rather than using a Terraform template during the Pub/Sub setup above, follow the instructions below.
Log in to your Google Cloud console.
Create a topic for the data.
You can create a topic using the gcloud
CLI tool with the following command format:
gcloud pubsub topics create $TOPIC_ID
Create a subscription to be used with the topic you created. Note: This subscription should not be used by any service other than Panther.
You can create a subscription using the gcloud
CLI tool with the following command format:
gcloud pubsub subscriptions create $SUBSCRIPTION_ID --topic $TOPIC_ID --topic-project $PROJECT_ID
Create a new Google Cloud service account. Make sure to take note of the account email address, as Panther will use this to access the infrastructure created for this GCS integration.
To create the account using the gcloud
CLI tool, use the following command format:
gcloud iam service-accounts create $PROJECT_ID --description="$DESCRIPTION" --display-name="$DISPLAY_NAME"
Assign the required IAM roles to the account.
The following permissions are required for the project where the Pub/Sub subscription and topic lives:
Permissions required
Role
Scope
pubsub.subscriptions.consume
roles/pubsub.subscriber
subscription-name
pubsub.subscriptions.get
roles/pubsub.viewer
subscription-name
monitoring.timeSeries.list
roles/monitoring.viewer
project
Alternatively, you can create the permissions using the gcloud
CLI tool:
gcloud projects add-iam-policy-binding $PROJECT_ID --member="serviceAccount:$SERVICE_ACCOUNT_EMAIL" --role="roles/pubsub.subscriber"
gcloud projects add-iam-policy-binding $PROJECT_ID --member="serviceAccount:$SERVICE_ACCOUNT_EMAIL" --role="roles/pubsub.viewer"
gcloud projects add-iam-policy-binding $PROJECT_ID --member="serviceAccount:$SERVICE_ACCOUNT_EMAIL" --role="roles/monitoring.viewer"
Generate a JSON key file for the service account, which will be used in Panther to authenticate to the GCP infrastructure.
To create a JSON key file using the gcloud CLI tool, use the following command format:
gcloud iam service-accounts keys create $KEYFILE_PATH --iam-account=$SERVICE_ACCOUNT_EMAIL
Alternatively, you can Download the key file from the Cloud Console:
Open the GCP terminal ("Activate Cloud Shell")
Click the 3 dots icon menu in the top right, then click Download.
Click the folder icon for Browse.
Navigate to the key file and select it, then click Download.
After Pub/Sub log sources are fully configured, you can search your data in Data Explorer. For more information and for example queries, please see the documentation on Data Explorer.
Note: You can set conditions or IAM policies on permissions for specific resources. This can be done either in the IAM page of the service account (as seen in the example screenshot below) or in the specific resource's page. The "monitoring" permission is not mandatory, but is recommended for improved autoscaling.