0

HI i want to monitor Azure Classic VM using REST API/Java SDK , when i tried it with REST API with the following URL(The below url worked for Azure VM)

https://management.azure.com/subscriptions/<subscription_id>/resourceGroups/Preprod2-Resource-Group/providers/Microsoft.ClassicCompute/virtualMachines/cloudops-testvm1/providers/microsoft.insights/metrics?api-version=2016-09-01

I'm getting the following error

{ "code": "NotFound", "message": "Resource provider not found: [Microsoft.ClassicCompute]" }

Please suggest me if it can be done via REST API or if there is an SDK please suggest me the same.

My requirement is i want to monitor Classic VM and collect Network In,Network Out,Percentage CPU,Disk Read Operations/Sec,Disk Write Operations/Sec,Disk Write Bytes and Disk Read Bytes for every 5mins

Kul-Tigin
  • 16,728
  • 1
  • 35
  • 64

1 Answers1

0

This isn't a supported resource type through metrics API. The supported types and metrics are here:Supported metrics with Azure Monitor. You could check this link, for now, classic VM is not supported.

According to your description, you could use the Metric Definitions API. It works for classic VM.

https://management.azure.com/subscriptions/<subscription_id>/resourceGroups/<resourceGroups/>/providers/Microsoft.ClassicCompute/virtualMachines/<Virutal name>/providers/microsoft.insights/metricdefinitions?api-version=2015-07-01

Metric information stores in Azure storage account, you also could call Storage API to get VM metrics. More information please refer to this link:Storage Analytics.

Shui shengbao
  • 18,746
  • 3
  • 27
  • 45
  • Walter Thank you for the reply, the above Storage Analytics link shows only Storage related tables, can you please help me on how Storage API can be used to get VM metrics – Abhishek B A Jul 13 '17 at 04:14
  • Walter as u suggested i have raised one more question on stackoverflow below is the link pls help with the same https://stackoverflow.com/questions/45071394/how-storage-api-can-be-used-to-get-classic-vm-metrics – Abhishek B A Jul 13 '17 at 04:28
  • @AbhishekBA Hi, `metricdefinitions` achieves your need. I could get some metrics you need. Also, I will test Storage API. – Shui shengbao Jul 13 '17 at 04:36
  • Walter i tried metricdefinitions but it only gives supported metric's information ,it does not give us the actual metric value for that hour or minute – Abhishek B A Jul 13 '17 at 04:45
  • @AbhishekBA OK, I mean. Because classic VM does not support metrics API, you should select storage account API or other methods. – Shui shengbao Jul 13 '17 at 04:47
  • Thank you Walter i got your point, but im trying to understand Storage API to get VM metrics. I have already used Storage API to get metrics for Azure Storage and Classic Storage there i used CloudAnalyticsClient to get the table names for storage but for VM i dont think it is not that straight forward. – Abhishek B A Jul 13 '17 at 05:09
  • @AbhishekBA Yes, you are right.For a classic VM, you could not get metrics according to VM. You also could refer to this [link](https://learn.microsoft.com/en-us/rest/api/storageservices/enabling-storage-metrics-and-viewing-metrics-data). – Shui shengbao Jul 13 '17 at 05:14
  • Walter please help me resolve https://stackoverflow.com/questions/46950222/azure-microsoft-insights-api-2016-09-01-error-while-collecting-metrics – Abhishek B A Oct 27 '17 at 07:30
  • @AbhishekBA Hi, I test in my lab, two API all work for me. – Shui shengbao Oct 27 '17 at 07:46