2
votes

I am trying to execute the REST API to get the usage metrics data from Web Application deployed on Azure.

Hi,

I am trying to execute the REST API to get the usage metrics data from Web Application deployed on Azure. https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/sites//metrics?$filter=startTime%20eq%202016-04-12T06:05:42.907Z%20and%20endTime%20eq%202016-04-12T06:10:42.907Z&api-version=2014-04-01

But I am getting constantly 500 Internal Server Error.

Also, I tried to find out the given URL in Resource Explorer under the Mincrosoft.Web But in that I can see the metricsDefinitions but metrics is not available for this.

Can someone please let me know what how can I get the usage metrics data for the Web Application Services?

1
I'm running into the same issue. Can you please post your complete URL structure or request/response as an answer?Leon Cullens

1 Answers

0
votes

You can retrieve resource metrics via the Azure Insights API.By using the Azure Insights API it is possible to programmatically retrieve the available default metric definitions (the type of metric such as CPU Time, Requests, etc.), granularity, and metric values.

https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}/metrics?api-version=2014-04-01&$filter={filter}

It seems the REST API URI you are using is right, but before that the first step is to authenticate the Azure Insights API request. The easiest way to set up authentication is by creating an Azure AD service principal and retrieve the authentication token.

A very detailed walkthrough at https://blogs.msdn.microsoft.com/cloud_solution_architect/2016/02/23/retrieving-resource-metrics-via-the-azure-insights-api/.