简体   繁体   中英

Azure Web Analytics API Required

I Would like to build my own custom simple webpage that display statistics from a number of our websites running on azure. (basically a stripped down version of portal.azure.com which will go up in the office displaying simple data on monitors)

All the stats I would like to display currently exist on portal.azure.com such as: - Requests per minute - Response Time - Http Server Errors per minute

Am I able to get access to the same data that the azure portal currently does or do I need to implement something else into the websites which has a API that I could then use to build my separate site?

I'm still using the Monitoring (Classic) APIs currently. I've not found a "non-classic" version of the API, but I've also not spent much time looking. Since a web job runs as part of the Web App you'll need to monitor the web app using the tools provided in the Microsoft.WindowsAzure.Management.Monitoring.Metrics Namespace.

I found the API to be somewhat confusing, but spent sometime working with the PG to get it right. I've provided some sample code on the MSPFE github page at: https://github.com/mspfe/AzureMetricsAPISampleKit . Running the "tests" in this Solution will show you how to use the lib.

You first need to identify the web app by getting a list of them:

var webSpaceList = _webSiteClient.WebSpaces.List(); Then collect the availabile metrics:

foreach (var website in websiteList) { MetricDefinitionListResponse wsMetricListResponse = _metricsClient.MetricDefinitions.List(website.WebsiteResourceId, null, null); website.MetricDefinitionsList = wsMetricListResponse.MetricDefinitionCollection; website.MetricNamesList = new List();

        foreach (var metric in website.MetricDefinitionsList.Value)
        {
            website.MetricNamesList.Add(metric.Name);
        }

        MetricValueListResponse wsValueResponse = _metricsClient.MetricValues.List(website.WebsiteResourceId, website.MetricNamesList, "",
            _timeGrain, _startDateTime, _endDateTime);
        website.MetricValueList = wsValueResponse.MetricValueSetCollection;
    }

From there you should have metric definitions and values. Sorry if this code is a little dated... but it should work.

To add to Devians answer, I found that with my websites I had Diagnostics logs for web server logging pointing at a Azure storage Account. This produced Tables with names "WADMetrics...." In here I found time periods (1minute,1 hour etc) with metrics for such things as get responses max,min,average and etc

All the data I needed is in these azure tables. So if the old API doesn't work then I will look to directly read from this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM