Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Nesta página, descrevemos como visualizar e modificar a configuração das recomendações de tipo de máquina. É possível modificar os tipos de máquinas recomendados para que as recomendações geradas incluam apenas sua série de máquinas preferida.
Também é possível mudar as métricas usadas para gerar recomendações de memória e melhorar a acurácia delas. As mudanças na configuração
são aplicadas no nível do projeto.
Configure a autenticação, caso ainda não tenha feito isso.
A autenticação é
o processo de verificação da sua identidade para acesso a serviços e APIs do Google Cloud .
Para executar códigos ou amostras de um ambiente de desenvolvimento local, autentique-se no
Compute Engine selecionando uma das seguintes opções:
Instale a CLI do Google Cloud.
Após a instalação,
inicialize a Google Cloud CLI executando o seguinte comando:
Esse papel predefinido contém
as permissões necessárias para modificar recomendações de tipo de máquina. Para conferir as permissões exatas
necessárias, expanda a seção Permissões necessárias:
Permissões necessárias
As seguintes permissões são necessárias para modificar as recomendações de tipo de máquina:
Confira a configuração de recomendação de tipo de máquina:
recommender.computeInstanceMachineTypeRecommenderConfig.get
no projeto
Modifique a configuração de recomendação de tipo de máquina:
recommender.computeInstanceMachineTypeRecommenderConfig.update
no projeto
Com a configuração, é possível personalizar os seguintes parâmetros:
preferred_machine_types: as recomendações de tipo de máquina que você recebe.
memory_metrics: como as métricas de memória são usadas para gerar recomendações.
Opções para recomendações de tipo de máquina
Para especificar quais recomendações de tipo de máquina você quer receber, mude a configuração preferred_machine_types para um dos seguintes valores:
DEFAULT: o valor padrão é STANDARD_AND_CUSTOM.
STANDARD_AND_CUSTOM: recomenda a melhor correspondência entre tipos de máquinas padrão e personalizados.
STANDARD_ONLY: recomenda a melhor opção apenas entre os tipos de máquinas padrão.
Opções para recomendações de memória
Para as métricas de memória usadas para gerar as recomendações, é possível definir os seguintes valores:
MEMORY_METRICS_DEFAULT: use as métricas padrão para gerar recomendações.
MEMORY_METRICS_ALL: use todas as métricas disponíveis para gerar recomendações.
MONITORING_AGENT_ONLY: use apenas métricas coletadas pelo
agente de operações do Cloud Monitoring.
Se você não usa o Agente de operações e prefere não receber recomendações de memória, use o valor MEMORY_AGENT_ONLY para desativar as recomendações.
Para receber recomendações mais precisas sobre o uso da memória, use o agente de operações.
Atualizar a configuração de um projeto
Para atualizar a configuração das recomendações de tipo de máquina, modifique os valores de configuração e faça o upload da nova configuração do projeto.
É possível mudar os tipos de máquina preferidos, as métricas de memória usadas para recomendações ou ambos os valores na mesma solicitação.
Depois de fazer upload da nova configuração, leva aproximadamente 48 horas para que
ela entre em vigor. Até lá, todas as recomendações geradas usarão a configuração
anterior.
ZONE: a zona com a configuração atual
que você quer obter.
LOCAL_FILE_PATH_AND_NAME: o caminho para o arquivo JSON
com a configuração atual.
ETAG: o valor de etag da configuração atual.
Esse valor está na saída do
comando anterior.
No arquivo de configuração, especifique apenas o objeto recommenderGenerationConfig
com os parâmetros de configuração atualizados. Se você salvou a configuração em um arquivo local, copie o valor etag e remova todos os campos, exceto o valor recommenderGenerationConfig.
Por exemplo, para receber recomendações apenas com tipos de máquina padrão,
use o seguinte arquivo de configuração:
Se o comando for bem-sucedido, ele retornará um corpo de resposta semelhante ao
seguinte, mostrando a nova configuração com os parâmetros que você
acabou de modificar.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-19 UTC."],[[["\u003cp\u003eThis page guides users on how to customize machine type recommendations at the project level, allowing them to control which machine series are suggested and how memory metrics are used in generating these recommendations.\u003c/p\u003e\n"],["\u003cp\u003eTo modify machine type recommendations, users need the "Compute Recommender Admin" IAM role, which grants the necessary permissions to view and update the recommendation configuration.\u003c/p\u003e\n"],["\u003cp\u003eThe configuration of machine type recommendations involves three main steps: retrieving the current configuration in JSON format, editing this configuration to specify preferred machine types and memory metrics, and uploading the updated file.\u003c/p\u003e\n"],["\u003cp\u003eUsers can specify their preferences for machine type recommendations, choosing between standard and custom types, or standard types only, and can also define how memory metrics are utilized, even opting to rely solely on the Cloud Monitoring Ops Agent or disabling memory recommendations.\u003c/p\u003e\n"],["\u003cp\u003eAfter uploading a new configuration, it takes approximately 48 hours for the changes to take effect, and during this time, the system will continue to use the previous settings for generating any recommendations.\u003c/p\u003e\n"]]],[],null,["# Configure machine type recommendations\n\n*** ** * ** ***\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes how to view and modify the configuration of your machine\ntype recommendations. You can modify which machine types are recommended,\nso the generated recommendations only include your preferred machine series.\nYou can also change the metrics used to generate memory recommendations to\nimprove the accuracy of the recommendations. The changes to the configuration\nare applied at the project level.\n\nFor more information about machine type recommendations, see\n[Apply machine type recommendations for VMs](/compute/docs/instances/apply-machine-type-recommendations-for-instances).\n\nBefore you begin\n----------------\n\n- If you haven't already, set up [authentication](/compute/docs/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:\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n### Required roles\n\n\nTo get the permissions that\nyou need to modify machine type recommendations,\n\nask your administrator to grant you the\n\n\n[Compute Recommender Admin](/iam/docs/roles-permissions/recommender#recommender.computeAdmin) (`roles/recommender.computeAdmin`)\nIAM role on your project.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nThis predefined role contains\n\nthe permissions required to modify machine type recommendations. To see the exact permissions that are\nrequired, expand the **Required permissions** section:\n\n\n#### Required permissions\n\nThe following permissions are required to modify machine type recommendations:\n\n- View the machine type recommendation configuration: `recommender.computeInstanceMachineTypeRecommenderConfig.get` on the project\n- Modify the machine type recommendation configuration: `recommender.computeInstanceMachineTypeRecommenderConfig.update` on the project\n\n\nYou might also be able to get\nthese permissions\nwith [custom roles](/iam/docs/creating-custom-roles) or\nother [predefined roles](/iam/docs/roles-overview#predefined).\n\nConfigure your recommendations\n------------------------------\n\nTo configure your machine type recommendations, perform the following steps:\n\n1. [Get the current configuration](#get_current_configuration) to obtain the JSON file of the configuration.\n2. Edit the configuration file in JSON format.\n3. [Upload the new configuration file](#update_configuration) to apply the changes.\n\n### Get the current configuration\n\nYou can obtain the current configuration for machine type recommendations for\nyour project by using the Google Cloud CLI. \n\n### gcloud\n\nTo get the current configuration parameters, use the\n[`gcloud beta recommender recommender-config describe` command](/sdk/gcloud/reference/beta/recommender/recommender-config/describe)\nand use `google.compute.instance.MachineTypeRecommender` as the\nRecommender ID: \n\n```\ngcloud beta recommender recommender-config describe google.compute.instance.MachineTypeRecommender \\\n --project=PROJECT_ID \\\n --location=ZONE\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your project.\n- \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the zone for which you want to obtain the current configuration.\n\nThe command returns the recommender configuration, including the modifiable\nsubfields `preferred_machine_types` and `memory_metrics`. \n\n```\n{\n \"name\": \"projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.MachineTypeRecommender/config\",\n \"recommenderGenerationConfig\": {\n \"params\": {\n \"preferred_machine_types\": \"STANDARD_AND_CUSTOM\",\n \"memory_metrics\": \"MONITORING_AGENT_ONLY\"\n }\n },\n \"etag\": \"\\\"2f3c9b65cda6a4ba\\\"\",\n \"updateTime\": \"2024-08-20T04:41:15.330351Z\"\n}\n```\n\nIf you want to save the configuration to a local file, so you can edit it\nand upload it later, run the following command: \n\n```\ngcloud beta recommender recommender-config describe \\\n google.compute.instance.MachineTypeRecommender \\\n --project=PROJECT_ID \\\n --location=ZONE \u003e LOCAL_FILE_PATH_AND_NAME\n```\n\n### Edit the recommendation configuration\n\nThe configuration lets you customize the following parameters:\n\n- `preferred_machine_types`: The machine types recommendations that you receive.\n- `memory_metrics`: How memory metrics are used to generate recommendations.\n\n#### Options for machine types recommendations\n\nYou can specify which machine types recommendations you get by changing\nthe `preferred_machine_types` setting to one of the following values:\n\n- `DEFAULT`: The default value is `STANDARD_AND_CUSTOM`.\n- `STANDARD_AND_CUSTOM`: Recommends the best match from standard and custom machine types.\n- `STANDARD_ONLY`: Recommends the best match from standard machine types only.\n\n#### Options for memory recommendations\n\nFor the memory metrics used to generate the recommendations, you can set\nthe following values:\n\n- `MEMORY_METRICS_DEFAULT`: Use the default metrics to generate recommendations.\n- `MEMORY_METRICS_ALL`: Use all the available metrics to generate recommendations.\n- `MONITORING_AGENT_ONLY`: Use only metrics collected by the Cloud Monitoring Ops Agent.\n- If you don't use the Ops Agent, and prefer not to receive memory recommendations, use the `MEMORY_AGENT_ONLY` value to disable the recommendations.\n\nTo get more accurate recommendations about memory usage, use the\n[Ops Agent](/monitoring/agent/ops-agent).\n\n### Update the configuration for a project\n\nTo update the configuration of your machine type recommendations, modify the\nconfiguration values and upload the new configuration for your project.\nYou can change the preferred machine types, the memory metrics used for\nrecommendations, or both values in the same request.\n\nAfter you upload the new configuration, it takes approximately 48 hours for it\nto take effect. Until that time, any generated recommendations use the previous\nconfiguration. \n\n### gcloud\n\nTo update the configuration parameters, use the\n[`gcloud beta recommender recommender-config update` command](/sdk/gcloud/reference/beta/recommender/recommender-config/update)\nand use `google.compute.instance.MachineTypeRecommender` as the\nRecommender ID: \n\n```\ngcloud beta recommender recommender-config update google.compute.instance.MachineTypeRecommender\\\n --project=PROJECT_ID \\\n --location=ZONE \\\n --config-file=LOCAL_FILE_PATH_AND_NAME \\\n --etag=ETAG\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your project.\n- \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the zone for which you want to obtain the current configuration.\n- \u003cvar translate=\"no\"\u003eLOCAL_FILE_PATH_AND_NAME\u003c/var\u003e: the path to the JSON file with the current configuration.\n- \u003cvar translate=\"no\"\u003eETAG\u003c/var\u003e: the etag value of the current configuration. You can find this value in the output of the [previous command](#get_current_configuration).\n\nIn your configuration file, specify only the `recommenderGenerationConfig`\nobject with the updated configuration parameters. If you saved the\nconfiguration to a local file, make sure you copy the `etag` value, then\nremove all the fields except the `recommenderGenerationConfig` value.\n\nFor example, to get recommendations with standard machine types only,\nuse the following configuration file: \n\n```\n{\n \"params\": {\n \"preferred_machine_types\": \"STANDARD_ONLY\"\n }\n}\n```\n\nIf the command is successful, it returns a response body similar to the\nfollowing, showing the new configuration with the parameters you just\nmodified. \n\n```\n{\n \"name\": \"projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.MachineTypeRecommender/config\",\n \"recommenderGenerationConfig\": {\n \"params\": {\n \"preferred_machine_types\": \"STANDARD_ONLY\"\n }\n },\n \"etag\": \"\\\"1245f9435cd01ea8\\\"\",\n \"updateTime\": \"2024-08-20T05:00:05Z\"\n}\n```\n| **Note:** the `etag` value changes from the previous configuration. You must use the new value if you update the configuration again.\n\nWhat's next\n-----------\n\n- Learn how to [Apply machine type recommendations to instances](/compute/docs/instances/apply-machine-type-recommendations-for-instances).\n- Learn how to [Apply machine type recommendations to managed instance groups](/compute/docs/instance-groups/apply-machine-type-recommendations-managed-instance-groups)."]]