虛擬機器 (VM) 執行個體洞察資料可協助您瞭解 Compute Engine VM 的 CPU、記憶體和網路使用情形。系統會根據系統指標或 Cloud Monitoring 收集的指標,自動產生深入分析資訊。您可以根據洞察資料,決定是否要調整機器類型的大小,以提高 VM 資源的使用效率。
如要進一步瞭解洞察,請參閱洞察。
事前準備
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Google Cloud 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列其中一個選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
PROJECT_ID
:您的專案 ID。LOCATION
:包含您要查看深入分析資訊的資源的可用區。INSIGHT_TYPE_ID
:洞察類型的 ID。如需可用的 VM 洞察資料清單,請參閱「VM 執行個體洞察資料類型」。FORMAT
:偏好的輸出格式,例如json
。PROJECT_ID
:您的專案 ID。LOCATION
:包含您要查看洞察資料的資源的可用區。INSIGHT_TYPE_ID
:洞察類型的 ID。如需可用的 VM 洞察資料清單,請參閱「VM 執行個體洞察資料類型」。HIGH_CPU_USAGE
LOW_CPU_USAGE
In the last 12 days for 90% of the time, CPU usage was greater than or equal to 83%.
In the last 10 days for 70% of the time, CPU usage was lower than or equal to 20%.
sampleProbability
:(DOUBLE) 相對 CPU 用量,低於分位數函式值。quantileFunctionValue
:(DOUBLE) CPU 使用率上限,至少會保留部分樣本 (樣本機率)。
這個值代表 vCPU 總量的比例,範圍為 [0, 1]。Predicted CPU usage is 0.1 vCPUs.
CPU_USAGE_INCREASE
CPU_USAGE_DECREASE
In the last 7 days, average daily CPU usage has increased by 8% from 65% to 73%.
In the last 7 days, average daily CPU usage has decreased by 10% from 55% to 45%.
HIGH_MEMORY_USAGE
LOW_MEMORY_USAGE
In the last 12 days for 80% of the time, memory usage was greater than or equal to 64%.
In the last 7 days for 50% of the time, memory usage was lower than or equal to 10%.
sampleProbability
:(DOUBLE) 低於分位數函式值的記憶體用量樣本相對數量。quantileFunctionValue
:(DOUBLE) 記憶體用量的上限,至少會保留部分樣本 (樣本機率)。
這個值代表記憶體總量的比例,範圍為 [0, 1]。Predicted memory usage is 1536 MB.
LOW_RECEIVED_NETWORK_THROUGHPUT
LOW_SENT_NETWORK_THROGHPUT
In the last 7 days for 80% of the time, received network throughput was lower than or equal to 500 B/s.
In the last 7 days for 80% of the time, sent network throughput was lower than or equal to 200 B/s.
- 進一步瞭解 Compute Engine 根據洞察資料建立的機器類型建議。
- 進一步瞭解閒置 VM 最佳化建議。
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
詳情請參閱 Google Cloud 驗證說明文件中的「Authenticate for using REST」。
查看 VM 建議的洞察資料
Compute Engine 會根據資源洞察產生建議。 建議包括機器類型建議和閒置 VM 建議。
查看與特定 VM 相關的洞察資料,進一步瞭解 VM 的 CPU、記憶體和網路用量。
如要查看產生特定建議的洞察資料,請使用 gcloud CLI 或 API。
gcloud
如要詳細查看特定區域的所有可用洞察資料,請使用
insights list
指令,並提供--format
選項。gcloud recommender insights list --project=PROJECT_ID \ --location=LOCATION \ --insight-type=INSIGHT_TYPE_ID \ --format=FORMAT
更改下列內容:
使用
json
輸出格式時,insights list
指令的典型輸出內容如下所示。[ { "associatedRecommendations": [ { "recommendation": "projects/PROJECT_ID/locations/us-central1-a/recommenders/google.compute.instance.MachineTypeRecommender/recommendations/7618763b-fee2-42e5-8b9b-e6eee0b2077f" } ], "category": "PERFORMANCE", "content": { "predictedCpuCores": 0.15 }, "description": "Predicted CPU usage is 0.1 vCPUs.", "etag": "\"fdb51460cac758a0\"", "insightSubtype": "CPU_USAGE_PREDICTION", "lastRefreshTime": "2021-09-15T06:50:45Z", "name": "projects/PROJECT_ID/locations/us-central1-a/insightTypes/google.compute.instance.CpuUsagePredictionInsight/insights/cb2ab4e6-2c5e-4f0e-8cbe-1487e8bae8c0", "observationPeriod": "604800s", "severity": "LOW", "stateInfo": { "state": "ACTIVE" }, "targetResources": [ "//compute.googleapis.com/projects/PROJECT_ID/zones/us-central1-a/instances/instance-name-1" ] } ]
REST
如要查看特定區域的所有可用深入分析詳細資料,請使用
insights.list
方法。GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/insightTypes/INSIGHT_TYPE_ID/insights
更改下列內容:
insights.list
方法的典型輸出內容可能如下所示。[ { "associatedRecommendations": [ { "recommendation": "projects/PROJECT_ID/locations/us-central1-a/recommenders/google.compute.instance.MachineTypeRecommender/recommendations/7618763b-fee2-42e5-8b9b-e6eee0b2077f" } ], "category": "PERFORMANCE", "content": { "predictedCpuCores": 0.15 }, "description": "Predicted CPU usage is 0.1 vCPUs.", "etag": "\"fdb51460cac758a0\"", "insightSubtype": "CPU_USAGE_PREDICTION", "lastRefreshTime": "2021-09-15T06:50:45Z", "name": "projects/PROJECT_ID/locations/us-central1-a/insightTypes/google.compute.instance.CpuUsagePredictionInsight/insights/cb2ab4e6-2c5e-4f0e-8cbe-1487e8bae8c0", "observationPeriod": "604800s", "severity": "LOW", "stateInfo": { "state": "ACTIVE" }, "targetResources": [ "//compute.googleapis.com/projects/PROJECT_ID/zones/us-central1-a/instances/instance-name-1" ] } ]
如要進一步瞭解洞察資料,請參閱參考文件。
VM 執行個體洞察類型
您可以運用各種洞察資料,擷取 VM 的效能資訊。每種洞察類型都有特定的內容屬性。
以下各節提供可用的 VM 洞察參考資料。
CPU 用量洞察
如果 VM 的 CPU 使用率在過去觀察期間內高於或低於平常,Compute Engine 就會建立 CPU 使用率洞察資料。
洞察類型 ID 為
google.compute.instance.CpuUsageInsight
。可用的子類型如下:
這些項目與下列深入分析說明相關聯:
下表提供與 CPU 使用率洞察資訊相關的內容詳細資料。
屬性 類型 說明 points
ARRAY 物件陣列。每個物件都包含下列屬性:
CPU 使用量預測深入分析
Compute Engine 會建立 CPU 使用率預測洞察資料,指出隔天的預測 CPU 使用率。
洞察類型 ID 為
google.compute.instance.CpuUsagePredictionInsight
。這項洞察資訊的常見說明如下:
下表提供與 CPU 使用率預測洞察資訊相關的內容詳細資料。
屬性 類型 說明 predicted_cpu_cores
DOUBLE 預測的 CPU 核心數量。 CPU 使用趨勢深入分析
如果 CPU 使用率在過去觀察期間內呈現上升或下降趨勢,Compute Engine 就會建立 CPU 使用率趨勢深入分析。
洞察類型 ID 為
google.compute.instance.CpuUsageTrendInsight
。可用的子類型如下:
這些通常與下列洞察描述相關聯:
下表提供與 CPU 使用率趨勢洞察資訊相關內容的部分詳細資料。
屬性 類型 說明 cpu_usage_percentage_at_start
DOUBLE 測量觀察期開始時的每日平均 CPU 使用率。 這個值代表 vCPU 總數的百分比,範圍為 [0, 100]。
cpu_usage_percentage_at_end
DOUBLE 測量觀察期結束時的每日平均 CPU 使用率。 這個值代表 vCPU 總數的百分比,範圍為 [0, 100]。
cpu_usage_percentage_change
DOUBLE 觀測期間內每日平均 CPU 使用率的預測變化。 預測功能會使用線性迴歸,模擬每日 CPU 用量的變化。
這個值代表 vCPU 總數的百分比,範圍為 [0, 100]。
記憶體用量洞察
如果記憶體用量在觀察期間內異常偏高或偏低,Compute Engine 就會建立記憶體用量洞察資料。
洞察類型 ID 為
google.compute.instance.MemoryUsageInsight
。可用的子類型如下:
這些通常與下列洞察描述相關聯:
下表提供與記憶體用量洞察資訊相關內容的部分詳細資料。
屬性 類型 說明 points
ARRAY 物件陣列。每個物件都包含下列屬性: 記憶體用量預測深入分析
Compute Engine 會建立記憶體用量預測洞察,指出隔天預計的記憶體用量。
洞察類型 ID 為
google.compute.instance.MemoryUsagePredictionInsight
。常見的洞察說明如下:
下表提供與記憶體用量預測洞察資訊相關的內容詳細資料。
屬性 類型 說明 predicted_memory_mb
DOUBLE 預測的記憶體量,以 MB 為單位。 網路總處理量深入分析
如果觀察期間的網路處理量異常偏低,Compute Engine 就會針對傳入或傳出流量建立網路處理量深入分析。
洞察類型 ID 為
google.compute.instance.NetworkThroughputInsight
。可用的子類型如下:
這些通常與下列洞察描述相關聯:
下表提供與網路輸送量洞察相關內容的部分詳細資料。
屬性 類型 說明 sample_probability
DOUBLE 低於分位數函式值的網路總處理量樣本相對數量。 值介於 [0, 1] 之間。
quantile_function_value_in_bytes_per_second
DOUBLE 網路總處理量上限,至少包含部分樣本 (樣本機率)。這個值以每秒位元組為單位。 後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-10 (世界標準時間)。
-