lib/plugins/aws/metrics/awsMetrics.js/AwsMetrics/getMetrics
class AwsMetrics:  getMetrics() {
    const StartTime = this.options.startTime;
    const EndTime = this.options.endTime;
    const hoursDiff = Math.abs(EndTime - StartTime) / 36e5;
    const Period = hoursDiff > 24 ? 3600 * 24 : 3600;
    const functions = this.options.function
      ? [this.serverless.service.getFunction(this.options.function).name]
      : this.serverless.service.getAllFunctionsNames();

    return BbPromise.map(functions, functionName => {
      const commonParams = {
        StartTime,
        EndTime,
        Namespace: 'AWS/Lambda',
        Period,
        Dimensions: [{ Name: 'FunctionName', Value: functionName }],
      };

      const invocationsParams = _.merge({}, commonParams, {
        MetricName: 'Invocations',
        Statistics: ['Sum'],
        Unit: 'Count',
      });
      const throttlesParams = _.merge({}, commonParams, {
        MetricName: 'Throttles',
        Statistics: ['Sum'],
        Unit: 'Count',
      });
      const errorsParams = _.merge({}, commonParams, {
        MetricName: 'Errors',
        Statistics: ['Sum'],
        Unit: 'Count',
      });
      const averageDurationParams = _.merge({}, commonParams, {
        MetricName: 'Duration',
        Statistics: ['Average'],
        Unit: 'Milliseconds',
      });

      const getMetrics = params =>
        this.provider.request('CloudWatch', 'getMetricStatistics', params);

      return BbPromise.all([
        getMetrics(invocationsParams),
        getMetrics(throttlesParams),
        getMetrics(errorsParams),
        getMetrics(averageDurationParams),
      ]).then(metrics => metrics);
    });
  }