Learning Cloud- Create StackDriver Monitoring tool for VM Instances in Google Cloud

Опубликовано: 25 Апрель 2026
на канале: Cyethack Solutions
71
2

In the GCP Console, on the Navigation menu (Navigation menu), click Compute Engine -- VM instances.

Select the checkbox for my-vm and click on STOP.

Click on STOP again to confirm.

Click on the VM instance's name to open its VM instance details screen.

Click on EDIT (pencil icon).

Scroll down to the bottom of the page and select Compute Engine default service account from Service account dropdown.

Select Allow full access to all Cloud APIs for Access scopes.

Click on Save.

Now, restart the VM by clicking on Start at the top of the VM instance details screen page.

Click on START again to confirm.

In the GCP Console, on the Navigation menu (Navigation menu), click Compute Engine -- VM instances.

To open a command prompt on the my-vm instance, click SSH in its row in the VM instances list.

In the ssh session on my-vm, execute this command to create a CPU load:

dd if=/dev/urandom | gzip -9 -- /dev/null &
This Linux pipeline forces the CPU to work on compressing a continuous stream of random data.

Leave the window containing your SSH session open while you proceed with the lab.

Create a Monitoring workspace
You will now setup a Monitoring workspace that's tied to your Qwiklabs GCP Project. The following steps create a new account that has a free trial of Monitoring.

In the Google Cloud Platform Console, click on Navigation menu -- Monitoring.

Wait for your workspace to be provisioned.

When the Monitoring dashboard opens, your workspace is ready.

Overview.png

Click on Settings option from the left panel and confirm that the GCP project which Qwiklabs created for you is shown under the GCP Projects section.
allocated_projects

Run the commands shown on screen in the SSH window of your VM instance to install both the Monitoring and Logging agents.

curl -sSO https://dl.google.com/cloudagents/ins...
sudo bash install-monitoring-agent.sh
curl -sSO https://dl.google.com/cloudagents/ins...
sudo bash install-logging-agent.sh
Once both of the agents have been installed on your project's VM, click Metrics Explorer under the main Cloud Monitoring menu on the far left.

In the Metric pane of Metrics Explorer, select the resource type VM instance and the metric CPU usage.

In the resulting graph, notice that CPU usage increased sharply a few minutes ago.

Terminate your workload generator. Return to your ssh session on my-vm and enter this command:

kill %1