GCP
This page describes steps to follow to setup real-time visualization of GCP Assets (vpc, subnet and virtual server).
Last updated
This page describes steps to follow to setup real-time visualization of GCP Assets (vpc, subnet and virtual server).
Last updated
Real-time visualization is only supported for vpc, subnet and virtual server resource types as of today (Feb 08, 2024).
Created initial version descripting steps for setting up real-time visualization of GCP assets (vpc, subnet and vm).
Updated instructions.
Go to console -> topics (use search bar to jump to this).
Add a topic with mc-mgmt-events id (see below screenshot for other details)
Click on newly created topic in the list of topics and then click on TRIGGER CLOUD FUNCTION link.
Create a function with details as follows -
Basics
Environment - 2nd gen
Function name - process-mc-events
Region - Choose a region of your choice
Trigger - Leave it unchanged ( make sure it is having topic created in the previous step selected under Cloud Pub/Sub topic field.
Runtime, build, connections and security settings (Choose other settings as per your convenience)
Runtime
Timeout - 30 seconds
Runtime environment variables -
TEAM_ID - d65e32d2-e18f-49a7-8cbf-e19205772ea0
CLOUD_ACCOUNT_ID - You can get this from MechCloud console -> Infrastructure -> Cloud Accounts page.
ACCESS_TOKEN - Once you are logged into MechCloud, simply open a new tab, and enter https://portal-preview.mechcloud.io/oauth2/auth1 url in the address bar. It will print your access/jwt token.
Connections
Ingress Settings - Allow internal traffic only
Source code
Runtime - Python 3.12
Entry point - process_event
Source code - Inline editor
Make sure requirements.txt has following additional modules -
requests==2.31.0
Add following code under main.py file-
To visualize GCP resource in real-time, we will need to create one log routing sink per resource type (e.g. vpc). You can add a log routing sink by going to console -> logging (use search bar to jump to this) -> Log router and click on Create sink link to add a sink. Make sure you have following log routing sinks created -
mc-vpc-mgmt-events
Service - Cloud Pub/Sub topic Topic - projects/<project_name>/topics/mc-mgmt-events
resource.type="gce_network" protoPayload.methodName="beta.compute.networks.insert" OR protoPayload.methodName="v1.compute.networks.insert" OR protoPayload.methodName="beta.compute.networks.delete" OR protoPayload.methodName="v1.compute.networks.delete"
mc-subnet-mgmt-events
Service - Cloud Pub/Sub topic Topic - projects/<project_name>/topics/mc-mgmt-events
resource.type="gce_subnetwork" protoPayload.methodName="beta.compute.subnetworks.insert" OR protoPayload.methodName="v1.compute.subnetworks.insert" OR protoPayload.methodName="beta.compute.subnetworks.delete" OR protoPayload.methodName="v1.compute.subnetworks.delete"
mc-vm-mgmt-events
Service - Cloud Pub/Sub topic Topic - projects/<project_name>/topics/mc-mgmt-events
resource.type="gce_instance" protoPayload.methodName="beta.compute.subnetworks.insert" OR protoPayload.methodName="v1.compute.instances.insert" OR protoPayload.methodName="beta.compute.instances.delete" OR protoPayload.methodName="v1.compute.instances.delete" OR protoPayload.methodName="beta.compute.instances.start" OR protoPayload.methodName="v1.compute.instances.start" OR protoPayload.methodName="beta.compute.instances.stop" OR protoPayload.methodName="v1.compute.instances.stop"