1
votes

I'm trying to access the metrics using the Azure Insights API as per the following MSDN blog.

My Request URL is:

https://management.azure.com/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachine/myVM/metrics?api-version=2016-03-30

with proper Accept and Authorization headers.

The same thing works for metricDefinitions and I get back a bunch of MetricDefinitions. But when I try to access the /metrics endpoint, I get back this:

{
  "error": {
    "code": "BadRequest",
    "message": "The request URL is not valid."
  }
}

Is there anyway to know what am I doing wrong in the request?

1

1 Answers

0
votes

You need to specify the metric's name for any filtering requests. But there is no metric specifed in your URL, which leads to an invalid URL. For example, you want to retreive the CpuTime metric data point, the request url should be like below:

https://management.azure.com/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachine/myVM/metrics?api-version=2016-03-30&$filter=%28name.value%20eq%20%27CpuTime%27%20