Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara melihat dan mengubah konfigurasi rekomendasi jenis mesin. Anda dapat mengubah jenis mesin yang direkomendasikan,
sehingga rekomendasi yang dihasilkan hanya mencakup rangkaian mesin pilihan Anda.
Anda juga dapat mengubah metrik yang digunakan untuk membuat rekomendasi memori guna meningkatkan akurasi rekomendasi. Perubahan pada konfigurasi
diterapkan di tingkat project.
Jika Anda belum melakukannya, siapkan autentikasi.
Autentikasi adalah
proses yang digunakan untuk memverifikasi identitas Anda untuk mengakses Google Cloud layanan dan API.
Untuk menjalankan kode atau sampel dari lingkungan pengembangan lokal, Anda dapat melakukan autentikasi ke
Compute Engine dengan memilih salah satu opsi berikut:
Menginstal Google Cloud CLI.
Setelah penginstalan,
lakukan inisialisasi Google Cloud CLI dengan menjalankan perintah berikut:
Untuk mendapatkan izin yang diperlukan untuk mengubah rekomendasi jenis mesin, minta administrator Anda untuk memberi Anda peran IAM Compute Recommender Admin (roles/recommender.computeAdmin) di project Anda.
Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.
Peran bawaan ini berisi
izin yang diperlukan untuk mengubah rekomendasi jenis mesin. Untuk melihat izin yang benar-benar diperlukan, luaskan bagian Izin yang diperlukan:
Izin yang diperlukan
Izin berikut diperlukan untuk mengubah rekomendasi jenis mesin:
Lihat konfigurasi rekomendasi jenis mesin:
recommender.computeInstanceMachineTypeRecommenderConfig.get
di project
Ubah konfigurasi rekomendasi jenis mesin:
recommender.computeInstanceMachineTypeRecommenderConfig.update
pada project
Anda dapat memperoleh konfigurasi saat ini untuk rekomendasi jenis mesin untuk project Anda menggunakan Google Cloud CLI.
gcloud
Untuk mendapatkan parameter konfigurasi saat ini, gunakan
perintah gcloud beta recommender recommender-config describe
dan gunakan google.compute.instance.MachineTypeRecommender sebagai
ID Pemberi Rekomendasi:
Konfigurasi ini memungkinkan Anda menyesuaikan parameter berikut:
preferred_machine_types: Rekomendasi jenis mesin yang Anda terima.
memory_metrics: Cara metrik memori digunakan untuk membuat rekomendasi.
Opsi untuk rekomendasi jenis mesin
Anda dapat menentukan jenis mesin yang direkomendasikan dengan mengubah setelan preferred_machine_types ke salah satu nilai berikut:
DEFAULT: Nilai defaultnya adalah STANDARD_AND_CUSTOM.
STANDARD_AND_CUSTOM: Merekomendasikan kecocokan terbaik dari jenis mesin standar dan kustom.
STANDARD_ONLY: Merekomendasikan kecocokan terbaik hanya dari jenis mesin standar.
Opsi untuk rekomendasi memori
Untuk metrik memori yang digunakan untuk membuat rekomendasi, Anda dapat menetapkan
nilai berikut:
MEMORY_METRICS_DEFAULT: Menggunakan metrik default untuk membuat rekomendasi.
MEMORY_METRICS_ALL: Menggunakan semua metrik yang tersedia untuk membuat rekomendasi.
MONITORING_AGENT_ONLY: Hanya gunakan metrik yang dikumpulkan oleh
Agen Operasi Cloud Monitoring.
Jika Anda tidak menggunakan Ops Agent, dan memilih untuk tidak menerima rekomendasi memori, gunakan nilai MEMORY_AGENT_ONLY untuk menonaktifkan rekomendasi.
Untuk mendapatkan rekomendasi yang lebih akurat tentang penggunaan memori, gunakan
Agen Operasional.
Memperbarui konfigurasi untuk sebuah project
Untuk memperbarui konfigurasi rekomendasi jenis mesin, ubah nilai konfigurasi dan upload konfigurasi baru untuk project Anda.
Anda dapat mengubah jenis mesin pilihan, metrik memori yang digunakan untuk rekomendasi, atau kedua nilai dalam permintaan yang sama.
Setelah Anda mengupload konfigurasi baru, perlu waktu sekitar 48 jam agar konfigurasi tersebut diterapkan. Hingga saatnya tiba, setiap rekomendasi yang dihasilkan akan menggunakan konfigurasi
sebelumnya.
gcloud
Untuk memperbarui parameter konfigurasi, gunakan
perintah gcloud beta recommender recommender-config update
dan gunakan google.compute.instance.MachineTypeRecommender sebagai
ID Pemberi Rekomendasi:
ZONE: zona yang konfigurasinya saat ini ingin Anda dapatkan.
LOCAL_FILE_PATH_AND_NAME: jalur ke file JSON
dengan konfigurasi saat ini.
ETAG: nilai etag konfigurasi saat ini.
Anda dapat menemukan nilai ini dalam output
perintah sebelumnya.
Dalam file konfigurasi, tentukan hanya objek recommenderGenerationConfig
dengan parameter konfigurasi yang telah diupdate. Jika Anda menyimpan konfigurasi ke file lokal, pastikan Anda menyalin nilai etag, lalu hapus semua kolom kecuali nilai recommenderGenerationConfig.
Misalnya, untuk mendapatkan rekomendasi dengan jenis mesin standar saja, gunakan file konfigurasi berikut:
Jika berhasil, perintah akan menampilkan isi respons yang mirip dengan
berikut, yang menunjukkan konfigurasi baru dengan parameter yang baru saja
Anda ubah.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)."]]