Quantcast
Channel: Azure Management Portal forum
Viewing all articles
Browse latest Browse all 4189

{"Code":"InvalidRequest","Message":"Could not retrieve metrics."}

$
0
0

I am trying to fetch metrices of cloud service using (Microsoft.WindowsAzure.Management) service api .I am able to get the definition of all metrices but while i am trying to retrieve the response for those metrices then getting error.The below is my code.

====================================================================================

X509Store store =newX509Store(

           StoreName.My,StoreLocation.CurrentUser);

 

           store.Open(OpenFlags.ReadOnly);

 

           string thumbprint ="--------------------------------";

 

           X509Certificate2 x509Certificate = store.Certificates.Find(

           X509FindType.FindByThumbprint, thumbprint,false)[0];

 

 

           string SUBSCRIPTION_ID ="-----------------------------------";

           CertificateCloudCredentials credentials =

           newCertificateCloudCredentials(SUBSCRIPTION_ID, x509Certificate);

 

           string cloudserviceResourceId =ResourceIdBuilder.BuildCloudServiceResourceId("wedsite","-----------------------------",null,null);

 

           MetricsClient metricsClient =newMetricsClient(credentials);

 

           

           MetricDefinitionListResponse metricListResponse =

           metricsClient.MetricDefinitions.List(cloudserviceResourceId, null,null);

          

          

           foreach (MetricDefinition metricDefinition in

           metricListResponse.MetricDefinitionCollection.Value)

           {

               String displayName = metricDefinition.DisplayName;

               String metricName = metricDefinition.Name;

               TimeSpan alertableTimeWindows =

               metricDefinition.MinimumAlertableTimeWindow;

               String units = metricDefinition.Unit;

               String primaryAggregation = metricDefinition.PrimaryAggregation;

           }

           

           IList<string> lstdata = newList<string>();

           List<String> metricNames = newList<String>() { "Disk Read Bytes/sec",

           "Disk Write Bytes/sec","Network In","Network Out",

               "Percentage CPU" };                  

           MetricValueListResponse response = metricsClient.MetricValues.List(cloudserviceResourceId, metricNames, "",

               TimeSpan.FromMinutes(5), DateTime.UtcNow.AddDays(-1), DateTime.UtcNow);           

           foreach (MetricValueSet value in

           response.MetricValueSetCollection.Value)

           {

               String valueName = value.Name;

               foreach (MetricValue metricValue in value.MetricValues)

               {

                   Double? average = metricValue.Average;

                   Int32? count = metricValue.Count;

                   Double? maximum = metricValue.Maximum;

                   Double? minimum = metricValue.Minimum;

                   DateTime timestamp = metricValue.Timestamp;

                   Double? total = metricValue.Total;

               }

====================================================================================

Please reponse as soon as  possible.

Thanks

Avikash Sharma


Viewing all articles
Browse latest Browse all 4189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>