Forum Discussion
Nayan Ch
Sep 19, 2018Copper Contributor
How to get Azure VM Guest Metrics (Performance Counters) through an API?
Able to retrieve Azure VM Host Metrics using Azure Management API call. https://docs.microsoft.com/en-us/azure/virtual-machines/linux/metrics-vm-usage-rest When trying to fetch performance count...
Noa Kuperberg
Microsoft
Sep 20, 2018Hi,
I think you might have mixed the logs and metrics APIs, which are separate. Logs contain a lot of performance data, some of which also covered by Metrics, which might be confusing.
To query, for example, the top 3 highest-memory using computers you want to run this query over Log Analytics:
Perf | where TimeGenerated > ago(1h) | where ObjectName == \"Memory\" and CounterName == \"Used Memory MBytes\" | summarize average_used_memory=avg(CounterValue) by Computer | top 3 by average_used_memory
(note this specific counter name is reported for Linux machines only). To run this through the API, post the query in a JSON format (shown below) to "https://api.loganalytics.io/v1/workspaces/DEMO_WORKSPACE/query" (url for the demo workspace API) and add the 2 required headers, as shown below:
You can find the details here.
HTH,
Noa