Configure machine type recommendations Stay organized with collections Save and categorize content based on your preferences.
Preview
This product or feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA products and features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.
This page describes how to view and modify the configuration of your machinetype recommendations. You can modify which machine types are recommended,so the generated recommendations only include your preferred machine series.You can also change the metrics used to generate memory recommendations toimprove the accuracy of the recommendations. The changes to the configurationare applied at the project level.
For more information about machine type recommendations, seeApply machine type recommendations for VMs.
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:
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.
Required roles
To get the permissions that you need to modify machine type recommendations, ask your administrator to grant you theCompute Recommender Admin (roles/recommender.computeAdmin) 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 modify machine type recommendations. To see the exact permissions that are required, expand theRequired permissions section:
Required permissions
The following permissions are required to modify machine type recommendations:
- View the machine type recommendation configuration:
recommender.computeInstanceMachineTypeRecommenderConfig.geton the project - Modify the machine type recommendation configuration:
recommender.computeInstanceMachineTypeRecommenderConfig.updateon the project
You might also be able to get these permissions withcustom roles or otherpredefined roles.
Configure your recommendations
To configure your machine type recommendations, perform the following steps:
- Get the current configuration to obtainthe JSON file of the configuration.
- Edit the configuration file in JSON format.
- Upload the new configuration fileto apply the changes.
Get the current configuration
You can obtain the current configuration for machine type recommendations foryour project by using the Google Cloud CLI.
gcloud
To get the current configuration parameters, use thegcloud beta recommender recommender-config describe commandand usegoogle.compute.instance.MachineTypeRecommender as theRecommender ID:
gcloud beta recommender recommender-config describe google.compute.instance.MachineTypeRecommender \ --project=PROJECT_ID \ --location=ZONE
Replace the following:
PROJECT_ID: the ID of your project.ZONE: the zone for which you want to obtain thecurrent configuration.
The command returns the recommender configuration, including the modifiablesubfieldspreferred_machine_types andmemory_metrics.
{ "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.MachineTypeRecommender/config", "recommenderGenerationConfig": {"params": { "preferred_machine_types": "STANDARD_AND_CUSTOM", "memory_metrics": "MONITORING_AGENT_ONLY" } }, "etag": "\"2f3c9b65cda6a4ba\"", "updateTime": "2024-08-20T04:41:15.330351Z"}If you want to save the configuration to a local file, so you can edit itand upload it later, run the following command:
gcloud beta recommender recommender-config describe \ google.compute.instance.MachineTypeRecommender \ --project=PROJECT_ID \ --location=ZONE >LOCAL_FILE_PATH_AND_NAME
Edit the recommendation configuration
The configuration lets you customize the following parameters:
preferred_machine_types: The machine types recommendations that you receive.memory_metrics: How memory metrics are used to generate recommendations.
Options for machine types recommendations
You can specify which machine types recommendations you get by changingthepreferred_machine_types setting to one of the following values:
DEFAULT: The default value isSTANDARD_AND_CUSTOM.STANDARD_AND_CUSTOM: Recommends the best match from standard and custommachine types.STANDARD_ONLY: Recommends the best match from standard machine types only.
Options for memory recommendations
For the memory metrics used to generate the recommendations, you can setthe following values:
MEMORY_METRICS_DEFAULT: Use the default metrics to generate recommendations.MEMORY_METRICS_ALL: Use all the available metrics to generaterecommendations.MONITORING_AGENT_ONLY: Use only metrics collected by theCloud Monitoring Ops Agent.- If you don't use the Ops Agent, and prefer not to receive memoryrecommendations, use the
MEMORY_AGENT_ONLYvalue to disablethe recommendations.
To get more accurate recommendations about memory usage, use theOps Agent.
Update the configuration for a project
To update the configuration of your machine type recommendations, modify theconfiguration values and upload the new configuration for your project.You can change the preferred machine types, the memory metrics used forrecommendations, or both values in the same request.
After you upload the new configuration, it takes approximately 48 hours for itto take effect. Until that time, any generated recommendations use the previousconfiguration.
gcloud
To update the configuration parameters, use thegcloud beta recommender recommender-config update commandand usegoogle.compute.instance.MachineTypeRecommender as theRecommender ID:
gcloud beta recommender recommender-config update google.compute.instance.MachineTypeRecommender\ --project=PROJECT_ID \ --location=ZONE \ --config-file=LOCAL_FILE_PATH_AND_NAME \ --etag=ETAG
Replace the following:
PROJECT_ID: the ID of your project.ZONE: the zone for which you want to obtain thecurrent configuration.LOCAL_FILE_PATH_AND_NAME: the path to the JSON filewith the current configuration.ETAG: the etag value of the current configuration.You can find this value in the output of theprevious command.
In your configuration file, specify only therecommenderGenerationConfigobject with the updated configuration parameters. If you saved theconfiguration to a local file, make sure you copy theetag value, thenremove all the fields except therecommenderGenerationConfig value.
For example, to get recommendations with standard machine types only,use the following configuration file:
{ "params": { "preferred_machine_types": "STANDARD_ONLY" }}If the command is successful, it returns a response body similar to thefollowing, showing the new configuration with the parameters you justmodified.
{ "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.MachineTypeRecommender/config", "recommenderGenerationConfig": { "params": { "preferred_machine_types": "STANDARD_ONLY" } }, "etag": "\"1245f9435cd01ea8\"", "updateTime": "2024-08-20T05:00:05Z"}etag value changes from the previous configuration. Youmust use the new value if you update the configuration again.What's next
- Learn how toApply machine type recommendations to instances.
- Learn how toApply machine type recommendations to managed instance groups.
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.