예제 #1
0
        private async Task <ChartData> GetCloudServiceMetrics(AMDCloudServiceRoleId serviceRoleId, TimeSpan history, string label, string regex, Func <string, string, string> formatSeriesLabel)
        {
            var client = new AzureCloudServicesClient(new AzureManagementRestClient(GetCredentials().GetCertificateCloudCredentials()), GetCredentials().GetCertificateCloudCredentials());

            var instances = await client.ListInstancesForServiceRole(serviceRoleId);

            var usages = await client.GetUsage(instances, history, MetricsFilter.FromRegexes(regex));

            var usagesPartitioned = PartitionByInstanceNameAndMetric(usages);

            return(new ChartData {
                Name = string.Format("{0} {1} (Cloud Service)", serviceRoleId.DisplayName, label),
                Series = usagesPartitioned.Keys.SelectMany(
                    instance => usagesPartitioned[instance].Keys.Select(metricName => new SeriesData {
                    Name = formatSeriesLabel(instance, metricName),
                    DataPoints = usagesPartitioned[instance][metricName].Select(uo => new DataPoint {
                        Timestamp = uo.Timestamp, Value = uo.Value
                    }).ToList()
                })).ToList()
            });


            //usages.Select(_=> new SeriesData{
            //    Name = formatInstanceName(_.Key.InstanceName),
            //    DataPoints = _.Value.Select(uo=>new DataPoint { Timestamp = uo.Timestamp, Value = uo.Value }).ToList()
            //}).ToList()
        }
        public static string GetSubcriptionName(MetricsEndpointConfiguration config)
        {
            var credentials = config.GetCertificateCloudCredentials();
            var client      = new AzureCloudServicesClient(new AzureManagementRestClient(credentials), credentials);

            return(client.GetSubscriptionNameSync());
        }
        private async Task<ChartData> GetCloudServiceMetrics(AMDCloudServiceRoleId serviceRoleId, TimeSpan history, string label,string regex,Func<string,string,string> formatSeriesLabel) {
            var client = new AzureCloudServicesClient(new AzureManagementRestClient(GetCredentials().GetCertificateCloudCredentials()),GetCredentials().GetCertificateCloudCredentials());

            var instances = await client.ListInstancesForServiceRole(serviceRoleId);

            var usages = await client.GetUsage(instances,history,MetricsFilter.FromRegexes(regex));

            var usagesPartitioned = PartitionByInstanceNameAndMetric(usages);

            return new ChartData {
                Name = string.Format("{0} {1} (Cloud Service)", serviceRoleId.DisplayName,label),
                Series = usagesPartitioned.Keys.SelectMany(
                    instance=>usagesPartitioned[instance].Keys.Select(metricName=>new SeriesData {
                        Name = formatSeriesLabel(instance,metricName),
                        DataPoints = usagesPartitioned[instance][metricName].Select(uo=>new DataPoint { Timestamp = uo.Timestamp, Value = uo.Value }).ToList()
                    })).ToList()
            };
                
                
                //usages.Select(_=> new SeriesData{
                //    Name = formatInstanceName(_.Key.InstanceName),
                //    DataPoints = _.Value.Select(uo=>new DataPoint { Timestamp = uo.Timestamp, Value = uo.Value }).ToList()
                //}).ToList()
            
        }
 public static string GetSubcriptionName(MetricsEndpointConfiguration config) {
     var credentials = config.GetCertificateCloudCredentials();
     var client = new AzureCloudServicesClient(new AzureManagementRestClient(credentials),credentials);
     return client.GetSubscriptionNameSync();
 }