After you've enabled the PMU in a compute instance and run performance-monitoring software on the compute instance, you can do the following:
Change the PMU type enabled in the compute instance. This change is useful when you want to track different types of low-level CPU events.
Disable the PMU in the compute instance. This action is useful when you no longer need to access the performance counters in the PMU.
This document explains how to change the performance monitoring unit (PMU) type that is enabled in a Compute Engine instance, or disable it. To learn more about the PMU, see PMU overview.
Before you begin
-
If you haven't already, set up authentication.
Authentication verifies your identity for access to Google Cloud services and APIs. To run
code or samples from a local development environment, you can authenticate to
Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
gcloud
-
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud initIf you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
Required roles
To get the permissions that
you need to change the PMU type enabled in a compute instance or disable it,
ask your administrator to grant you the
Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on your project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to change the PMU type enabled in a compute instance or disable it. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to change the PMU type enabled in a compute instance or disable it:
-
To update a compute instance:
compute.instances.updateon the compute instance
You might also be able to get these permissions with custom roles or other predefined roles.
Change the PMU type in a compute instance
Before you change the PMU type for an existing A4X, C4A, C4, or M4 instance, view the details of the compute instance by using the Google Cloud CLI or REST API. In the output from the command or API request, verify the following:
To verify that the PMU type is enabled in the compute instance, check the value of the
performanceMonitoringUnitfield. If the field is missing, then the PMU is disabled.If you want to enable the enhanced PMU type, then you must verify that the compute instance uses one of the following machine types by checking the value of the
machineTypefield:A C4 machine type with 144 or 288 vCPUs
One of the following M4 machine types:
m4-megamem-112m4-megamem-224m4-ultramem-56m4-ultramem-112m4-ultramem-224
If your compute instance uses a different machine type, then you must change the machine type that the compute instance uses before you can monitor enhanced PMU types.
You don't have to stop the compute instance to change the PMU type. However, to make the change effective, you must restart the compute instance as described in this section.
To change the PMU type enabled in an existing compute instance, select one of the following options: