本頁面說明如何查看及修改未充分利用的隨選預訂建議設定。您可能想修改設定,增加收到的建議數量,或是減少建議數量,以便刪除打算使用的預訂。
- 如要進一步瞭解可自訂建議的參數,請參閱「選擇合適的設定參數」。
- 如要進一步瞭解如何根據閒置或未充分利用的預留項目最佳化建議採取行動,請參閱「查看及套用閒置預留項目最佳化建議」或「查看及套用未充分利用的預留項目最佳化建議」。
事前準備
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Trusted Cloud by S3NS 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列任一選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
gcloud
-
安裝 Google Cloud CLI,然後 使用同盟身分登入 gcloud CLI。 登入後,執行下列指令初始化 Google Cloud CLI:
gcloud init
- Set a default region and zone.
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
安裝 Google Cloud CLI,然後 使用同盟身分登入 gcloud CLI。 登入後,執行下列指令初始化 Google Cloud CLI:
gcloud init
詳情請參閱 Trusted Cloud 驗證說明文件中的「Authenticate for using REST」。
設定建議
如要設定資源用量不足的預訂項目建議,請按照下列步驟操作:
取得目前的設定
您可以透過 Google Cloud CLI 或 REST,取得專案目前未充分利用預留項目建議的設定。
請使用下列其中一種方法完成這項工作。
gcloud
如要取得目前的設定參數,請使用
gcloud recommender recommender-config describe
指令,並將google.compute.RightSizeResourceRecommender
做為 Recommender ID:gcloud recommender recommender-config describe google.compute.RightSizeResourceRecommender \ --location=ZONE --billing-account=BILLING_ACCOUNT_ID
更改下列內容:
ZONE
,其中包含要列出建議的預訂項目。- 將
BILLING_ACCOUNT_ID
替換為帳單帳戶的 ID。
例如:
gcloud recommender recommender-config describe google.compute.RightSizeResourceRecommender \ --location=us-central1-c --billing-account=my-billing-account-id
指令會傳回建議事項設定,包括可修改的子欄位
params.under_utilized_reservation_lookback_period
和params.under_utilized_reservation_utilization_threshold
。{ "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.RightSizeResourceRecommender/config", "recommenderGenerationConfig": { "params": { "under_utilized_reservation_lookback_period": "P7D", "under_utilized_reservation_utilization_threshold": "0.8" } }, "etag": "\"2f3c9b65cda6a4ba\"", "updateTime": "2024-06-03T04:41:15.330351Z" }
REST
如要擷取目前的設定,請使用
recommenders.getConfig
方法,並將google.compute.RightSizeResourceRecommender
指定為建議事項 ID:GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.RightSizeResourceRecommender/config
更改下列內容:
PROJECT_ID
:要修改建議事項設定的專案 ID。ZONE
:包含專案的可用區。
在指令列執行下列指令,取得專案的建議事項設定:
PROJECT_ID=PROJECT_ID ZONE=ZONE curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-user-project: ${PROJECT_ID}" \ https://recommender.googleapis.com/v1/projects/$PROJECT_ID/locations/$ZONE/recommenders/google.compute.RightSizeResourceRecommender/config
這項指令會傳回建議事項設定,包括可修改的子欄位:
params.under_utilized_reservation_lookback_period
和params.under_utilized_reservation_utilization_threshold
。{ "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.RightSizeResourceRecommender/config", "recommenderGenerationConfig": { "params": { "under_utilized_reservation_lookback_period": "P7D", "under_utilized_reservation_utilization_threshold": "0.8" } }, "etag": "\"2f3c9b65cda6a4ba\"", "updateTime": "2024-06-03T04:41:15.330351Z" }
更新專案的設定
如要更新資源用量不足預訂建議的設定,請修改
under_utilized_reservation_lookback_period
的值,並上傳專案的新設定。您可以將觀察期設為 7 天到 30 天之間的值,方法是使用以
P
開頭的字串,然後輸入天數的整數值 (最小值為7
,最大值為30
),最後加上D
,例如:- 如要將觀測期設為 7 天,請使用
"P7D"
。 - 如要設定 30 天的觀測期,請使用
"P30D"
。
同樣地,請修改
under_utilized_reservation_utilization_threshold
的值,設定觸發資源用量不足預訂項目建議的用量門檻,並上傳專案的新設定,例如:- 如果門檻為 80%,則為
"0.8"
。
上傳新設定後,大約需要 48 小時才會生效。在此之前,系統會使用先前的設定生成建議。
請使用下列其中一種方法完成這項工作。
gcloud
如要更新設定參數,請使用
gcloud recommender recommender-config update
指令,並將google.compute.RightSizeResourceRecommender
做為建議事項 ID:gcloud recommender recommender-config update google.compute.RightSizeResourceRecommender\ --location=ZONE \ --config-file=CONFIG_FILE_PATH \ --etag=ETAG \ --billing-account=BILLING_ACCOUNT_ID
更改下列內容:
ZONE
:要取得目前設定的區域CONFIG_FILE_PATH
:包含目前設定的 JSON 檔案路徑ETAG
:目前設定的 etag 值BILLING_ACCOUNT_ID
:帳單帳戶的 ID
在設定檔中,只指定包含更新後設定參數的
recommenderGenerationConfig
物件。舉例來說,如要指定 21 天的觀察期,並將資源用量不足的預訂項目門檻設為 80%,請使用下列設定檔:{ "params": { "under_utilized_reservation_lookback_period": "P21D", "under_utilized_reservation_utilization_threshold": "0.8" } }
如果指令成功,會傳回類似以下的內容,顯示您剛修改參數的新設定。
{ "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.RightSizeResourceRecommender/config", "recommenderGenerationConfig": { "params": { "under_utilized_reservation_lookback_period": "P21D", "under_utilized_reservation_utilization_threshold": "0.8" } }, "etag": "\"1245f9435cd01ea8\"", "updateTime": "2024-06-03T05:00:05Z" }
REST
如要更新設定,請對
recommenders.updateConfig
方法發出PATCH
要求,並將google.compute.RightSizeResourceRecommender
指定為建議事項 ID:PATCH https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.RightSizeResourceRecommender/config { "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.RightSizeResourceRecommender/config", "recommenderGenerationConfig": { "params": { "under_utilized_reservation_lookback_period": "P21D", "under_utilized_reservation_utilization_threshold": "0.8" } }, "etag": "\"2f3c9b65cda6a4ba\"" }
更改下列內容:
PROJECT_ID
:要修改建議事項設定的專案 ID。ZONE
:包含專案的可用區。
將要求主體儲存在檔案中,例如
config.json
。接著,您可以使用類似下列的指令,在更新專案的建議事項設定時參照該檔案:curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ -H "x-goog-user-project: ${PROJECT_ID}" \ -d @config.json \ https://recommender.googleapis.com/v1/projects/$PROJECT_ID/locations/$ZONE/recommenders/google.compute.RightSizeResourceRecommender/config
POST
指令會傳回類似下列的回應主體,顯示您剛修改的參數和新設定。{ "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.RightSizeResourceRecommender/config", "recommenderGenerationConfig": { "params": { "under_utilized_reservation_lookback_period": "P21D", "under_utilized_reservation_utilization_threshold": "0.8" } }, "etag": "\"1245f9435cd01ea8\"", "updateTime": "2024-06-03T05:00:05Z" }
後續步驟
- 瞭解如何查看及套用閒置預訂項目建議。
- 瞭解如何查看及套用未充分利用的預訂項目建議。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-19 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-19 (世界標準時間)。"],[[["\u003cp\u003eThis page explains how to configure underutilized reservation recommendations, which are Pre-GA products available "as is" with potentially limited support.\u003c/p\u003e\n"],["\u003cp\u003eYou can modify the configuration to adjust the number of recommendations received by altering parameters like the lookback period (7-30 days) and utilization threshold.\u003c/p\u003e\n"],["\u003cp\u003eConfiguration changes require getting the current configuration in JSON format, editing it, and then uploading the updated file using either the Google Cloud CLI or REST API.\u003c/p\u003e\n"],["\u003cp\u003eTo update the configuration you must have \u003ccode\u003erecommender.computeRightSizeResourceRecommender.get\u003c/code\u003e to view, and \u003ccode\u003erecommender.computeRightSizeResourceRecommender.update\u003c/code\u003e permissions to modify.\u003c/p\u003e\n"],["\u003cp\u003eAfter uploading a new configuration, it will take approximately 48 hours for the changes to become effective and to be used to generate any new recommendations.\u003c/p\u003e\n"]]],[],null,[]] -