user3726056
user3726056

Reputation: 3

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

Like from URL GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmname}/providers/microsoft.insights/metrics?api-version=2018-01-01&metricnames=Percentage%20CPU&timespan=2018-06-05T03:00:00Z/2018-06-07T03:00:00Z

We can fetch only one metric "percentage CPU" at a time.

I want to fetch percentage CPU, Memory, disk network, etc metrics in one API call for a single VM.

Is that possible?

Upvotes: 0

Views: 1041

Answers (2)

PyLover
PyLover

Reputation: 41

Azure allows to fetch multiple metrics as mentioned on its documents

metrics_names

Image has been picked form Azure document https://learn.microsoft.com/en-us/rest/api/monitor/metrics/list

*Note: Although it allows multiple metrics but with a limit cap of 20. It would give an error if more than 20 metrics name are specified "Requested metrics count: 21 bigger than allowed max: 20"

Upvotes: 0

Stanley Gong
Stanley Gong

Reputation: 12153

You can specify all metrics you want to query by metricnames param separate by , in request URL just as below:

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&timespan=2018-06-05T03:00:00Z/2018-06-07T03:00:00Z

Result:

enter image description here

All natively supported metrics are:

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

If you want to get memory-related metrics, see this post.

Upvotes: 1

Related Questions