2014-10-27 51 views
0

我有一个函数可以获取实例的统计信息。它通过了严格的细节。但不幸的是,我只是获得空的数据点。有任何想法吗?AWS响应中的数据点为空

public Object getMetricStatisticResults(Credentials creds, Amazon.RegionEndpoint region, string instanceID, int period, string[] statistics, DateTime starttime, DateTime endtime) 
     { 
      var client = AWSClientFactory.CreateAmazonCloudWatchClient(creds, region); 
      var dimension = new Dimension 
      { 
       Name = "InstanceID", 
       Value = instanceID 
      }; 

      var request = new GetMetricStatisticsRequest(); 
      request.Dimensions.Add(dimension); 


      var currentTime = DateTime.UtcNow; 

      request.StartTime = starttime; //checked and it is all correct! -5 days 
      request.EndTime = endtime; //checked, showing now value! 

      request.Namespace = "AWS/EC2"; //not sure what this is but added in as per examples 

      request.MetricName = "CPUUtilization"; //what I want to get 
      request.Statistics.Add("Average"); //I want others but reducing to minimum so that I can test the easier part. 
      request.Period = 300; 
      var response = client.GetMetricStatistics(request); 

      if(response.Datapoints.Count > 0) 
      { 
       //never happens 
      } 
      else 
      { 
       //always happens!!! grrrrr 
      } 
     } 

我试图改变该区域的区域,以及(我做了一些google搜索),但并没有解决我的问题,我可以确认选择的是正确的反正。

AWS主控制台中是否存在需要启用的功能?我错过了什么吗?花了很长时间测试不同的东西,但没有真正起作用。非常感谢您的帮助。

谢谢!

回答

0

的问题是与下面的代码行:

{ 
       Name = "InstanceID", 
       Value = instanceID 
      }; 

应该说“实例ID”,注意小“d”结尾。这为我解决了它。 解决方案:

{ 
        Name = "InstanceId", 
        Value = instanceID 
       };