如何在单个 VM 的单个 API 调用中获取多个 VM 指标(百分比 CPU、DIisk 读取 Operations/sec、内存等 .. 平台指标)详细信息
How to get multiple VM metric (Percentage CPU, DIisk Read Operations/sec, Memory etc .. platform metrics) details in a single API Call for a single VM
我们一次只能获取一个指标“百分比 CPU”。
我想在单个 VM 的一次 API 调用中获取百分比 CPU、内存、磁盘网络等指标。
这可能吗?
您可以在请求 URL 中通过 metricnames
param 分隔的 ,
指定要查询的所有指标,如下所示:
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmname}/providers/microsoft.insights/metrics?api-version=2018-01-01&metricnames=Percentage CPU,Disk Read Bytes,Disk Write Bytes,Network In,Network Out×pan=2018-06-05T03:00:00Z/2018-06-07T03:00:00Z
结果:
所有原生支持的指标是:
Percentage CPU,Network In,Network Out,Disk Read Bytes,Disk Write Bytes,Disk Read Operations/Sec,Disk Write Operations/Sec,CPU Credits Remaining,CPU Credits Consumed,Data Disk Read Bytes/sec,Data Disk Write Bytes/sec,Data Disk Read Operations/Sec,Data Disk Write Operations/Sec,Data Disk Queue Depth,Data Disk Bandwidth Consumed Percentage,Data Disk IOPS Consumed Percentage,Data Disk Target Bandwidth,Data Disk Target IOPS,Data Disk Max Burst Bandwidth,Data Disk Max Burst IOPS,Data Disk Used Burst BPS Credits Percentage,Data Disk Used Burst IO Credits Percentage,OS Disk Read Bytes/sec,OS Disk Write Bytes/sec,OS Disk Read Operations/Sec,OS Disk Write Operations/Sec,OS Disk Queue Depth,OS Disk Bandwidth Consumed Percentage,OS Disk IOPS Consumed Percentage,OS Disk Target Bandwidth,OS Disk Target IOPS,OS Disk Max Burst Bandwidth,OS Disk Max Burst IOPS,OS Disk Used Burst BPS Credits Percentage,OS Disk Used Burst IO Credits Percentage,Inbound Flows,Outbound Flows,Inbound Flows Maximum Creation Rate,Outbound Flows Maximum Creation Rate,Premium Data Disk Cache Read Hit,Premium Data Disk Cache Read Miss,Premium OS Disk Cache Read Hit,Premium OS Disk Cache Read Miss,VM Cached Bandwidth Consumed Percentage,VM Cached IOPS Consumed Percentage,VM Uncached Bandwidth Consumed Percentage,VM Uncached IOPS Consumed Percentage,Network In Total,Network Out Total
如果您想获取与内存相关的指标,see this post。
Azure 允许获取其文档中提到的多个指标
图像已从 Azure 文档中选取
https://docs.microsoft.com/en-us/rest/api/monitor/metrics/list
*注意:虽然允许多个metrics,但是上限为20个,超过20个metrics名称会报错
“请求的指标数:21 大于允许的最大值:20”
我们一次只能获取一个指标“百分比 CPU”。
我想在单个 VM 的一次 API 调用中获取百分比 CPU、内存、磁盘网络等指标。
这可能吗?
您可以在请求 URL 中通过 metricnames
param 分隔的 ,
指定要查询的所有指标,如下所示:
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmname}/providers/microsoft.insights/metrics?api-version=2018-01-01&metricnames=Percentage CPU,Disk Read Bytes,Disk Write Bytes,Network In,Network Out×pan=2018-06-05T03:00:00Z/2018-06-07T03:00:00Z
结果:
所有原生支持的指标是:
Percentage CPU,Network In,Network Out,Disk Read Bytes,Disk Write Bytes,Disk Read Operations/Sec,Disk Write Operations/Sec,CPU Credits Remaining,CPU Credits Consumed,Data Disk Read Bytes/sec,Data Disk Write Bytes/sec,Data Disk Read Operations/Sec,Data Disk Write Operations/Sec,Data Disk Queue Depth,Data Disk Bandwidth Consumed Percentage,Data Disk IOPS Consumed Percentage,Data Disk Target Bandwidth,Data Disk Target IOPS,Data Disk Max Burst Bandwidth,Data Disk Max Burst IOPS,Data Disk Used Burst BPS Credits Percentage,Data Disk Used Burst IO Credits Percentage,OS Disk Read Bytes/sec,OS Disk Write Bytes/sec,OS Disk Read Operations/Sec,OS Disk Write Operations/Sec,OS Disk Queue Depth,OS Disk Bandwidth Consumed Percentage,OS Disk IOPS Consumed Percentage,OS Disk Target Bandwidth,OS Disk Target IOPS,OS Disk Max Burst Bandwidth,OS Disk Max Burst IOPS,OS Disk Used Burst BPS Credits Percentage,OS Disk Used Burst IO Credits Percentage,Inbound Flows,Outbound Flows,Inbound Flows Maximum Creation Rate,Outbound Flows Maximum Creation Rate,Premium Data Disk Cache Read Hit,Premium Data Disk Cache Read Miss,Premium OS Disk Cache Read Hit,Premium OS Disk Cache Read Miss,VM Cached Bandwidth Consumed Percentage,VM Cached IOPS Consumed Percentage,VM Uncached Bandwidth Consumed Percentage,VM Uncached IOPS Consumed Percentage,Network In Total,Network Out Total
如果您想获取与内存相关的指标,see this post。
Azure 允许获取其文档中提到的多个指标
图像已从 Azure 文档中选取 https://docs.microsoft.com/en-us/rest/api/monitor/metrics/list
*注意:虽然允许多个metrics,但是上限为20个,超过20个metrics名称会报错 “请求的指标数:21 大于允许的最大值:20”