lib/plugins/aws/metrics/awsMetrics.js/AwsMetrics/showMetrics
class AwsMetrics:  showMetrics(metrics) {
    let message = '';

    if (this.options.function) {
      message += `${chalk.yellow.underline(this.options.function)}\n`;
    } else {
      message += `${chalk.yellow.underline('Service wide metrics')}\n`;
    }

    const formattedStartTime = moment(this.options.startTime).format('LLL');
    const formattedEndTime = moment(this.options.endTime).format('LLL');
    message += `${formattedStartTime} - ${formattedEndTime}\n\n`;

    if (metrics && metrics.length > 0) {
      const getDatapointsByLabel = Label =>
        _.chain(metrics)
          .flatten()
          .filter({ Label })
          .map('Datapoints')
          .flatten()
          .value();

      const invocationsCount = _.sumBy(getDatapointsByLabel('Invocations'), 'Sum');
      const throttlesCount = _.sumBy(getDatapointsByLabel('Throttles'), 'Sum');
      const errorsCount = _.sumBy(getDatapointsByLabel('Errors'), 'Sum');
      const durationAverage = _.meanBy(getDatapointsByLabel('Duration'), 'Average') || 0;

      // display the data
      message += `${chalk.yellow('Invocations:', invocationsCount, '\n')}`;
      message += `${chalk.yellow('Throttles:', throttlesCount, '\n')}`;
      message += `${chalk.yellow('Errors:', errorsCount, '\n')}`;
      message += `${chalk.yellow('Duration (avg.):', `${Number(durationAverage.toFixed(2))}ms`)}`;
    } else {
      message += `${chalk.yellow('There are no metrics to show for these options')}`;
    }

    this.serverless.cli.consoleLog(message);
    return BbPromise.resolve(message);
  }