code: @Override
      public Double getLastHourInstanceNetworkIn(String instanceId,
                                                 long lastUpdated) {
          long offsetInMilliseconds = Math.min(ONE_DAY_MILLI_SECOND,
                  System.currentTimeMillis() - lastUpdated);
          Dimension instanceDimension = new Dimension().withName("InstanceId")
                  .withValue(instanceId);
          GetMetricStatisticsRequest request = new GetMetricStatisticsRequest()
                  .withMetricName("NetworkIn")
                  .withNamespace("AWS/EC2")
                  .withPeriod(60 * 60)
                  // one hour
                  .withDimensions(instanceDimension)
                  // to get metrics a specific
                  // instance
                  .withStatistics("Average")
                  .withStartTime(
                          new Date(new Date().getTime() - offsetInMilliseconds))
                  .withEndTime(new Date());
          GetMetricStatisticsResult result = cloudWatchClient
                  .getMetricStatistics(request);
          // to read data
          List<Datapoint> datapoints = result.getDatapoints();
          if (CollectionUtils.isEmpty(datapoints)) return 0.0;
          Datapoint datapoint = datapoints.get(0);
          return datapoint.getAverage();
      }
docs: /* Averages CPUUtil every minute for the last hour