How to Monitor Memory usage of VM instances in Google Cloud

To monitor the memory usage of VM instances in Google Cloud, you must enable the Stackdriver Monitoring agent on your VMs. The agent collects memory usage and other system metrics, which can be viewed in the Google Cloud Console. Here’s how to set up and use the Stackdriver Monitoring agent:

Step 1: Install the Monitoring agent on your VM instance

SSH into your VM instance and run the following commands based on your operating system:


curl -sSO
sudo bash
sudo apt-get update
sudo apt-get install stackdriver-agent


curl -sSO
sudo bash
sudo yum clean all
sudo yum install stackdriver-agent

Step 2: Start the Monitoring agent

Run the following command to start the Monitoring agent on your VM instance:

sudo service stackdriver-agent start

Step 3: Verify that the agent is running

You can use the following command to check the status of the agent:

sudo service stackdriver-agent status

Step 4: View memory usage metrics in the Google Cloud Console

  1. Go to the Google Cloud Console:
  2. Select your project from the project drop-down menu at the top of the page.
  3. Navigate to the “Monitoring” page by clicking on the navigation menu (three horizontal lines) at the top left corner, then select “Monitoring”.
  4. Click “Metrics Explorer” on the left-hand menu in the Monitoring Dashboard.
  5. In the “Find resource type and metric” field, type “instance” and select “gce_instance” as the resource type.
  6. In the same field, type “memory” and select the “memory/usage” metric. You can also choose metrics like “memory/bytes_used” or “memory/percent_used”.
  7. Adjust the filters and groupings as needed to display the memory usage for your VM instances.

You can also create custom dashboards, set up alerts, or use the Monitoring API to analyze the collected metrics further.

That’s it.

Leave a Comment