Manage the PMU in VMs Stay organized with collections Save and categorize content based on your preferences.
This document explains how to change the performance monitoring unit (PMU) typeenabled in a virtual machine (VM) instance, or disable it. To learn more aboutthe PMU, seePMU overview.
After you've enabled the PMU in a VM and run performance-monitoring software onthe VM, you can do the following:
Change the PMU type enabled in the VM. This change is useful when youwant to track different types of low-level CPU events.
Disable the PMU in the VM. This action is useful when you no longer needto access the performance counters in the PMU.
Before you begin
- If you haven't already, set upauthentication. 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:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.- 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. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.For more information, seeAuthenticate 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 VM or disable it, ask your administrator to grant you theCompute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on your project. For more information about granting roles, seeManage access to projects, folders, and organizations.
This predefined role contains the permissions required to change the PMU type enabled in a VM or disable it. To see the exact permissions that are required, expand theRequired permissions section:
Required permissions
The following permissions are required to change the PMU type enabled in a VM or disable it:
- To update a VM:
compute.instances.updateon the VM
You might also be able to get these permissions withcustom roles or otherpredefined roles.
Change the PMU type in a VM
Before changing the PMU type enabled in an existing C4A or C4 VM,view the details of the VM using theGoogle Cloud CLI or REST API. In the output from the command or APIrequest, verify the following:
To verify the PMU type enabled in the VM, check the value of the
performanceMonitoringUnitfield. If the field is missing, then the PMU isdisabled.If you want to enable the Enhanced PMU type, then make sure that the VM isusing a C4 machine type with 96 or 192 vCPUs by checking the value of the
machineTypefield. If not, thenchange the machine type of the VM.
You don't have to stop the VM to change the PMU type enabled in it. However, tomake the change effective, you must restart the VM as described in this section.
To change the PMU type enabled in an existing VM, select one of the followingoptions:
gcloud
Create an empty YAML file.
To export the properties of a VM into the YAML file that you've justcreated, use the
gcloud compute instances exportcommand:gcloud compute instances exportVM_NAME \ --destination=YAML_FILE \ --zone=ZONEReplace the following:
VM_NAME: the name of the VM.YAML_FILE: the path to the YAML file that youcreated in the previous step.ZONE: the zone where the VM is located.
In the YAML configuration file, locate the
performanceMonitoringUnitfield and change its value to specify a different PMU type:advancedMachineFeatures: performanceMonitoringUnit:PMU_TYPEReplace
PMU_TYPEwith one of the following values:Architectural PMU type:
ARCHITECTURALStandard PMU type:
STANDARDEnhanced PMU type:
ENHANCED
"ERROR: (gcloud.compute.instances.update-from-file) Cannot parse YAML: [Expected type, add quotes (for field value, found True (type )]" ' ') around any label values ofyesornoin the exported instance configuration file. This indicates the values are strings, not Boolean values.To update the VM and restart it, use the
gcloud compute instances update-from-filecommandwith the--most-disruptive-allowed-actionflag set toRESTART:gcloud compute instances update-from-fileVM_NAME \ --most-disruptive-allowed-action=RESTART \ --source=YAML_FILE \ --zone=ZONEReplace the following:
VM_NAME: the name of the VM.YAML_FILE: the path to the YAML file with theconfiguration data that you modified in the previous step.ZONE: the zone where the VM is located.
REST
Create an empty JSON file.
To view the properties of an existing VM, make a
GETrequest to theinstances.getmethod:GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAMEReplace the following:
PROJECT_ID: the ID of the project where the VM islocated.ZONE: the zone where the VM is located.VM_NAME: the name of an existing VM.
In the empty JSON file that you created in the previous steps, do thefollowing:
Enter the VM properties from the
GETrequest output.Locate the
performanceMonitoringUnitfield, and then change itsvalue to specify a different PMU type:"advancedMachineFeatures": { "performanceMonitoringUnit": "PMU_TYPE"}Replace
PMU_TYPEwith one of the followingvalues:Architectural PMU type:
ARCHITECTURALStandard PMU type:
STANDARDEnhanced PMU type:
ENHANCED
To update the VM and restart it, make a
PUTrequest to theinstances.updatemethod.In the request, do the following:In the request URL, include the
mostDisruptiveAllowedActionqueryparameter set toRESTART.For the request body, use the VM properties from the JSON file thatyou created and updated in the previous steps.
The request is similar to the following:
PUT https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME?mostDisruptiveAllowedAction=RESTART{ "advancedMachineFeatures": { "performanceMonitoringUnit": "PMU_TYPE" }, ...}
For more information about updating the properties of a VM, seeUpdate VM properties.
Disable the PMU in a VM
You don't have to stop the VM to disable the PMU. However, to make the changeeffective, you must restart the VM as described in this section.
To disable the PMU in an existing VM, select one of the following options:
gcloud
Create an empty YAML file.
To export the properties of a VM into the YAML file that you've justcreated, use the
gcloud compute instances exportcommand:gcloud compute instances exportVM_NAME \ --destination=YAML_FILE \ --zone=ZONEReplace the following:
VM_NAME: the name of the VM.YAML_FILE: the path to the YAML file that youcreated in the previous step.ZONE: the zone where the VM is located.
In the YAML configuration file, locate the
performanceMonitoringUnitfield and set its value toNONE: Tip: To avoid getting an error such asadvancedMachineFeatures: performanceMonitoringUnit: NONE"ERROR: (gcloud.compute.instances.update-from-file) Cannot parse YAML: [Expected type, add quotes (for field value, found True (type )]" ' ') around any label values ofyesornoin the exported instance configuration file. This indicates the values are strings, not Boolean values.To update the VM and restart it, use the
gcloud compute instances update-from-filecommandwith the--most-disruptive-allowed-actionflag set toRESTART:gcloud compute instances update-from-fileVM_NAME \ --most-disruptive-allowed-action=RESTART \ --source=YAML_FILE \ --zone=ZONEReplace the following:
VM_NAME: the name of the VM.YAML_FILE: the path to the YAML file with theconfiguration data that you modified in the previous step.ZONE: the zone where the VM is located.
REST
Create an empty JSON file.
To view the properties of an existing VM, make a
GETrequest to theinstances.getmethod:GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAMEReplace the following:
PROJECT_ID: the ID of the project where the VM islocated.ZONE: the zone where the VM is located.VM_NAME: the name of an existing VM.
In the empty JSON file that you created in the previous steps, do thefollowing:
Enter the VM properties from the
GETrequest output.Locate the
performanceMonitoringUnitfield, and then change itsvalue toNONE:"advancedMachineFeatures": { "performanceMonitoringUnit": "NONE"}
To update the VM and restart it, make a
PUTrequest to theinstances.updatemethod.In the request, do the following:In the request URL, include the
mostDisruptiveAllowedActionqueryparameter set toRESTART.For the request body, use the VM properties from the JSON file thatyou created and updated in the previous steps.
The request is similar to the following:
PUT https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME?mostDisruptiveAllowedAction=RESTART{ "advancedMachineFeatures": { "performanceMonitoringUnit": "NONE" }, ...}
For more information about updating the properties of a VM, seeUpdate VM properties.
What's next
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.