title: Cloudwatch metrics never returning any results
body: <p>I've been trying to get a simple application going that returns some cloudwatch metrics.  I've tried 3 different web examples and none are returning any data.  I can see the data on the AWS console. Perhaps someone can spot my error or point me to a simple example that is know to work?</p>
  
  <p>The principal I want to achieve is:  I want to know when our application gets close to its dynamoDB read/write limits and then increase them.  I assume I need to write some thread that polls asking for stats, and if it reaches say 80% of capacity, increases the limits.</p>
  
  <pre><code>private static void findCloudWatchData() throws InterruptedException {
      AmazonCloudWatchClient cloudWatch = new AmazonCloudWatchClient(new BasicAWSCredentials(key, secret));
      cloudWatch.setEndpoint("monitoring.eu-west-1.amazonaws.com");
  
      GetMetricStatisticsRequest getMetricStatisticsRequest = new GetMetricStatisticsRequest();
  
      GregorianCalendar g = new GregorianCalendar(2012, 9, 17, 12, 0);
  
      getMetricStatisticsRequest.setStartTime(g.getTime());
      g.add(Calendar.DAY_OF_MONTH, 2);
      getMetricStatisticsRequest.setEndTime(g.getTime());
  
      getMetricStatisticsRequest.setNamespace("AWS/DynamoDB");
      getMetricStatisticsRequest.setMetricName("SuccessfulRequestLatency");
      getMetricStatisticsRequest.setPeriod(5*60);
  
      Dimension tableDimension = new Dimension();
      tableDimension.setName("TableName");
      tableDimension.setValue("personalisation.user_favourite-int");
  
      Dimension operationDimension = new Dimension();
      operationDimension.setName("Operation");
      operationDimension.setValue("Query");
  
      getMetricStatisticsRequest.setDimensions(Arrays.asList(tableDimension, operationDimension));
  
      Collection&lt;String&gt; statistics = new ArrayList&lt;String&gt;();
      statistics.add("Average");
  
      getMetricStatisticsRequest.setStatistics(statistics);
      getMetricStatisticsRequest.setUnit(StandardUnit.Count);
  
      //results
      GetMetricStatisticsResult result = cloudWatch.getMetricStatistics(getMetricStatisticsRequest);
      System.err.println(result.getDatapoints().size());  //this returns 0 always
      for (Datapoint p : result.getDatapoints()) {
          System.out.println(p.getTimestamp() + " " + p.getAverage());
      }
   }
  </code></pre>