GCP Logs Collection using Pub/Sub :: Kloudfuse Docs
GCP Logs Collection using Pub/Sub
Kloudfuse integrates with the GCP cloud service to collect logs through the Pub/Sub console.
Complete these tasks to successfully collect logs:
- Create a GCP Subscription
- Configure Service Account for Pub/Sub Access
- Configure Kloudfuse to Consume Logs from the GCP Subscription
Create a GCP Subscription
- Use an existing project, or create a new project in Cloud Pub-Sub console
Create New Project
- In the Cloud Pub-Sub console, create a new topic.
Create Topic
Specify Topic
In the Pub/Sub Topics overview page, select Subscriptions in the left-hand navigation.
Click Create Subscription.
Create Subscription
- Create a subscription with ID
kloudfuse-gcp-subscriptionand select the topic you previously created,MyLogsCollector.
Click Create.
Specify Subscription
- Confirm that the new subscription exists.
New Subscription created successfully
- In the Logs Explorer page of the console, under More actions, choose Create sink from the drop-down.
Create Sink
- In Sink details, specify the Name and optional Description of the sink.
Click Next.
Sink details
- In Sink destination, in Select sink service, choose Cloud Pub/Sub. In Select a Cloud Pub/Sub Topic, select the topic that you created in a previous step.
Click Next.
Sink destination
- In the Choose logs to include in sink, create optional inclusion filters for the logs.
Click Preview logs to see the available logs.
Click Next.
Preview Logs
- In the Choose logs to filter out of sink, create optional exclusion filters for the logs.
Click Next.
- Click Create sink.
Create sink
- The confirmation message appears.
Confirmation
Configure Service Account for Pub/Sub Access
To allow Kloudfuse to consume logs from the GCP Pub/Sub subscription, you must configure a service account with the appropriate permissions and generate credentials.
Assign Pub/Sub Subscriber Role
- In the Google Cloud console, navigate to Menu > IAM & Admin > Service Accounts.
- Select your service account, or create a new one.
- Navigate to Menu > IAM & Admin > IAM.
- Click Grant Access to add a new principal, or edit an existing principal.
- In the New principals field, enter the service account email.
- In the Assign roles section, select Pub/Sub Subscriber (
roles/pubsub.subscriber).
This role allows the service account to consume messages from the Pub/Sub subscription.
- Click Save.
Create and Encode the Service Account Key
- In the Google Cloud console, navigate to Menu > IAM & Admin > Service Accounts.
- Select the service account you configured with the Pub/Sub Subscriber role.
- Select Keys > Add key > Create new key.
- Select JSON, then click Create.
The JSON key file downloads to your local machine.
- Click Close.
- Base64-encode the JSON key file:
cat <your-service-account-key>.json | base64
Copied!
- Copy the base64-encoded output. You will use this value for the
pubsubKeyfield in the Kloudfuse configuration.
Configure Kloudfuse to Consume Logs from the GCP Subscription
Add the following configuration to the custom-values.yaml file when installing Kloudfuse using Helm, and add the GCP pub/sub access key in the pubsubKey field.
global:
...
enrichmentEnabled:
- gcp
gcpConfig:
enabled: true
subscriptionId: "kloudfuse-gcp-subscription" (1)
pubsubKey: "<BASE64_ENCODED_SERVICE_ACCOUNT_KEY>" (2)
...
yamlCopied!
| 1 | Add the subscription information. |
| 2 | Paste the base64-encoded service account JSON key from the previous section. |